start reworking driver to preferred code style
This commit is contained in:
parent
c4166fef74
commit
e91d1ed0bd
8
.gitignore
vendored
8
.gitignore
vendored
@ -7,3 +7,11 @@ Debug
|
||||
*.user.*
|
||||
*.lss
|
||||
*.d
|
||||
stm32f4-sdio.cflags
|
||||
stm32f4-sdio.config
|
||||
stm32f4-sdio.creator
|
||||
stm32f4-sdio.cxxflags
|
||||
stm32f4-sdio.files
|
||||
stm32f4-sdio.includes
|
||||
|
||||
|
||||
|
@ -80,7 +80,6 @@ volatile uint32_t debug_timeout;
|
||||
volatile int debug_acmd = 0;
|
||||
DSTATUS SDIO_initialize(){
|
||||
int timeout = 0x3000;
|
||||
int i;
|
||||
CMD8_RESP_t res8;
|
||||
ACMD41_RESP_t resa41;
|
||||
uint8_t hcs_flag = 0;
|
||||
@ -383,20 +382,24 @@ void SDIO_wait_cmd_sent() {
|
||||
SDIO->ICR |= SDIO_ICR_CMDSENTC;
|
||||
}
|
||||
|
||||
int /*__attribute__((noinline)) __attribute__((optimize("O0")))*/ SDIO_get_response(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t *responseBuffer) {
|
||||
int SDIO_get_response(uint8_t expected_command, uint8_t type_of_answer, uint32_t *response_buffer) {
|
||||
uint32_t sdio_status;
|
||||
|
||||
/* Wait until command isn't active anymore */
|
||||
while (SDIO->STA & SDIO_STA_CMDACT);
|
||||
//Wait for error or success
|
||||
|
||||
/* Wait for error or success */
|
||||
while (1) {
|
||||
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
|
||||
|
||||
/* Check if a valid response was received */
|
||||
if (sdio_status & SDIO_STA_CMDREND)
|
||||
break;
|
||||
if ((sdio_status & SDIO_STA_CMDSENT) && (type_of_answer == NO_ANS)) break; // No response required
|
||||
|
||||
//Exclude ACMD41 and CMD2 from valid CRC check
|
||||
if ((sdio_status & SDIO_STA_CCRCFAIL)) {
|
||||
if(expectedCMD == 0xff) {
|
||||
if(expected_command == 0xff) {
|
||||
break;
|
||||
} else {
|
||||
return -CCRCFAIL;
|
||||
@ -408,16 +411,16 @@ int /*__attribute__((noinline)) __attribute__((optimize("O0")))*/ SDIO_get_respo
|
||||
return -CTIMEOUT;
|
||||
}
|
||||
//Valid Respone Received
|
||||
if (((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expectedCMD) && (expectedCMD != 0xff))
|
||||
if (((SDIO->RESPCMD & SDIO_RESPCMD_RESPCMD) != expected_command) && (expected_command != 0xff))
|
||||
return -CNOTEXPETED; //Not the expected respose
|
||||
|
||||
//If case of a correct Response
|
||||
*(responseBuffer++) = SDIO->RESP1;
|
||||
*(response_buffer++) = SDIO->RESP1;
|
||||
//Long response.
|
||||
if (typeOfAns == LONG_ANS) {
|
||||
*(responseBuffer++) = SDIO->RESP2;
|
||||
*(responseBuffer++) = SDIO->RESP3;
|
||||
*(responseBuffer++) = SDIO->RESP4;
|
||||
if (type_of_answer == LONG_ANS) {
|
||||
*(response_buffer++) = SDIO->RESP2;
|
||||
*(response_buffer++) = SDIO->RESP3;
|
||||
*(response_buffer++) = SDIO->RESP4;
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user