mirror of https://github.com/ARMmbed/mbed-os.git
Retry command sending on SD card
Sometimes card is busy programming multiple blocks and responds with 0xFF i.e. response. Re-trying 3 times to send the command.pull/7774/head
parent
a7f23635a4
commit
d82f084f11
|
@ -603,7 +603,8 @@ int SDBlockDevice::_cmd(SDBlockDevice::cmdSupported cmd, uint32_t arg, bool isAc
|
||||||
debug_if(SD_DBG, "Card not ready yet \n");
|
debug_if(SD_DBG, "Card not ready yet \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-try command
|
||||||
|
for(int i = 0; i < 3; i++) {
|
||||||
// Send CMD55 for APP command first
|
// Send CMD55 for APP command first
|
||||||
if (isAcmd) {
|
if (isAcmd) {
|
||||||
_cmd_spi(CMD55_APP_CMD, 0x0);
|
_cmd_spi(CMD55_APP_CMD, 0x0);
|
||||||
|
@ -611,7 +612,13 @@ int SDBlockDevice::_cmd(SDBlockDevice::cmdSupported cmd, uint32_t arg, bool isAc
|
||||||
|
|
||||||
// Send command over SPI interface
|
// Send command over SPI interface
|
||||||
response = _cmd_spi(cmd, arg);
|
response = _cmd_spi(cmd, arg);
|
||||||
debug_if(_dbg, "CMD:%d \t arg:0x%x \t Response:0x%x \n", cmd, arg, response);
|
if (R1_NO_RESPONSE == response) {
|
||||||
|
debug_if(SD_DBG, "No response CMD:%d \n", cmd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Pass the response to the command call if required
|
// Pass the response to the command call if required
|
||||||
if (NULL != resp) {
|
if (NULL != resp) {
|
||||||
*resp = response;
|
*resp = response;
|
||||||
|
|
Loading…
Reference in New Issue