Skip to content

Commit

Permalink
Merge pull request #58 from deepikabhavnani/sd_cmd12
Browse files Browse the repository at this point in the history
Should not wait for card to be ready when sending stop command
  • Loading branch information
Deepika authored Sep 6, 2017
2 parents 9439243 + d4d1d87 commit 49262a3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions SDBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,20 +697,23 @@ int SDBlockDevice::_cmd(SDBlockDevice::cmdSupported cmd, uint32_t arg, bool isAc
// Select card and wait for card to be ready before sending next command
// Note: next command will fail if card is not ready
_select();
if (false == _wait_ready(SD_COMMAND_TIMEOUT)) {
debug_if(SD_DBG, "Card not ready yet \n");

// No need to wait for card to be ready when sending the stop command
if (CMD12_STOP_TRANSMISSION != cmd) {
if (false == _wait_ready(SD_COMMAND_TIMEOUT)) {
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
if (isAcmd) {
response = _cmd_spi(CMD55_APP_CMD, 0x0);
}

// Wait for card to be ready after CMD55
if (false == _wait_ready(SD_COMMAND_TIMEOUT)) {
debug_if(SD_DBG, "Card not ready yet \n");
// Wait for card to be ready after CMD55
if (false == _wait_ready(SD_COMMAND_TIMEOUT)) {
debug_if(SD_DBG, "Card not ready yet \n");
}
}

// Send command over SPI interface
Expand Down

0 comments on commit 49262a3

Please sign in to comment.