found bug in get response function. compile with O0 works. Further checking required
This commit is contained in:
@@ -23,6 +23,7 @@ extern void SDIO_wait_ms(unsigned int i);
|
||||
|
||||
#define CCRCFAIL 1
|
||||
#define CTIMEOUT 2
|
||||
#define CNOTEXPETED 3
|
||||
|
||||
/* OCR Register Masks */
|
||||
#define OCS_CCS (1<<30)
|
||||
@@ -74,9 +75,9 @@ DSTATUS SDIO_status(){
|
||||
}
|
||||
return returnval;
|
||||
}
|
||||
uint32_t debug;
|
||||
uint32_t debug_timeout;
|
||||
int debug_acmd = 0;
|
||||
volatile uint32_t debug;
|
||||
volatile uint32_t debug_timeout;
|
||||
volatile int debug_acmd = 0;
|
||||
DSTATUS SDIO_initialize(){
|
||||
int timeout = 0x3000;
|
||||
int i;
|
||||
@@ -115,6 +116,7 @@ DSTATUS SDIO_initialize(){
|
||||
debug++;
|
||||
debug_timeout=timeout;
|
||||
do {
|
||||
//SDIO_wait_ms(2);
|
||||
resa41 = SDIO_init_card_ACMD41(hcs_flag);
|
||||
} while((resa41 == ACMD41_RESP_INIT) && (--timeout > 0));
|
||||
|
||||
@@ -381,14 +383,16 @@ void SDIO_wait_cmd_sent() {
|
||||
SDIO->ICR |= SDIO_ICR_CMDSENTC;
|
||||
}
|
||||
|
||||
int SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffer) {
|
||||
int __attribute__((noinline)) __attribute__((optimize("O0"))) SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffer) {
|
||||
uint32_t sdio_status;
|
||||
//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
|
||||
sdio_status = SDIO->STA;
|
||||
if (sdio_status & SDIO_STA_CMDREND) break; //Correct Respone Received
|
||||
if ((sdio_status & 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 ((sdio_status & SDIO_STA_CCRCFAIL)) {
|
||||
if(expectedCMD == 0xff) {
|
||||
break;
|
||||
} else {
|
||||
@@ -397,12 +401,12 @@ int SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *response
|
||||
}
|
||||
|
||||
|
||||
if (SDIO->STA & SDIO_STA_CTIMEOUT)
|
||||
if (sdio_status & SDIO_STA_CTIMEOUT)
|
||||
return -CTIMEOUT;
|
||||
}
|
||||
//Valid Respone Received
|
||||
if (((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) && (expectedCMD != 0xff))
|
||||
return -1; //Not the expected respose
|
||||
return -CNOTEXPETED; //Not the expected respose
|
||||
|
||||
//If case of a correct Response
|
||||
*(responseBuffer++) = SDIO->RESP1;
|
||||
|
Reference in New Issue
Block a user