Merge branch 'master' of git.shimatta.de:mhu/stm32f4-sdio

This commit is contained in:
2020-01-19 20:11:48 +01:00
18 changed files with 18904 additions and 33377 deletions

View File

@@ -136,7 +136,6 @@ sdio_unlock_card()
DSTATUS SDIO_initialize(){
int timeout = 0x3000;
int i;
CMD8_RESP_t res8;
ACMD41_RESP_t resa41;
uint8_t hcs_flag = 0;
@@ -442,20 +441,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;
@@ -467,16 +470,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;

View File

@@ -9,6 +9,7 @@
#define FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_
#include <fatfs/diskio.h>
#include <fatfs/ff.h>
#include <stdint.h>
DSTATUS SDIO_status();