Skip to content

Commit

Permalink
Merge pull request ARMmbed#50 from LemonBoy/sdcard-init-seq
Browse files Browse the repository at this point in the history
Make the initialization sequence more flexible
  • Loading branch information
Deepika authored Aug 17, 2017
2 parents 48c1b7e + 52f5e0d commit c7347c9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions SDBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,13 @@ int SDBlockDevice::_initialise_card()
return SD_BLOCK_DEVICE_ERROR_NO_DEVICE;
}

// Send CMD8
if (BD_ERROR_OK != (status = _cmd8())) {
// Send CMD8, if the card rejects the command then it's probably using the
// legacy protocol, or is a MMC, or just flat-out broken
status = _cmd8();
if (BD_ERROR_OK != status && SD_BLOCK_DEVICE_ERROR_UNSUPPORTED != status) {
return status;
}

// Disable CRC
status = _cmd(CMD59_CRC_ON_OFF, 0);

// Read OCR - CMD58 Response contains OCR register
if (BD_ERROR_OK != (status = _cmd(CMD58_READ_OCR, 0x0, 0x0, &response))) {
return status;
Expand Down Expand Up @@ -337,6 +336,10 @@ int SDBlockDevice::_initialise_card()
_card_type = SDCARD_V1;
debug_if(SD_DBG, "Card Initialized: Version 1.x Card\n");
}

// Disable CRC
status = _cmd(CMD59_CRC_ON_OFF, 0);

return status;
}

Expand Down

0 comments on commit c7347c9

Please sign in to comment.