Skip to content

Commit 823a961

Browse files
dhylandsdpgeorge
authored andcommitted
stmhal: Enable sdcard on STM32F7DISC board.
1 parent 3510499 commit 823a961

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎stmhal/boards/STM32F7DISC/mpconfigboard.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define MICROPY_HW_MCU_NAME "STM32F746"
55

66
#define MICROPY_HW_HAS_SWITCH (1)
7-
#define MICROPY_HW_HAS_SDCARD (0)
7+
#define MICROPY_HW_HAS_SDCARD (1)
88
#define MICROPY_HW_HAS_MMA7660 (0)
99
#define MICROPY_HW_HAS_LIS3DSH (0)
1010
#define MICROPY_HW_HAS_LCD (0)
@@ -78,6 +78,11 @@ void STM32F7DISC_board_early_init(void);
7878
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRR = pin->pin_mask)
7979
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRR = (pin->pin_mask << 16))
8080

81+
// SD card detect switch
82+
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)
83+
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
84+
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
85+
8186
// USB config (CN13 - USB OTG FS)
8287
// The Hardware VBUS detect only works on pin PA9. The STM32F7 Discovery uses
8388
// PA9 for VCP_TX functionality and connects the VBUS to pin J12 (so software

‎stmhal/sdcard.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@
3737

3838
#if MICROPY_HW_HAS_SDCARD
3939

40+
#if defined(MCU_SERIES_F7)
41+
42+
// The F7 series calls the peripheral SDMMC rather than SDIO, so provide some
43+
// #defines for backwards compatability.
44+
45+
#define SDIO SDMMC1
46+
47+
#define SDIO_CLOCK_EDGE_RISING SDMMC_CLOCK_EDGE_RISING
48+
#define SDIO_CLOCK_EDGE_FALLING SDMMC_CLOCK_EDGE_FALLING
49+
50+
#define SDIO_CLOCK_BYPASS_DISABLE SDMMC_CLOCK_BYPASS_DISABLE
51+
#define SDIO_CLOCK_BYPASS_ENABLE SDMMC_CLOCK_BYPASS_ENABLE
52+
53+
#define SDIO_CLOCK_POWER_SAVE_DISABLE SDMMC_CLOCK_POWER_SAVE_DISABLE
54+
#define SDIO_CLOCK_POWER_SAVE_ENABLE SDMMC_CLOCK_POWER_SAVE_ENABLE
55+
56+
#define SDIO_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
57+
#define SDIO_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
58+
#define SDIO_BUS_WIDE_8B SDMMC_BUS_WIDE_8B
59+
60+
#define SDIO_HARDWARE_FLOW_CONTROL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
61+
#define SDIO_HARDWARE_FLOW_CONTROL_ENABLE SDMMC_HARDWARE_FLOW_CONTROL_ENABLE
62+
63+
#define SDIO_TRANSFER_CLK_DIV SDMMC_TRANSFER_CLK_DIV
64+
65+
#endif
66+
67+
4068
static SD_HandleTypeDef sd_handle;
4169

4270
void sdcard_init(void) {

0 commit comments

Comments
 (0)