1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00

h7: sdio: allow custom clock divider (#14167)

* add SDIO_CLOCK_DIV define to allow compatibility with a wide range of SD cards

* Update src/platform/STM32/sdio_h7xx.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

---------

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
This commit is contained in:
Jacob Dahl 2025-01-16 11:16:05 -09:00 committed by GitHub
parent 892da2d46e
commit 83beeafb0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -285,11 +285,14 @@ static SD_Error_t SD_DoInit(void)
hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; // FIXME untested hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; // FIXME untested
} }
hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE; hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;
#if defined(STM32H730xx) #if !defined(SDIO_CLOCK_DIV)
hsd1.Init.ClockDiv = 2; // 200Mhz / (2 * 2 ) = 50Mhz, used for "UltraHigh speed SD card" only, see HAL_SD_ConfigWideBusOperation, SDMMC_HSpeed_CLK_DIV, SDMMC_NSpeed_CLK_DIV # if defined(STM32H730xx)
#else # define SDIO_CLOCK_DIV 2 // 200Mhz / (2 * 2 ) = 50Mhz, used for "UltraHigh speed SD card" only, see HAL_SD_ConfigWideBusOperation, SDMMC_HSpeed_CLK_DIV, SDMMC_NSpeed_CLK_DIV
hsd1.Init.ClockDiv = 1; // 200Mhz / (2 * 1 ) = 100Mhz, used for "UltraHigh speed SD card" only, see HAL_SD_ConfigWideBusOperation, SDMMC_HSpeed_CLK_DIV, SDMMC_NSpeed_CLK_DIV # else
# define SDIO_CLOCK_DIV 1 // 200Mhz / (2 * 1 ) = 100Mhz, used for "UltraHigh speed SD card" only, see HAL_SD_ConfigWideBusOperation, SDMMC_HSpeed_CLK_DIV, SDMMC_NSpeed_CLK_DIV
# endif
#endif #endif
hsd1.Init.ClockDiv = SDIO_CLOCK_DIV;
status = HAL_SD_Init(&hsd1); // Will call HAL_SD_MspInit status = HAL_SD_Init(&hsd1); // Will call HAL_SD_MspInit
if (status != HAL_OK) { if (status != HAL_OK) {