mirror of https://github.com/ARMmbed/mbed-os.git
Make the initialization sequence more flexible
According to the SD specification v2.00 we this is the right way to initialize a card using the v1 protocol in a forward-compatible way.pull/7774/head
parent
2d247581c6
commit
52f5e0d41a
|
|
@ -274,14 +274,13 @@ int SDBlockDevice::_initialise_card()
|
||||||
return SD_BLOCK_DEVICE_ERROR_NO_DEVICE;
|
return SD_BLOCK_DEVICE_ERROR_NO_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send CMD8
|
// Send CMD8, if the card rejects the command then it's probably using the
|
||||||
if (BD_ERROR_OK != (status = _cmd8())) {
|
// 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;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable CRC
|
|
||||||
status = _cmd(CMD59_CRC_ON_OFF, 0);
|
|
||||||
|
|
||||||
// Read OCR - CMD58 Response contains OCR register
|
// Read OCR - CMD58 Response contains OCR register
|
||||||
if (BD_ERROR_OK != (status = _cmd(CMD58_READ_OCR, 0x0, 0x0, &response))) {
|
if (BD_ERROR_OK != (status = _cmd(CMD58_READ_OCR, 0x0, 0x0, &response))) {
|
||||||
return status;
|
return status;
|
||||||
|
|
@ -333,6 +332,10 @@ int SDBlockDevice::_initialise_card()
|
||||||
_card_type = SDCARD_V1;
|
_card_type = SDCARD_V1;
|
||||||
debug_if(SD_DBG, "Card Initialized: Version 1.x Card\n");
|
debug_if(SD_DBG, "Card Initialized: Version 1.x Card\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable CRC
|
||||||
|
status = _cmd(CMD59_CRC_ON_OFF, 0);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue