Skip to content

Commit

Permalink
cpu/sam0_common: add SDMMC support
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Sep 23, 2023
1 parent 33d1e82 commit 6ab9277
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpu/sam0_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ config CPU_COMMON_SAM0
select HAS_PERIPH_I2C_RECONFIGURE
select HAS_PERIPH_RTT_SET_COUNTER
select HAS_PERIPH_RTT_OVERFLOW
select HAS_PERIPH_SDMMC_AUTO_CMD12
select HAS_PERIPH_SDMMC_HS
select HAS_PERIPH_SDMMC_MMC
select HAS_PERIPH_SDMMC_SDHC
select HAS_PERIPH_SPI_RECONFIGURE
select HAS_PERIPH_SPI_GPIO_MODE
select HAS_PERIPH_TIMER_PERIODIC
Expand Down
4 changes: 4 additions & 0 deletions cpu/sam0_common/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ ifneq (,$(filter periph_spi,$(USEMODULE)))
USEMODULE += periph_spi_gpio_mode
endif

ifneq (,$(filter periph_sdmmc,$(USEMODULE)))
USEMODULE += sdmmc_sdhc
endif

# include sam0 common periph drivers
USEMODULE += sam0_common_periph

Expand Down
4 changes: 4 additions & 0 deletions cpu/sam0_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_i2c_reconfigure
FEATURES_PROVIDED += periph_rtt_set_counter
FEATURES_PROVIDED += periph_rtt_overflow
FEATURES_PROVIDED += periph_sdmmc_auto_cmd12
FEATURES_PROVIDED += periph_sdmmc_hs
FEATURES_PROVIDED += periph_sdmmc_mmc
FEATURES_PROVIDED += periph_sdmmc_sdhc
FEATURES_PROVIDED += periph_spi_reconfigure
FEATURES_PROVIDED += periph_spi_gpio_mode
FEATURES_PROVIDED += periph_timer_periodic # implements timer_set_periodic()
Expand Down
19 changes: 19 additions & 0 deletions cpu/sam0_common/include/periph_cpu_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,25 @@ typedef struct {
} sam0_common_usb_config_t;
#endif /* USB_INST_NUM */

/**
* @brief SDIO/SDMMC buffer alignment for SDHC because of DMA/FIFO buffer restrictions
*/
#define SDMMC_CPU_DMA_ALIGNMENT 4

/**
* @brief SDIO/SDMMC buffer instantiation requirement for SDHC
*/
#define SDMMC_CPU_DMA_REQUIREMENTS __attribute__((aligned(SDMMC_CPU_DMA_ALIGNMENT)))

/**
* @brief SDHC peripheral configuration
*/
typedef struct {
void *sdhc; /**< SDHC peripheral */
gpio_t cd; /**< Card Detect pin (must be GPIO_UNDEF if not connected) */
gpio_t wp; /**< Write Protect pin (must be GPIO_UNDEF if not connected) */
} sdhc_conf_t;

/**
* @name WDT upper and lower bound times in ms
* @{
Expand Down
3 changes: 3 additions & 0 deletions cpu/sam0_common/include/sdhc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* @ingroup cpu_sam0_common
* @brief SD card interface functions for sam0 class devices
*
* @warning This driver is deprecated. Use the `sdmmc` driver module
* instead. You can refer to the `same54-xpro´ board as an example
* on how to use it.
* @{
*
* @file
Expand Down

0 comments on commit 6ab9277

Please sign in to comment.