Fix for Toshiba FlashAir (or other) SD card initialization - add clock cycles between sending CMD0 and CMD8. Redone for MK3 branch)

This commit is contained in:
rhounsell 2019-08-08 15:45:59 -04:00
parent f40663408f
commit 4e58a112e8
2 changed files with 17 additions and 0 deletions

View File

@ -319,6 +319,21 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
goto fail; goto fail;
} }
} }
// send 0xFF until 0xFF received to give card some clock cycles
SERIAL_ECHOLNRPGM(PSTR("Sending 0xFF"));
spiSend(0XFF);
while ((status_ = spiRec()) != 0xFF)
{
spiSend(0XFF);
if (((uint16_t)_millis() - t0) > SD_CARD_ERROR_FF_TIMEOUT)
{
error(SD_CARD_ERROR_CMD8);
SERIAL_ECHOLNRPGM(PSTR("No 0xFF received"));
goto fail;
}
}
// check SD version // check SD version
if ((cardCommand(CMD8, 0x1AA) & R1_ILLEGAL_COMMAND)) { if ((cardCommand(CMD8, 0x1AA) & R1_ILLEGAL_COMMAND)) {
type(SD_CARD_TYPE_SD1); type(SD_CARD_TYPE_SD1);

View File

@ -105,6 +105,8 @@ uint8_t const SD_CARD_ERROR_SCK_RATE = 0X18;
uint8_t const SD_CARD_ERROR_INIT_NOT_CALLED = 0X19; uint8_t const SD_CARD_ERROR_INIT_NOT_CALLED = 0X19;
/** crc check error */ /** crc check error */
uint8_t const SD_CARD_ERROR_CRC = 0X20; uint8_t const SD_CARD_ERROR_CRC = 0X20;
/** no response to sent 0xFF */
uint8_t const SD_CARD_ERROR_FF_TIMEOUT = 0X21;
/** Toshiba FlashAir: iSDIO */ /** Toshiba FlashAir: iSDIO */
uint8_t const SD_CARD_ERROR_CMD48 = 0x80; uint8_t const SD_CARD_ERROR_CMD48 = 0x80;