Skip to content

Commit 2879351

Browse files
authored
Merge pull request #50 from fpistm/enhancement
Support of STM32L5xx and STM32U5xx
2 parents b9bdcf2 + 25d4a9e commit 2879351

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/bsp_sd.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,20 @@
5353
#endif
5454

5555
#define SD_CLK_EDGE SDMMC_CLOCK_EDGE_RISING
56-
#define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE
56+
#if defined(SDMMC_CLOCK_BYPASS_DISABLE)
57+
#define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE
58+
#endif
5759
#define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE
5860
#define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
5961
#define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
6062
#define SD_BUS_WIDE_8B SDMMC_BUS_WIDE_8B
6163
#define SD_HW_FLOW_CTRL_ENABLE SDMMC_HARDWARE_FLOW_CONTROL_ENABLE
6264
#define SD_HW_FLOW_CTRL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
6365

64-
#ifdef STM32H7xx
65-
#define SD_CLK_DIV 1
66-
#else
66+
#if defined(SDMMC_TRANSFER_CLK_DIV)
6767
#define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV
68+
#else
69+
#define SD_CLK_DIV SDMMC_NSpeed_CLK_DIV
6870
#endif
6971

7072
#ifdef SDMMC_TRANSCEIVER_ENABLE
@@ -77,7 +79,9 @@
7779
#define SD_CLK_ENABLE __HAL_RCC_SDIO_CLK_ENABLE
7880
#define SD_CLK_DISABLE __HAL_RCC_SDIO_CLK_DISABLE
7981
#define SD_CLK_EDGE SDIO_CLOCK_EDGE_RISING
80-
#define SD_CLK_BYPASS SDIO_CLOCK_BYPASS_DISABLE
82+
#if defined(SDIO_CLOCK_BYPASS_DISABLE)
83+
#define SD_CLK_BYPASS SDIO_CLOCK_BYPASS_DISABLE
84+
#endif
8185
#define SD_CLK_PWR_SAVE SDIO_CLOCK_POWER_SAVE_DISABLE
8286
#define SD_BUS_WIDE_1B SDIO_BUS_WIDE_1B
8387
#define SD_BUS_WIDE_4B SDIO_BUS_WIDE_4B
@@ -132,7 +136,7 @@ uint8_t BSP_SD_Init(void)
132136
uSdHandle.Instance = SD_INSTANCE;
133137

134138
uSdHandle.Init.ClockEdge = SD_CLK_EDGE;
135-
#if !defined(STM32L4xx) && !defined(STM32H7xx)
139+
#if defined(SD_CLK_BYPASS)
136140
uSdHandle.Init.ClockBypass = SD_CLK_BYPASS;
137141
#endif
138142
uSdHandle.Init.ClockPowerSave = SD_CLK_PWR_SAVE;

src/bsp_sd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Please update the core or install previous library version."
9191
#endif
9292
#endif
9393

94+
#ifndef GPIO_PIN_All
95+
#define GPIO_PIN_All GPIO_PIN_ALL
96+
#endif
97+
9498
/* SD Exported Functions */
9599
uint8_t BSP_SD_Init(void);
96100
uint8_t BSP_SD_DeInit(void);

0 commit comments

Comments
 (0)