1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

boards/esp32-wrover-kit: add SDMMC support

This commit is contained in:
Gunar Schorcht 2023-07-03 12:19:11 +02:00
parent 7ba9cbe736
commit 517cbc59ff
5 changed files with 66 additions and 21 deletions

View File

@ -18,11 +18,13 @@ config BOARD_ESP32_WROVER_KIT
select HAS_PERIPH_ADC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SDMMC
select HAS_PERIPH_SPI
select HAS_SDCARD_SPI
select HAVE_ILI9341
select HAVE_MTD_SDCARD_DEFAULT
select HAVE_MTD_SDMMC_DEFAULT if !MODULE_SDCARD_SPI
select MODULE_FATFS_VFS if MODULE_VFS_DEFAULT
source "$(RIOTBOARD)/common/esp32/Kconfig"

View File

@ -5,14 +5,17 @@ endif
# Sets up configuration for openocd
USEMODULE += esp_jtag
ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_sdcard_default
endif
# default to using fatfs on SD card
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEMODULE += fatfs_vfs
USEMODULE += mtd
endif
ifneq (,$(filter mtd,$(USEMODULE)))
ifeq (,$(filter sdcard_spi,$(USEMODULE)))
# use mtd_sdmmc_default if sdcard_spi isn't explicitly enabled
USEMODULE += mtd_sdmmc_default
endif
endif
include $(RIOTBOARD)/common/esp32/Makefile.dep

View File

@ -7,6 +7,7 @@ include $(RIOTBOARD)/common/esp32/Makefile.features
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_sdmmc
FEATURES_PROVIDED += periph_spi
# unique features provided by the board

View File

