mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/mtd_sdcard: add mtd_sdcard_default module
This commit is contained in:
parent
4e3151406c
commit
6f9dd8cf86
@ -23,6 +23,15 @@ config HAVE_MTD_NATIVE
|
||||
help
|
||||
Indicates that a native MTD is present.
|
||||
|
||||
config HAVE_MTD_SDCARD_DEFAULT
|
||||
bool
|
||||
imply MODULE_MTD_SDCARD if MODULE_MTD
|
||||
imply MODULE_MTD_SDCARD_DEFAULT if MODULE_MTD
|
||||
imply MODULE_SDCARD_SPI if MODULE_MTD
|
||||
select HAS_SDCARD_SPI
|
||||
help
|
||||
Indicates that a sdcard MTD is present with generic configuration
|
||||
|
||||
config HAVE_MTD_SDCARD
|
||||
bool
|
||||
imply MODULE_MTD_SDCARD if MODULE_MTD
|
||||
@ -86,6 +95,12 @@ config MODULE_MTD_MCI
|
||||
depends on CPU_FAM_LPC23XX
|
||||
select MODULE_MCI
|
||||
|
||||
config MODULE_MTD_SDCARD_DEFAULT
|
||||
bool "Use Generic SD card configuration"
|
||||
depends on MODULE_MTD_SDCARD
|
||||
help
|
||||
Automatically create a MTD device and mount point for the SD card.
|
||||
|
||||
config MODULE_MTD_SDCARD
|
||||
bool "MTD interface for SPI SD-Card"
|
||||
depends on MODULE_SDCARD_SPI
|
||||
|
@ -6,6 +6,10 @@ ifneq (,$(filter mtd_at25xxx,$(USEMODULE)))
|
||||
USEMODULE += at25xxx
|
||||
endif
|
||||
|
||||
ifneq (,$(filter mtd_sdcard_default,$(USEMODULE)))
|
||||
USEMODULE += mtd_sdcard
|
||||
endif
|
||||
|
||||
ifneq (,$(filter mtd_sdcard,$(USEMODULE)))
|
||||
USEMODULE += sdcard_spi
|
||||
endif
|
||||
|
@ -13,6 +13,14 @@ menuconfig KCONFIG_USEMODULE_MTD_SDCARD
|
||||
|
||||
if KCONFIG_USEMODULE_MTD_SDCARD
|
||||
|
||||
config SDCARD_GENERIC_MTD_OFFSET
|
||||
depends on MODULE_MTD_SDCARD_DEFAULT
|
||||
int "Index of first auto-configured MTD SDcard device"
|
||||
default 0
|
||||
help
|
||||
If you have other MTD devices defined, set this number so that
|
||||
the auto-configured SD Card(s) from mtd_sdcard_default will come after them.
|
||||
|
||||
config MTD_SDCARD_ERASE
|
||||
bool "Enable SD card erase"
|
||||
help
|
||||
|
1
drivers/mtd_sdcard/Makefile.include
Normal file
1
drivers/mtd_sdcard/Makefile.include
Normal file
@ -0,0 +1 @@
|
||||
PSEUDOMODULES += mtd_sdcard_default
|
@ -221,3 +221,37 @@ const mtd_desc_t mtd_sdcard_driver = {
|
||||
.erase_sector = mtd_sdcard_erase_sector,
|
||||
.power = mtd_sdcard_power,
|
||||
};
|
||||
|
||||
#if IS_USED(MODULE_MTD_SDCARD_DEFAULT)
|
||||
#include "sdcard_spi_params.h"
|
||||
#include "vfs_default.h"
|
||||
|
||||
#define SDCARD_NUMOF ARRAY_SIZE(sdcard_spi_params)
|
||||
|
||||
#ifndef CONFIG_SDCARD_GENERIC_MTD_OFFSET
|
||||
#define CONFIG_SDCARD_GENERIC_MTD_OFFSET 0
|
||||
#endif
|
||||
|
||||
#define MTD_SDCARD_DEV(n, m) \
|
||||
mtd_sdcard_t mtd_sdcard_dev ## n = { \
|
||||
.base = { \
|
||||
.driver = &mtd_sdcard_driver, \
|
||||
}, \
|
||||
.sd_card = &sdcard_spi_devs[n], \
|
||||
.params = &sdcard_spi_params[n] \
|
||||
}; \
|
||||
\
|
||||
mtd_dev_t CONCAT(*mtd, m) = (mtd_dev_t *)&mtd_sdcard_dev ## n
|
||||
|
||||
#define MTD_SDCARD_DEV_FS(n, m, filesystem) \
|
||||
VFS_AUTO_MOUNT(filesystem, VFS_MTD(mtd_sdcard_dev ## n), VFS_DEFAULT_SD(n), m)
|
||||
|
||||
/* this is provided by the sdcard_spi driver see drivers/sdcard_spi/sdcard_spi.c */
|
||||
extern sdcard_spi_t sdcard_spi_devs[SDCARD_NUMOF];
|
||||
|
||||
MTD_SDCARD_DEV(0, CONFIG_SDCARD_GENERIC_MTD_OFFSET);
|
||||
#ifdef MODULE_FATFS_VFS
|
||||
MTD_SDCARD_DEV_FS(0, CONFIG_SDCARD_GENERIC_MTD_OFFSET, fatfs);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user