diff --git a/fatfs/shimatta_sdio_driver/shimatta_sdio-driver.c b/fatfs/shimatta_sdio_driver/shimatta_sdio-driver.c index 3f04205..cff98c4 100644 --- a/fatfs/shimatta_sdio_driver/shimatta_sdio-driver.c +++ b/fatfs/shimatta_sdio_driver/shimatta_sdio-driver.c @@ -240,16 +240,14 @@ void SDIO_wait_cmd_sent() { } int SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffer) { - //Return with success because no data is needed - if (typeOfAns == NO_ANS) return 0; - //Wait for error or success while (1) { if (SDIO->STA & SDIO_STA_CMDREND) break; //Correct Respone Received + if ((SDIO->STA & SDIO_STA_CMDSENT) && (typeOfAns == NO_ANS)) break; // No response required //Exclude ACMD41 and CMD2 from valid CRC check if ((SDIO->STA & SDIO_STA_CCRCFAIL)) { - if(expectedCMD == 0x3f) { // TODO: This seems odd.. + if(expectedCMD == 0xff) { // TODO: This seems odd.. break; } else return CCRCFAIL; @@ -260,7 +258,8 @@ int SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *response return CTIMEOUT; } //Valid Respone Received - if ((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) return -1; //Not the expected respose + if (((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) && expectedCMD != 0xff) + return -1; //Not the expected respose //If case of a correct Response *(responseBuffer++) = SDIO->RESP1; @@ -302,7 +301,7 @@ ACMD41_RESP_t SDIO_send_ACMD41(uint8_t HCS){ do { SDIO_send_cmd(41, (HCS ? (1<<30) : 0) | (1<<28), SHORT_ANS); - if (!SDIO_get_response(0x3F, SHORT_ANS, &response)) { + if (!SDIO_get_response(0xFF, SHORT_ANS, &response)) { if (response & OCS_BUSY) { // Card is ready... Who knows why this bit is called busy... if (response & OCS_CCS) { return ACMD41_RESP_SDXC; @@ -326,7 +325,7 @@ int SDIO_send_CMD2() { int retry = 0x20; do { SDIO_send_cmd(2, 0, LONG_ANS); - if (!SDIO_get_response(0x3F, LONG_ANS, response)) return 0; + if (!SDIO_get_response(0xFF, LONG_ANS, response)) return 0; }while(retry-- > 0); }