@ -83,7 +83,7 @@ configuration can be overridden by
These abbreviations are used in subsequent tables:
*SDC* = SD-Card interface is used (module **sdcard_spi** is enabled)\n
*SDC* = SD-Card interface is used (module **periph_sdmmc** is enabled)\n
*CAM* = Camera is plugged in/used
<center>
@ -95,12 +95,18 @@ These abbreviations are used in subsequent tables:
| `ADC_LINE(2)` | `GPIO36` | `GPIO36` | - | - | `CAMERA_D4` | \ref esp32_adc_channels |
| `ADC_LINE(3)` | `GPIO39` | `GPIO39` | - | - | `CAMERA_D5` | \ref esp32_adc_channels |
| `PWM_DEV(0):0 / LED0` | `GPIO0` | `GPIO0` | - | - | `LED_RED` / `CAMERA_RESET` | \ref esp32_pwm_channels |
| `PWM_DEV(0):2 / LED2` | `GPIO4` | `GPIO4` | - | - | `LED_BLUE` / `CAMERA_D0` | \ref esp32_pwm_channels |
| `PWM_DEV(0):1 / LED2` | `GPIO4` | `GPIO4` | - | - | `LED_BLUE` / `CAMERA_D0` | \ref esp32_pwm_channels |
| `LED1` | `GPIO2` | `GPIO2` | `GPIO2` | `GPIO2` | `LED_GREEN` | |
| `I2C_DEV(0):SCL` | `GPIO27` | `GPIO27` | `GPIO27` | `GPIO27` | `CAMERA_SIO_C` | \ref esp32_i2c_interfaces |
| `I2C_DEV(0):SDA` | `GPIO26` | `GPIO26` | `GPIO26` | `GPIO27` | `CAMERA_SIO_D` | \ref esp32_i2c_interfaces |
| `I2C_DEV(0):SDA` | `GPIO26` | `GPIO26` | `GPIO26` | `GPIO26` | `CAMERA_SIO_D` | \ref esp32_i2c_interfaces |
| `UART_DEV(0):TX` | `GPIO1` | `GPIO1` | `GPIO1` | `GPIO1` | | \ref esp32_uart_interfaces |
| `UART_DEV(0):RX` | `GPIO3` | `GPIO3` | `GPIO3` | `GPIO3` | | \ref esp32_uart_interfaces |
| `SDMMC_DEV(0):CLK` | `GPIO14` | `GPIO14` | - | - | SD-Card | \ref esp32_sdmmc_interfaces |
| `SDMMC_DEV(0):CMD` | `GPIO15` | `GPIO` | - | - | SD-Card | \ref esp32_sdmmc_interfaces |
| `SDMMC_DEV(0):DAT0` | `GPIO2` | `GPIO2` | - | - | SD-Card | \ref esp32_sdmmc_interfaces |
| `SDMMC_DEV(0):DAT1` | `GPIO4` | `GPIO4` | - | - | SD-Card | \ref esp32_sdmmc_interfaces |
| `SDMMC_DEV(0):DAT2` | `GPIO12` | `GPIO` | - | - | SD-Card | \ref esp32_sdmmc_interfaces |
| `SDMMC_DEV(0):DAT3` | `GPIO13` | `GPIO` | - | - | SD-Card | \ref esp32_sdmmc_interfaces |
| `SPI_DEV(0):SCK` | `GPIO14` | `GPIO14` | `GPIO14` | `GPIO14` | HSPI: SD-Card / Peripherals | \ref esp32_spi_interfaces |
| `SPI_DEV(0):MOSI` | `GPIO15` | `GPIO15` | `GPIO15` | `GPIO15` | HSPI: SD-Card / Peripherals | \ref esp32_spi_interfaces |
| `SPI_DEV(0):CS0` | `GPIO13` | `GPIO13` | `GPIO13` | `GPIO13` | HSPI: SD-Card CS | \ref esp32_spi_interfaces |
@ -133,17 +139,18 @@ These abbreviations are used in subsequent tables:
</center>
Following table shows the default board configuration sorted by GPIOs.
Following table shows the default board configuration sorted by GPIOs depending
on used hardware.
<center>
| Pin | None | SDC | CAM | SDC+CAM | Remarks |
| Pin | None | SDC 4-bit | CAM | SDC 1-bit + CAM | Remarks |
|:-------|:-----------------------|:--------------------|:--------------------|:---------------------------|:-----|
| GPIO0 | PWM_DEV(0):0 / LED0 | PWM_DEV(0):0 / LED0 | CAMERA_RESET | CAMERA_RESET | |
| GPIO1 | UART_DEV(0):TX | UART_DEV(0):TX | UART_DEV(0):TX | UART_DEV(0):TX | |
| GPIO2 | SPI_DEV(0):MISO / LED1 | SPI_DEV(0):MISO | SPI_DEV(0):MISO | SPI_DEV(0):MISO | HSPI |
| GPIO2 | SPI_DEV(0):MISO / LED1 | SDMMC_DEV(0):DAT0 | SPI_DEV(0):MISO | SDMMC_DEV(0):DAT0 | HSPI |
| GPIO3 | UART_DEV(0):RX | UART_DEV(0):RX | UART_DEV(0):RX | UART_DEV(0):RX | |
| GPIO4 | PWM_DEV(0):1 / LED2 | PWM_DEV(0):1 / LED2 | CAMERA_D0 | CAMERA_D0 | |
| GPIO4 | PWM_DEV(0):1 / LED2 | SDMMC_DEV(0):DAT1 | CAMERA_D0 | CAMERA_D0 | |
| GPIO5 | LCD LED | LCD_LED | CAMERA_D1 | CAMERA_D1 | |
| GPIO6 | Flash CLK | Flash CLK | Flash CLK | Flash CLK | |
| GPIO7 | Flash SD0 | Flash SD0 | Flash SD0 | Flash SD0 | |
@ -151,10 +158,10 @@ Following table shows the default board configuration sorted by GPIOs.
| GPIO9 | | | | | |
| GPIO10 | | | | | |
| GPIO11 | Flash CMD | Flash CMD | Flash CMD | Flash CMD | |
| GPIO12 | | | | | |
| GPIO13 | SPI_DEV(0):CS0 | SPI_DEV(0):CS0 | SPI_DEV(0):CS0 | SPI_DEV(0):CS0 | HSPI / SD-Card CS |
| GPIO14 | SPI_DEV(0):SCK | SPI_DEV(0):SCK | SPI_DEV(0):SCK | SPI_DEV(0):SCK | HSPI |
| GPIO15 | SPI_DEV(0):MOSI | SPI_DEV(0):MOSI | SPI_DEV(0):MOSI | SPI_DEV(0):MOSI | HSPI |
| GPIO12 | | SDMMC_DEV(0):DAT2 | | | |
| GPIO13 | SPI_DEV(0):CS0 | SDMMC_DEV(0):DAT3 | SPI_DEV(0):CS0 | | HSPI / SPI SD-Card CS |
| GPIO14 | SPI_DEV(0):SCK | SDMMC_DEV(0):CLK | SPI_DEV(0):SCK | | HSPI |
| GPIO15 | SPI_DEV(0):MOSI | SDMMC_DEV(0):CMD | SPI_DEV(0):MOSI | | HSPI |
| GPIO16 | N/A | N/A | N/A | N/A | see below |
| GPIO17 | N/A | N/A | N/A | N/A | see below |
| GPIO18 | LCD_RESET | LCD_RESET | LCD_RESET | CAMERA_D2 | |

