Skip to content

Commit

Permalink
boards/stm32f746g-disco: add SD Card interface support
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed May 10, 2023
1 parent 8c0c0c5 commit e29320e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
11 changes: 11 additions & 0 deletions boards/stm32f746g-disco/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ endif
ifneq (,$(filter touch_dev,$(USEMODULE)))
USEMODULE += ft5x06
endif

# default to using fatfs on SD card
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEMODULE += fatfs_vfs
USEMODULE += mtd
endif

ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_sdcard_default
USEMODULE += sdmmc
endif
1 change: 1 addition & 0 deletions boards/stm32f746g-disco/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Current hardware support:
| User microphones | - | |
| External Quad-SPI Flash | - | |
| External SDRAM | - | |
| SD Card Interface | x | SDMMC1 on PC8..PC13 and PD2 |

## Flashing the device

Expand Down
1 change: 1 addition & 0 deletions boards/stm32f746g-disco/features-shared.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_ltdc
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_rtt
FEATURES_PROVIDED += periph_sdmmc
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
Expand Down
48 changes: 43 additions & 5 deletions boards/stm32f746g-disco/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static const dma_conf_t dma_config[] = {
{ .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
{ .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
{ .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
{ .stream = 11 }, /* DMA2 Stream 3 - SPI4_RX */
{ .stream = 11 }, /* DMA2 Stream 3 - SPI4_RX Ch5 / SDMMC1 Ch 4 */
{ .stream = 12 }, /* DMA2 Stream 4 - SPI4_TX */
{ .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
};
Expand Down Expand Up @@ -94,7 +94,7 @@ static const uart_conf_t uart_config[] = {
.tx_af = GPIO_AF7,
.bus = APB2,
.irqn = USART1_IRQn,
#ifdef MODULE_PERIPH_DMA
#if IS_USED(MODULE_PERIPH_DMA)
.dma = 0,
.dma_chan = 4
#endif
Expand All @@ -108,7 +108,7 @@ static const uart_conf_t uart_config[] = {
.tx_af = GPIO_AF7,
.bus = APB2,
.irqn = USART6_IRQn,
#ifdef MODULE_PERIPH_DMA
#if IS_USED(MODULE_PERIPH_DMA)
.dma = 1,
.dma_chan = 5
#endif
Expand Down Expand Up @@ -140,7 +140,7 @@ static const spi_conf_t spi_config[] = {
.cs_af = GPIO_AF5,
.rccmask = RCC_APB1ENR_SPI2EN,
.apbbus = APB1,
#ifdef MODULE_PERIPH_DMA
#if IS_USED(MODULE_PERIPH_DMA)
.tx_dma = 4,
.tx_dma_chan = 0,
.rx_dma = 3,
Expand Down Expand Up @@ -260,7 +260,8 @@ static const ltdc_conf_t ltdc_config = {
/* values below come from STM32CubeF7 code and differ from the typical
* values mentioned in the RK043FN48H datasheet. Both sets of values work
* with the display.
* See the discussion in https://community.st.com/s/question/0D50X0000BOvdWP/how-to-set-displays-parameters-
* See the discussion in
* https://community.st.com/s/question/0D50X0000BOvdWP/how-to-set-displays-parameters-
*/
.hsync = 41,
.vsync = 10,
Expand Down Expand Up @@ -321,6 +322,43 @@ static const dwc2_usb_otg_fshs_config_t dwc2_usb_otg_fshs_config[] = {
/** @} */
#endif /* defined(MODULE_PERIPH_USBDEV_HS_ULPI) || DOXYGEN */

/**
* @name SDIO/SDMMC configuration
* @{
*/

/**
* @brief SDIO/SDMMC static configuration struct
*/
static const sdmmc_conf_t sdmmc_config[] = {
{
.dev = SDMMC1,
.bus = APB2,
.rcc_mask = RCC_APB2ENR_SDMMC1EN,
.cd = GPIO_PIN(PORT_C, 13),
.cd_active = 0, /* CD pin is LOW active */
.cd_mode = GPIO_IN_PU, /* Pull-up R12 not soldered by default */
.clk = { GPIO_PIN(PORT_C, 12), GPIO_AF12 },
.cmd = { GPIO_PIN(PORT_D, 2), GPIO_AF12 },
.dat0 = { GPIO_PIN(PORT_C, 8), GPIO_AF12 },
.dat1 = { GPIO_PIN(PORT_C, 9), GPIO_AF12 },
.dat2 = { GPIO_PIN(PORT_C, 10), GPIO_AF12 },
.dat3 = { GPIO_PIN(PORT_C, 11), GPIO_AF12 },
#if IS_USED(MODULE_PERIPH_DMA)
.dma = 5,
.dma_chan = 4,
#endif
.irqn = SDMMC1_IRQn
},
};

/**
* @brief Number of available SDIO/SDMMC peripherals
*/
#define SDMMC_NUMOF ARRAY_SIZE(sdmmc_config)

/** @} */

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit e29320e

Please sign in to comment.