Browse Source

stmhal: Enable sdcard on STM32F7DISC board.

pull/1554/merge
Dave Hylands 9 years ago
committed by Damien George
parent
commit
823a961ecc
  1. 7
      stmhal/boards/STM32F7DISC/mpconfigboard.h
  2. 28
      stmhal/sdcard.c

7
stmhal/boards/STM32F7DISC/mpconfigboard.h

@ -4,7 +4,7 @@
#define MICROPY_HW_MCU_NAME "STM32F746" #define MICROPY_HW_MCU_NAME "STM32F746"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_SDCARD (0) #define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (0) #define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0) #define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (0) #define MICROPY_HW_HAS_LCD (0)
@ -78,6 +78,11 @@ void STM32F7DISC_board_early_init(void);
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRR = pin->pin_mask) #define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRR = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRR = (pin->pin_mask << 16)) #define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRR = (pin->pin_mask << 16))
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
// USB config (CN13 - USB OTG FS) // USB config (CN13 - USB OTG FS)
// The Hardware VBUS detect only works on pin PA9. The STM32F7 Discovery uses // The Hardware VBUS detect only works on pin PA9. The STM32F7 Discovery uses
// PA9 for VCP_TX functionality and connects the VBUS to pin J12 (so software // PA9 for VCP_TX functionality and connects the VBUS to pin J12 (so software

28
stmhal/sdcard.c

@ -37,6 +37,34 @@
#if MICROPY_HW_HAS_SDCARD #if MICROPY_HW_HAS_SDCARD
#if defined(MCU_SERIES_F7)
// The F7 series calls the peripheral SDMMC rather than SDIO, so provide some
// #defines for backwards compatability.
#define SDIO SDMMC1
#define SDIO_CLOCK_EDGE_RISING SDMMC_CLOCK_EDGE_RISING
#define SDIO_CLOCK_EDGE_FALLING SDMMC_CLOCK_EDGE_FALLING
#define SDIO_CLOCK_BYPASS_DISABLE SDMMC_CLOCK_BYPASS_DISABLE
#define SDIO_CLOCK_BYPASS_ENABLE SDMMC_CLOCK_BYPASS_ENABLE
#define SDIO_CLOCK_POWER_SAVE_DISABLE SDMMC_CLOCK_POWER_SAVE_DISABLE
#define SDIO_CLOCK_POWER_SAVE_ENABLE SDMMC_CLOCK_POWER_SAVE_ENABLE
#define SDIO_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
#define SDIO_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
#define SDIO_BUS_WIDE_8B SDMMC_BUS_WIDE_8B
#define SDIO_HARDWARE_FLOW_CONTROL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
#define SDIO_HARDWARE_FLOW_CONTROL_ENABLE SDMMC_HARDWARE_FLOW_CONTROL_ENABLE
#define SDIO_TRANSFER_CLK_DIV SDMMC_TRANSFER_CLK_DIV
#endif
static SD_HandleTypeDef sd_handle; static SD_HandleTypeDef sd_handle;
void sdcard_init(void) { void sdcard_init(void) {

Loading…
Cancel
Save