Skip to content

Support of STM32L5xx and STM32U5xx #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/bsp_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@
#endif

#define SD_CLK_EDGE SDMMC_CLOCK_EDGE_RISING
#define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE
#if defined(SDMMC_CLOCK_BYPASS_DISABLE)
#define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE
#endif
#define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE
#define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
#define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
#define SD_BUS_WIDE_8B SDMMC_BUS_WIDE_8B
#define SD_HW_FLOW_CTRL_ENABLE SDMMC_HARDWARE_FLOW_CONTROL_ENABLE
#define SD_HW_FLOW_CTRL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE

#ifdef STM32H7xx
#define SD_CLK_DIV 1
#else
#if defined(SDMMC_TRANSFER_CLK_DIV)
#define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV
#else
#define SD_CLK_DIV SDMMC_NSpeed_CLK_DIV
#endif

#ifdef SDMMC_TRANSCEIVER_ENABLE
Expand All @@ -77,7 +79,9 @@
#define SD_CLK_ENABLE __HAL_RCC_SDIO_CLK_ENABLE
#define SD_CLK_DISABLE __HAL_RCC_SDIO_CLK_DISABLE
#define SD_CLK_EDGE SDIO_CLOCK_EDGE_RISING
#define SD_CLK_BYPASS SDIO_CLOCK_BYPASS_DISABLE
#if defined(SDIO_CLOCK_BYPASS_DISABLE)
#define SD_CLK_BYPASS SDIO_CLOCK_BYPASS_DISABLE
#endif
#define SD_CLK_PWR_SAVE SDIO_CLOCK_POWER_SAVE_DISABLE
#define SD_BUS_WIDE_1B SDIO_BUS_WIDE_1B
#define SD_BUS_WIDE_4B SDIO_BUS_WIDE_4B
Expand Down Expand Up @@ -132,7 +136,7 @@ uint8_t BSP_SD_Init(void)
uSdHandle.Instance = SD_INSTANCE;

uSdHandle.Init.ClockEdge = SD_CLK_EDGE;
#if !defined(STM32L4xx) && !defined(STM32H7xx)
#if defined(SD_CLK_BYPASS)
uSdHandle.Init.ClockBypass = SD_CLK_BYPASS;
#endif
uSdHandle.Init.ClockPowerSave = SD_CLK_PWR_SAVE;
Expand Down
4 changes: 4 additions & 0 deletions src/bsp_sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Please update the core or install previous library version."
#endif
#endif

#ifndef GPIO_PIN_All
#define GPIO_PIN_All GPIO_PIN_ALL
#endif

/* SD Exported Functions */
uint8_t BSP_SD_Init(void);
uint8_t BSP_SD_DeInit(void);
Expand Down