View File

@ -46,6 +46,7 @@
#define PERIPH_CONF_H
#include <stdint.h>
#include "periph_cpu.h"
#ifdef __cplusplus
extern "C" {
@ -109,10 +110,6 @@
*
* LEDs are used as PWM channels for device PWM_DEV(0).
*
* @note As long as the according PWM device is not initialized with function
* pwm_init, the GPIOs declared for this device can be used for other
* purposes.
*
* @note As long as the according PWM device is not initialized with
* the `pwm_init`, the GPIOs declared for this device can be used
* for other purposes.
@ -120,8 +117,10 @@
* @{
*/
#ifndef PWM0_GPIOS
#if !MODULE_ESP32_WROVER_KIT_CAMERA || DOXYGEN
#if (!MODULE_ESP32_WROVER_KIT_CAMERA && !MODULE_PERIPH_SDMMC) || DOXYGEN
#define PWM0_GPIOS { GPIO0, GPIO4 } /**< only available when camera is not connected */
#elif !MODULE_ESP32_WROVER_KIT_CAMERA
#define PWM0_GPIOS { GPIO0 }
#else
#define PWM0_GPIOS { }
#endif
@ -129,6 +128,33 @@
/** @} */
/**
* @name SD/MMC host controller configuration
*
* @warning If the camera is plugged in, the SD Card has to be used in
* 1-bit mode.
* @{
*/
/** SDMMC devices */
static const sdmmc_conf_t sdmmc_config[] = {
{
.slot = SDMMC_SLOT_1,
.cd = GPIO21,
.wp = GPIO_UNDEF,
#if MODULE_ESP32_WROVER_KIT_CAMERA
/* if camera used, only DAT0 is available */
.bus_width = 1,
#else
.bus_width = 4,
#endif
},
};
/** Number of configured SDMMC devices */
#define SDMMC_CONFIG_NUMOF 1
/** @} */
/**
* @name SPI configuration
*
@ -137,6 +163,12 @@
* HSPI is always available and therefore used as SPI_DEV(0)
* VSPI is only available when the camera is not plugged.
*
* @warning In order not to change the index of the SPI devices depending on
* the different hardware configuration options including the camera,
* SPI_DEV(0) is also defined in case of using the SD/MMC host
* controller, by default but cannot be used once an SD card is
* inserted. Use SPI_DEV(1) instead in this case.
*
* @{
*/