From 9bce46516a45c81baad5dd4bd22ffb4552978201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 27 Sep 2016 17:34:06 +0200 Subject: [PATCH] implemented clock switch --- .../shimatta_sdio-driver.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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