diff --git a/FATFS/shimatta_sdio_driver/shimatta_sdio-driver.c b/FATFS/shimatta_sdio_driver/shimatta_sdio-driver.c index 239862e..6107854 100644 --- a/FATFS/shimatta_sdio_driver/shimatta_sdio-driver.c +++ b/FATFS/shimatta_sdio_driver/shimatta_sdio-driver.c @@ -28,7 +28,7 @@ typedef enum {ACMD41_RESP_INIT, ACMD41_RESP_ERR, ACMD41_RESP_SDSC, ACMD41_RESP_S typedef enum {CMD8_RESP_TIMEOUT, CMD8_RESP_ACK, CMD8_RESP_ERR} CMD8_RESP_t; typedef uint8_t CID_t; -void SDIO_InitModule(); +void initModuleHw(); int SDIO_sendCmd(uint8_t CMD, uint32_t arg, uint8_t expectedAns); int SDIO_getResp(uint8_t expectedCMD, uint8_t typeOfAns, uint32_t* responseBuffer); @@ -45,7 +45,7 @@ CMD8_RESP_t SDIO_send_CMD8(); void initDetectandProtectionPins(); int checkNotInserted(); // Returns 0 if inserted! int checkWriteProtection(); // returns 0 if write protected - +void switchPrescaler(uint8_t clkdiv); //BYTE rxtxbuffer[1<AHB1ENR |= PORTCLKMASK; RCC->APB2ENR |= RCC_APB2ENR_SDIOEN; @@ -209,6 +213,15 @@ void SDIO_InitModule(){ } +void switchPrescaler(uint8_t clkdiv) { + SDIO->POWER = 0; + __DSB(); + SDIO->CLKCR &= ~SDIO_CLKCR_CLKDIV; // Clear prescaler + SDIO->CLKCR |= (SDIO_CLKCR_CLKDIV & clkdiv); // Set bits + __DSB(); + SDIO->POWER = SDIO_POWER_PWRCTRL_0 | SDIO_POWER_PWRCTRL_1; +} + //Send Command //Clear respone Flags