diff --git a/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h b/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h index 821de04eab..dd26ebbe87 100644 --- a/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h @@ -21,6 +21,22 @@ #include "drivers/DigitalOut.h" #include "features/storage/blockdevice/BlockDevice.h" +#ifndef MBED_CONF_SPIF_DRIVER_SPI_MOSI +#define MBED_CONF_SPIF_DRIVER_SPI_MOSI NC +#endif +#ifndef MBED_CONF_SPIF_DRIVER_SPI_MISO +#define MBED_CONF_SPIF_DRIVER_SPI_MISO NC +#endif +#ifndef MBED_CONF_SPIF_DRIVER_SPI_CLK +#define MBED_CONF_SPIF_DRIVER_SPI_CLK NC +#endif +#ifndef MBED_CONF_SPIF_DRIVER_SPI_CS +#define MBED_CONF_SPIF_DRIVER_SPI_CS NC +#endif +#ifndef MBED_CONF_SPIF_DRIVER_SPI_FREQ +#define MBED_CONF_SPIF_DRIVER_SPI_FREQ 40000000 +#endif + /** Enum spif standard error codes * * @enum spif_bd_error @@ -82,8 +98,14 @@ public: * @param sclk SPI clock pin * @param csel SPI chip select pin * @param freq Clock speed of the SPI bus (defaults to 40MHz) + * + * */ - SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq = 40000000); + SPIFBlockDevice(PinName mosi = MBED_CONF_SPIF_DRIVER_SPI_MOSI, + PinName miso = MBED_CONF_SPIF_DRIVER_SPI_MISO, + PinName sclk = MBED_CONF_SPIF_DRIVER_SPI_CLK, + PinName csel = MBED_CONF_SPIF_DRIVER_SPI_CS, + int freq = MBED_CONF_SPIF_DRIVER_SPI_FREQ); /** Initialize a block device * diff --git a/features/storage/system_storage/SystemStorage.cpp b/features/storage/system_storage/SystemStorage.cpp index ba6f01a6cf..e9ae6b5001 100644 --- a/features/storage/system_storage/SystemStorage.cpp +++ b/features/storage/system_storage/SystemStorage.cpp @@ -64,13 +64,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() { #if COMPONENT_SPIF - static SPIFBlockDevice default_bd( - MBED_CONF_SPIF_DRIVER_SPI_MOSI, - MBED_CONF_SPIF_DRIVER_SPI_MISO, - MBED_CONF_SPIF_DRIVER_SPI_CLK, - MBED_CONF_SPIF_DRIVER_SPI_CS, - MBED_CONF_SPIF_DRIVER_SPI_FREQ - ); + static SPIFBlockDevice default_bd; return &default_bd; diff --git a/tools/test_configs/SPIFBlockDeviceAndHeapBlockDevice.json b/tools/test_configs/SPIFBlockDeviceAndHeapBlockDevice.json new file mode 100644 index 0000000000..05be4d17ff --- /dev/null +++ b/tools/test_configs/SPIFBlockDeviceAndHeapBlockDevice.json @@ -0,0 +1,25 @@ +{ + "config": { + "sim-blockdevice": { + "help": "Simulated block device, requires sufficient heap", + "macro_name": "MBED_TEST_SIM_BLOCKDEVICE", + "value": "HeapBlockDevice" + }, + "test-blockdevice": { + "help": "Used blockdevice", + "macro_name": "MBED_TEST_BLOCKDEVICE", + "value": "SPIFBlockDevice" + }, + "test-filesystem": { + "help": "Used filesystem", + "macro_name": "MBED_TEST_FILESYSTEM", + "value": "LittleFileSystem" + } + }, + "target_overrides": { + "NRF52840_DK": { + "target.components_remove": ["QSPI", "QSPIF"], + "target.components_add" : ["SPI", "SPIF"] + } + } +}