From 1842b2fae3735f523970d9c47e70350c8feea3e6 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Wed, 21 May 2025 13:05:03 +0200 Subject: [PATCH] boards/esp32s3-usb-otg: enable SDMMC peripheral --- boards/esp32s3-usb-otg/Makefile.dep | 8 ++++++- boards/esp32s3-usb-otg/Makefile.features | 1 + boards/esp32s3-usb-otg/doc.txt | 8 ++++++- boards/esp32s3-usb-otg/include/periph_conf.h | 24 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/boards/esp32s3-usb-otg/Makefile.dep b/boards/esp32s3-usb-otg/Makefile.dep index c8b90d8ebb1e..ea5db8e874c9 100644 --- a/boards/esp32s3-usb-otg/Makefile.dep +++ b/boards/esp32s3-usb-otg/Makefile.dep @@ -8,7 +8,13 @@ ifneq (,$(filter vfs_default,$(USEMODULE))) endif ifneq (,$(filter mtd,$(USEMODULE))) - USEMODULE += mtd_sdcard_default + ifneq (,$(filter sdcard_spi,$(USEMODULE))) + # use SD Card in SPI mode if sdcard_spi is explicitly enabled + USEMODULE += mtd_sdcard_default + else + # use SDMMC host for the SD Card otherwise + USEMODULE += mtd_sdmmc_default + endif endif ifneq (,$(filter disp_dev,$(USEMODULE))) diff --git a/boards/esp32s3-usb-otg/Makefile.features b/boards/esp32s3-usb-otg/Makefile.features index b43f63bb5058..3bb2eca3a884 100644 --- a/boards/esp32s3-usb-otg/Makefile.features +++ b/boards/esp32s3-usb-otg/Makefile.features @@ -6,6 +6,7 @@ include $(RIOTBOARD)/common/esp32s3/Makefile.features # additional features provided by the board FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_pwm +FEATURES_PROVIDED += periph_sdmmc FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev diff --git a/boards/esp32s3-usb-otg/doc.txt b/boards/esp32s3-usb-otg/doc.txt index 5202e42275ff..e9bfb370f204 100644 --- a/boards/esp32s3-usb-otg/doc.txt +++ b/boards/esp32s3-usb-otg/doc.txt @@ -47,7 +47,7 @@ The main features of the board are: | 8 MByte Flash | yes | | USB Type-A Host Interface | no | | USB Type-A Device Interface | yes | -| SD Card Slot | yes (SPI mode) | +| SD Card Slot | yes | | LCD Color Display 240 x 240 | yes | ## Hardware {#esp32s3_usb_otg_hardware} @@ -108,6 +108,12 @@ UART_DEV(0):RxD | GPIO44 | USB-to-UART bridge | \ref esp32_uart_interfaces "UA \n +@note +SPI_DEV(1) is only configured if the `sdcard_spi` module is explicitly added to +the `USEMODULE` in the application's Makefile to access the SD card in SPI mode. +By default, the SDMMC host is configured and used by the `periph_sdmmc` +module to access the SD card. + For detailed information about the peripheral configurations of ESP32-S3 boards, see section \ref esp32_peripherals "Common Peripherals". diff --git a/boards/esp32s3-usb-otg/include/periph_conf.h b/boards/esp32s3-usb-otg/include/periph_conf.h index 3c4e3263ca3b..24541bd17da8 100644 --- a/boards/esp32s3-usb-otg/include/periph_conf.h +++ b/boards/esp32s3-usb-otg/include/periph_conf.h @@ -64,6 +64,30 @@ extern "C" { #endif /** @} */ +/** + * @name SD/MMC host controller configuration + * @{ + */ + +/** SDMMC devices */ +static const sdmmc_conf_t sdmmc_config[] = { + { + .slot = SDMMC_SLOT_1, + .cd = GPIO_UNDEF, + .wp = GPIO_UNDEF, + .clk = GPIO36, + .cmd = GPIO35, + .dat0 = GPIO37, + .dat1 = GPIO38, + .dat2 = GPIO33, + .dat3 = GPIO34, + }, +}; + +/** Number of configured SDMMC devices */ +#define SDMMC_CONFIG_NUMOF 1 +/** @} */ + /** * @name SPI configuration *