fixed clock switch

This commit is contained in:
Mario Hüttel 2016-09-27 17:41:53 +02:00
parent 9bce46516a
commit 1844e46167

View File

@ -214,12 +214,11 @@ void initModuleHw(){
} }
void switchPrescaler(uint8_t clkdiv) { void switchPrescaler(uint8_t clkdiv) {
SDIO->POWER = 0; uint32_t reg;
__DSB(); reg = SDIO->CLKCR;
SDIO->CLKCR &= ~SDIO_CLKCR_CLKDIV; // Clear prescaler reg &= ~SDIO_CLKCR_CLKDIV; // Clear prescaler
SDIO->CLKCR |= (SDIO_CLKCR_CLKDIV & clkdiv); // Set bits reg |= (SDIO_CLKCR_CLKDIV & clkdiv); // Set bits
__DSB(); SDIO->CLKCR = reg;
SDIO->POWER = SDIO_POWER_PWRCTRL_0 | SDIO_POWER_PWRCTRL_1;
} }