@@ -780,79 +780,78 @@ uint8_t Sd2Card::isBusy(void) {
780780 \param[in] setLock true if the card should be locked, false if it should be unlocked
781781 \param[in] pwd password to lock/unlock the card
782782
783- \return true if the locking was successful
783+ \return true if the locking was successful
784784*/
785785bool Sd2Card::lockCard (bool setLock, const char *pwd){
786- if (!isBusy ()){
787- int16_t i;
788- uint8_t pwd_len = sizeof (pwd);
789- bool locked = false ;
790-
791- if (cardCommand (CMD42, 0 ) != 0 ){
792- return false ;
793- }
794-
795- spiSend (DATA_START_BLOCK);
796- if (setLock) {
797- spiSend (SET_CARD_PWD & 0x07 );
798- }
799- else {
800- spiSend (CLEAR_CARD_PWD & 0x07 );
801- }
802-
803- spiSend (pwd_len);
804- for (i=0 ; i<512 ; i++){
805- if (i<pwd_len){
806- spiSend (pwd[i]);
807- }
808- else {
809- spiSend (0xFF );
810- }
811- }
812-
813- locked = getCardStatus ();
814-
815- spiSend (0xFF );
816- spiSend (0xFF );
817-
818- i = 0xFFFF ;
819- while (isBusy () && (--i));
820-
821- return locked;
822- }
786+ if (!isBusy ()){
787+ int16_t i;
788+ uint8_t pwd_len = sizeof (pwd);
789+ bool locked = false ;
790+
791+ if (cardCommand (CMD42, 0 ) != 0 ){
792+ return false ;
793+ }
794+
795+ spiSend (DATA_START_BLOCK);
796+ if (setLock) {
797+ spiSend (SET_CARD_PWD & 0x07 );
798+ }
799+ else {
800+ spiSend (CLEAR_CARD_PWD & 0x07 );
801+ }
802+
803+ spiSend (pwd_len);
804+ for (i=0 ; i<512 ; i++){
805+ if (i<pwd_len){
806+ spiSend (pwd[i]);
807+ }
808+ else {
809+ spiSend (0xFF );
810+ }
811+ }
812+
813+ locked = getCardStatus ();
814+
815+ spiSend (0xFF );
816+ spiSend (0xFF );
817+
818+ i = 0xFFFF ;
819+ while (isBusy () && (--i));
820+
821+ return locked;
822+ }
823823}
824824
825825/* * Completly erase a card
826- !! Use with caution !! this removes everything from a card, even the file system.
827- Use this to remove a lock with an unknown password from a card.
828-
829- \return true if the erase was successful
826+ !! Use with caution !! this removes everything from a card, even the file system.
827+ Use this to remove a lock with an unknown password from a card.
828+
829+ \return true if the erase was successful
830830*/
831831bool Sd2Card::forceEraseCard (void ) {
832- // set block size to 512 bytes
833- cardCommand (CMD16, 1 );
834-
835- // enable
836- if (cardCommand (CMD42, 0 ) != 0 ){
837- return false ;
838- }
839-
840- spiSend (DATA_START_BLOCK);
841- spiSend (FORCE_ERASE);
842-
843- return true ;
832+ // set block size to 512 bytes
833+ cardCommand (CMD16, 1 );
834+
835+ // enable
836+ if (cardCommand (CMD42, 0 ) != 0 ){
837+ return false ;
838+ }
839+
840+ spiSend (DATA_START_BLOCK);
841+ spiSend (FORCE_ERASE);
842+
843+ return true ;
844844}
845845
846846/* * Check status of card lock
847-
848- \return true if card is locked
847+ \return true if card is locked
849848*/
850849bool Sd2Card::getCardStatus (void ) {
851- bool cardOK = true ;
852-
853- if (cardCommand (CMD13, 0 ) || spiRec ()) {
854- cardOK = false ;
855- }
856-
857- return cardOK;
850+ bool cardOK = true ;
851+
852+ if (cardCommand (CMD13, 0 ) || spiRec ()) {
853+ cardOK = false ;
854+ }
855+
856+ return cardOK;
858857}
0 commit comments