diff --git a/boards/same54-xpro/Kconfig b/boards/same54-xpro/Kconfig index 371d51cf14..80bc1ecd6e 100644 --- a/boards/same54-xpro/Kconfig +++ b/boards/same54-xpro/Kconfig @@ -27,5 +27,6 @@ config BOARD_SAME54_XPRO select HAVE_SAUL_GPIO select HAVE_MTD_SPI_NOR select HAVE_AT24MAC + select HAVE_SAM0_SDHC # This specific board requires SPI_ON_QSPI for the MTD_SPI_NOR select MODULE_PERIPH_SPI_ON_QSPI if MODULE_MTD_SPI_NOR diff --git a/boards/same54-xpro/Makefile.dep b/boards/same54-xpro/Makefile.dep index e2b4474207..b17e553e40 100644 --- a/boards/same54-xpro/Makefile.dep +++ b/boards/same54-xpro/Makefile.dep @@ -10,6 +10,7 @@ ifneq (,$(filter mtd,$(USEMODULE))) FEATURES_REQUIRED += periph_spi_on_qspi USEMODULE += mtd_spi_nor USEMODULE += mtd_at24cxxx at24mac + USEMODULE += sam0_sdhc endif # enables sam0_eth as default network device @@ -17,8 +18,9 @@ ifneq (,$(filter netdev_default,$(USEMODULE))) USEMODULE += sam0_eth endif -# default to using littlefs2 on the external flash +# default to using littlefs2 on the external flash and fatfs on SD card ifneq (,$(filter vfs_default,$(USEMODULE))) USEPKG += littlefs2 + USEMODULE += fatfs_vfs USEMODULE += mtd endif diff --git a/boards/same54-xpro/board.c b/boards/same54-xpro/board.c index 10331bae3c..9bdd448c41 100644 --- a/boards/same54-xpro/board.c +++ b/boards/same54-xpro/board.c @@ -20,10 +20,13 @@ #include "board.h" #include "periph/gpio.h" -#include "mtd_spi_nor.h" #include "timex.h" +#ifdef MODULE_VFS_DEFAULT +#include "vfs_default.h" +#endif -#ifdef MODULE_MTD +#ifdef MODULE_MTD_SPI_NOR +#include "mtd_spi_nor.h" /* N25Q256A or SST26VF064B */ static const mtd_spi_nor_params_t _same54_nor_params = { .opcode = &mtd_spi_nor_opcode_default, @@ -50,6 +53,12 @@ static mtd_spi_nor_t same54_nor_dev = { }; mtd_dev_t *mtd0 = (mtd_dev_t *)&same54_nor_dev; +#ifdef MODULE_VFS_DEFAULT +VFS_AUTO_MOUNT(littlefs2, VFS_MTD(same54_nor_dev), VFS_DEFAULT_NVM(0), 0); +#endif +#endif /* MODULE_MTD_SPI_NOR */ + +#ifdef MODULE_MTD_AT24CXXX #include "mtd_at24cxxx.h" #include "at24cxxx_params.h" static at24cxxx_t at24cxxx_dev; @@ -61,9 +70,23 @@ static mtd_at24cxxx_t at24mac_dev = { .params = at24cxxx_params, }; mtd_dev_t *mtd1 = (mtd_dev_t *)&at24mac_dev; +#endif /* MODULE_MTD_AT24CXXX */ + +#ifdef MODULE_SAM0_SDHC +#include "mtd_sam0_sdhc.h" +static mtd_sam0_sdhc_t sdhc_dev = { + .base = { + .driver = &mtd_sam0_sdhc_driver, + }, + .state = { + .dev = SDHC1, + .cd = GPIO_PIN(PD, 20), + .wp = GPIO_PIN(PD, 21), + }, + }; +mtd_dev_t *mtd2 = (mtd_dev_t *)&sdhc_dev; #ifdef MODULE_VFS_DEFAULT -#include "vfs_default.h" -VFS_AUTO_MOUNT(littlefs2, VFS_MTD(same54_nor_dev), VFS_DEFAULT_NVM(0), 0); +VFS_AUTO_MOUNT(fatfs, VFS_MTD(sdhc_dev), VFS_DEFAULT_SD(0), 1); #endif -#endif /* MODULE_MTD */ +#endif /* MODULE_SAM0_SDHC */ diff --git a/boards/same54-xpro/include/board.h b/boards/same54-xpro/include/board.h index 45f57e455f..737a0fe480 100644 --- a/boards/same54-xpro/include/board.h +++ b/boards/same54-xpro/include/board.h @@ -72,10 +72,11 @@ extern "C" { * @name MTD configuration * @{ */ -extern mtd_dev_t *mtd0, *mtd1; +extern mtd_dev_t *mtd0, *mtd1, *mtd2; #define MTD_0 mtd0 #define MTD_1 mtd1 -#define MTD_NUMOF 2 +#define MTD_2 mtd2 +#define MTD_NUMOF 3 /** @} */ /** diff --git a/boards/same54-xpro/include/periph_conf.h b/boards/same54-xpro/include/periph_conf.h index fbd66a1024..d8df9a4e71 100644 --- a/boards/same54-xpro/include/periph_conf.h +++ b/boards/same54-xpro/include/periph_conf.h @@ -360,6 +360,17 @@ static const adc_conf_chan_t adc_channels[] = { #define DAC_VREF DAC_CTRLB_REFSEL_VREFPU /** @} */ +/** + * @name SDHC configuration + * + * This is entirely optional, but allows us to save a few bytes if only + * a single SDHC instance is used. + * @{ + */ +#define SDHC_DEV SDHC1 /**< The SDHC instance to use */ +#define SDHC_DEV_ISR isr_sdhc1 /**< Interrupt service routing for SDHC1 */ +/** @} */ + /** * @name Ethernet peripheral configuration * @{ diff --git a/dist/tools/doccheck/exclude_patterns b/dist/tools/doccheck/exclude_patterns index 16138cb027..3de636f22f 100644 --- a/dist/tools/doccheck/exclude_patterns +++ b/dist/tools/doccheck/exclude_patterns @@ -4906,11 +4906,13 @@ boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member LED0_TOGGLE \(macro boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member LED_PORT \(macro definition\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member MTD_0 \(macro definition\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member MTD_1 \(macro definition\) of file board\.h is not documented\. +boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member MTD_2 \(macro definition\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member MTD_NUMOF \(macro definition\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member XTIMER_HZ \(macro definition\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member XTIMER_WIDTH \(macro definition\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member mtd0 \(variable\) of file board\.h is not documented\. boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member mtd1 \(variable\) of file board\.h is not documented\. +boards/same54\-xpro/include/board\.h:[0-9]+: warning: Member mtd2 \(variable\) of file board\.h is not documented\. boards/same54\-xpro/include/eui_provider_params\.h:[0-9]+: warning: Member EUI48_PROVIDER_FUNC \(macro definition\) of file eui_provider_params\.h is not documented\. boards/same54\-xpro/include/eui_provider_params\.h:[0-9]+: warning: Member EUI48_PROVIDER_TYPE \(macro definition\) of file eui_provider_params\.h is not documented\. boards/same54\-xpro/include/periph_conf\.h:[0-9]+: warning: Member ADC_DEV \(macro definition\) of file periph_conf\.h is not documented\.