|
|
|
|
|
|
|
|
|
|
|
|
|
|
// command to go idle in SPI mode
|
|
|
// command to go idle in SPI mode
|
|
|
while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) {
|
|
|
while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) {
|
|
|
if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
|
|
|
|
|
|
|
|
|
if (((uint16_t)(millis() - t0)) > SD_INIT_TIMEOUT) {
|
|
|
error(SD_CARD_ERROR_CMD0);
|
|
|
error(SD_CARD_ERROR_CMD0);
|
|
|
goto fail;
|
|
|
goto fail;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {
|
|
|
while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {
|
|
|
// check for timeout
|
|
|
// check for timeout
|
|
|
if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) {
|
|
|
|
|
|
|
|
|
if (((uint16_t)(millis() - t0)) > SD_INIT_TIMEOUT) {
|
|
|
error(SD_CARD_ERROR_ACMD41);
|
|
|
error(SD_CARD_ERROR_ACMD41);
|
|
|
goto fail;
|
|
|
goto fail;
|
|
|
}
|
|
|
}
|