From 803ae3444d3fd271a25890e91a88f5a32fcc7b42 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Wed, 18 Dec 2019 17:03:35 +0200 Subject: [PATCH 1/5] SDBlockDevice: Makes default configuration to use mbed_lib.json settings SDBlockDevice parameters come from mbed_lib.json if not provided explicitly. Introduced an app config file for running filesystem tests. --- .../blockdevice/COMPONENT_SD/SDBlockDevice.h | 34 +++++++++++++++++-- .../blockdevice/COMPONENT_SD/mbed_lib.json | 3 +- .../storage/system_storage/SystemStorage.cpp | 7 +--- .../SDBlockDeviceAndHeapBlockDevice.json | 19 +++++++++++ 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 tools/test_configs/SDBlockDeviceAndHeapBlockDevice.json diff --git a/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h b/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h index 4439f883c1..e55286afa4 100644 --- a/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h @@ -29,6 +29,28 @@ #include "platform/PlatformMutex.h" #include "hal/static_pinmap.h" +#ifndef MBED_CONF_SD_SPI_MOSI +#define MBED_CONF_SD_SPI_MOSI NC +#endif +#ifndef MBED_CONF_SD_SPI_MISO +#define MBED_CONF_SD_SPI_MISO NC +#endif +#ifndef MBED_CONF_SD_SPI_CLK +#define MBED_CONF_SD_SPI_CLK NC +#endif +#ifndef MBED_CONF_SD_SPI_CS +#define MBED_CONF_SD_SPI_CS NC +#endif +#ifndef MBED_CONF_SD_INIT_FREQUENCY +#define MBED_CONF_SD_INIT_FREQUENCY 100000 +#endif +#ifndef MBED_CONF_SD_TRX_FREQUENCY +#define MBED_CONF_SD_TRX_FREQUENCY 1000000 +#endif +#ifndef MBED_CONF_SD_CRC_ENABLED +#define MBED_CONF_SD_CRC_ENABLED 0 +#endif + /** SDBlockDevice class * * Access an SD Card using SPI bus @@ -44,7 +66,12 @@ public: * @param hz Clock speed of the SPI bus (defaults to 1MHz) * @param crc_on Enable cyclic redundancy check (defaults to disabled) */ - SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName cs, uint64_t hz = 1000000, bool crc_on = 0); + SDBlockDevice(PinName mosi = MBED_CONF_SD_SPI_MOSI, + PinName miso = MBED_CONF_SD_SPI_MISO, + PinName sclk = MBED_CONF_SD_SPI_CLK, + PinName cs = MBED_CONF_SD_SPI_CS, + uint64_t hz = MBED_CONF_SD_TRX_FREQUENCY, + bool crc_on = MBED_CONF_SD_CRC_ENABLED); /** Creates an SDBlockDevice on a SPI bus specified by pins (using static pin-map) * @@ -52,7 +79,10 @@ public: * @param hz Clock speed of the SPI bus (defaults to 1MHz) * @param crc_on Enable cyclic redundancy check (defaults to disabled) */ - SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_t hz = 1000000, bool crc_on = 0); + SDBlockDevice(const spi_pinmap_t &spi_pinmap, + PinName cs = MBED_CONF_SD_SPI_CS, + uint64_t hz = MBED_CONF_SD_TRX_FREQUENCY, + bool crc_on = MBED_CONF_SD_CRC_ENABLED); virtual ~SDBlockDevice(); diff --git a/components/storage/blockdevice/COMPONENT_SD/mbed_lib.json b/components/storage/blockdevice/COMPONENT_SD/mbed_lib.json index ab3ec6c7ca..f9cf25a18d 100644 --- a/components/storage/blockdevice/COMPONENT_SD/mbed_lib.json +++ b/components/storage/blockdevice/COMPONENT_SD/mbed_lib.json @@ -9,7 +9,8 @@ "CMD_TIMEOUT": 10000, "CMD0_IDLE_STATE_RETRIES": 5, "INIT_FREQUENCY": 100000, - "CRC_ENABLED": 1, + "TRX_FREQUENCY": 1000000, + "CRC_ENABLED": 0, "TEST_BUFFER": 8192 }, "target_overrides": { diff --git a/features/storage/system_storage/SystemStorage.cpp b/features/storage/system_storage/SystemStorage.cpp index 8ef0fab0e7..579497b1f5 100644 --- a/features/storage/system_storage/SystemStorage.cpp +++ b/features/storage/system_storage/SystemStorage.cpp @@ -120,12 +120,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() MBED_CONF_SD_SPI_CS ); #else - static SDBlockDevice default_bd( - MBED_CONF_SD_SPI_MOSI, - MBED_CONF_SD_SPI_MISO, - MBED_CONF_SD_SPI_CLK, - MBED_CONF_SD_SPI_CS - ); + static SDBlockDevice default_bd; #endif return &default_bd; diff --git a/tools/test_configs/SDBlockDeviceAndHeapBlockDevice.json b/tools/test_configs/SDBlockDeviceAndHeapBlockDevice.json new file mode 100644 index 0000000000..49e0e07431 --- /dev/null +++ b/tools/test_configs/SDBlockDeviceAndHeapBlockDevice.json @@ -0,0 +1,19 @@ +{ + "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": "SDBlockDevice" + }, + "test-filesystem": { + "help": "Used filesystem", + "macro_name": "MBED_TEST_FILESYSTEM", + "value": "LittleFileSystem" + } + } +} From 3be2b8bf120b733e32d46e00a513862d0d66db45 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 19 Dec 2019 11:27:22 +0200 Subject: [PATCH 2/5] QSPIFBlockDevice: Makes default configuration to use mbed_lib.json settings QSPIFBlockDevice parameters come from mbed_lib.json if not provided explicitly. Introduced an app config file for running filesystem tests with QSPIF modules --- .../COMPONENT_QSPIF/QSPIFBlockDevice.h | 36 +++++++++++++++++-- .../storage/system_storage/SystemStorage.cpp | 11 +----- .../QSPIFBlockDeviceAndHeapBlockDevice.json | 19 ++++++++++ 3 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 tools/test_configs/QSPIFBlockDeviceAndHeapBlockDevice.json diff --git a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h index 3a3dc712b0..3f1ec01400 100644 --- a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h @@ -19,6 +19,31 @@ #include "drivers/QSPI.h" #include "features/storage/blockdevice/BlockDevice.h" +#ifndef MBED_CONF_QSPIF_QSPI_IO0 +#define MBED_CONF_QSPIF_QSPI_IO0 NC +#endif +#ifndef MBED_CONF_QSPIF_QSPI_IO1 +#define MBED_CONF_QSPIF_QSPI_IO1 NC +#endif +#ifndef MBED_CONF_QSPIF_QSPI_IO2 +#define MBED_CONF_QSPIF_QSPI_IO2 NC +#endif +#ifndef MBED_CONF_QSPIF_QSPI_IO3 +#define MBED_CONF_QSPIF_QSPI_IO3 NC +#endif +#ifndef MBED_CONF_QSPIF_QSPI_SCK +#define MBED_CONF_QSPIF_QSPI_SCK NC +#endif +#ifndef MBED_CONF_QSPIF_QSPI_CSN +#define MBED_CONF_QSPIF_QSPI_CSN NC +#endif +#ifndef MBED_CONF_QSPIF_QSPI_POLARITY_MODE +#define MBED_CONF_QSPIF_QSPI_POLARITY_MODE 0 +#endif +#ifndef MBED_CONF_QSPIF_QSPI_FREQ +#define MBED_CONF_QSPIF_QSPI_FREQ 40000000 +#endif + /** Enum qspif standard error codes * * @enum qspif_bd_error @@ -98,10 +123,15 @@ public: * @param clock_mode specifies the QSPI Clock Polarity mode (QSPIF_POLARITY_MODE_0/QSPIF_POLARITY_MODE_1) * default value = 0 * @param freq Clock frequency of the QSPI bus (defaults to 40MHz) - * */ - QSPIFBlockDevice(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName csel, - int clock_mode, int freq = MBED_CONF_QSPIF_QSPI_FREQ); + QSPIFBlockDevice(PinName io0 = MBED_CONF_QSPIF_QSPI_IO0, + PinName io1 = MBED_CONF_QSPIF_QSPI_IO1, + PinName io2 = MBED_CONF_QSPIF_QSPI_IO2, + PinName io3 = MBED_CONF_QSPIF_QSPI_IO3, + PinName sclk = MBED_CONF_QSPIF_QSPI_SCK, + PinName csel = MBED_CONF_QSPIF_QSPI_CSN, + int clock_mode = MBED_CONF_QSPIF_QSPI_POLARITY_MODE, + int freq = MBED_CONF_QSPIF_QSPI_FREQ); /** Initialize a block device * diff --git a/features/storage/system_storage/SystemStorage.cpp b/features/storage/system_storage/SystemStorage.cpp index 579497b1f5..ba6f01a6cf 100644 --- a/features/storage/system_storage/SystemStorage.cpp +++ b/features/storage/system_storage/SystemStorage.cpp @@ -88,16 +88,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() #elif COMPONENT_QSPIF - static QSPIFBlockDevice default_bd( - MBED_CONF_QSPIF_QSPI_IO0, - MBED_CONF_QSPIF_QSPI_IO1, - MBED_CONF_QSPIF_QSPI_IO2, - MBED_CONF_QSPIF_QSPI_IO3, - MBED_CONF_QSPIF_QSPI_SCK, - MBED_CONF_QSPIF_QSPI_CSN, - MBED_CONF_QSPIF_QSPI_POLARITY_MODE, - MBED_CONF_QSPIF_QSPI_FREQ - ); + static QSPIFBlockDevice default_bd; return &default_bd; diff --git a/tools/test_configs/QSPIFBlockDeviceAndHeapBlockDevice.json b/tools/test_configs/QSPIFBlockDeviceAndHeapBlockDevice.json new file mode 100644 index 0000000000..91dbefc5fa --- /dev/null +++ b/tools/test_configs/QSPIFBlockDeviceAndHeapBlockDevice.json @@ -0,0 +1,19 @@ +{ + "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": "QSPIFBlockDevice" + }, + "test-filesystem": { + "help": "Used filesystem", + "macro_name": "MBED_TEST_FILESYSTEM", + "value": "LittleFileSystem" + } + } +} From 23f87877a1ed87d70f20951b70e4292bec21c967 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 19 Dec 2019 13:23:21 +0200 Subject: [PATCH 3/5] SPIFBlockDevice: Makes default configuration to use mbed_lib.json settings SPIFBlockDevice parameters come from mbed_lib.json if not provided explicitly. Introduced an app config file for running filesystem tests with SPIF modules --- .../COMPONENT_SPIF/SPIFBlockDevice.h | 24 +++++++++++++++++- .../storage/system_storage/SystemStorage.cpp | 8 +----- .../SPIFBlockDeviceAndHeapBlockDevice.json | 25 +++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 tools/test_configs/SPIFBlockDeviceAndHeapBlockDevice.json 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"] + } + } +} From 67676dc1238a1fc478d61ad2d9f2bc92b761cc05 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 19 Dec 2019 13:44:14 +0200 Subject: [PATCH 4/5] SPIFReducedBlockDevice: Makes default configuration to use mbed_lib.json settings SPIFReducedBlockDevice parameters come from mbed_lib.json if not provided explicitly. Introduced an app config file for running filesystem tests with RSPIF block device --- .../COMPONENT_RSPIF/SPIFReducedBlockDevice.h | 22 +++++++++++++++- .../blockdevice/COMPONENT_RSPIF/mbed_lib.json | 10 ++++---- .../storage/system_storage/SystemStorage.cpp | 8 +----- .../RSPIFBlockDeviceAndHeapBlockDevice.json | 25 +++++++++++++++++++ 4 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 tools/test_configs/RSPIFBlockDeviceAndHeapBlockDevice.json diff --git a/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h b/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h index 53bf7d83c7..e7434e4c67 100644 --- a/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h @@ -20,6 +20,22 @@ #include "drivers/DigitalOut.h" #include "features/storage/blockdevice/BlockDevice.h" +#ifndef MBED_CONF_RSPIF_DRIVER_SPI_MOSI +#define MBED_CONF_RSPIF_DRIVER_SPI_MOSI NC +#endif +#ifndef MBED_CONF_RSPIF_DRIVER_SPI_MISO +#define MBED_CONF_RSPIF_DRIVER_SPI_MISO NC +#endif +#ifndef MBED_CONF_RSPIF_DRIVER_SPI_CLK +#define MBED_CONF_RSPIF_DRIVER_SPI_CLK NC +#endif +#ifndef MBED_CONF_RSPIF_DRIVER_SPI_CS +#define MBED_CONF_RSPIF_DRIVER_SPI_CS NC +#endif +#ifndef MBED_CONF_RSPIF_DRIVER_SPI_FREQ +#define MBED_CONF_RSPIF_DRIVER_SPI_FREQ 40000000 +#endif + /** Reduced BlockDevice for SPI based flash devices * *Should only be used by Boot Loader* * @@ -66,7 +82,11 @@ public: * @param csel SPI chip select pin * @param freq Clock speed of the SPI bus (defaults to 40MHz) */ - SPIFReducedBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq = 40000000); + SPIFReducedBlockDevice(PinName mosi = MBED_CONF_RSPIF_DRIVER_SPI_MOSI, + PinName miso = MBED_CONF_RSPIF_DRIVER_SPI_MISO, + PinName sclk = MBED_CONF_RSPIF_DRIVER_SPI_CLK, + PinName csel = MBED_CONF_RSPIF_DRIVER_SPI_CS, + int freq = MBED_CONF_RSPIF_DRIVER_SPI_FREQ); /** Initialize a block device * diff --git a/components/storage/blockdevice/COMPONENT_RSPIF/mbed_lib.json b/components/storage/blockdevice/COMPONENT_RSPIF/mbed_lib.json index 11b5f7c53c..11477938cc 100644 --- a/components/storage/blockdevice/COMPONENT_RSPIF/mbed_lib.json +++ b/components/storage/blockdevice/COMPONENT_RSPIF/mbed_lib.json @@ -1,11 +1,11 @@ { "name": "rspif-driver", "config": { - "SPI_MOSI": "NC", - "SPI_MISO": "NC", - "SPI_CLK": "NC", - "SPI_CS": "NC", - "SPI_FREQ": "40000000" + "SPI_MOSI": "SPI_MOSI", + "SPI_MISO": "SPI_MISO", + "SPI_CLK": "SPI_SCK", + "SPI_CS": "SPI_CS", + "SPI_FREQ":"40000000" }, "target_overrides": { "K82F": { diff --git a/features/storage/system_storage/SystemStorage.cpp b/features/storage/system_storage/SystemStorage.cpp index e9ae6b5001..84190dcf72 100644 --- a/features/storage/system_storage/SystemStorage.cpp +++ b/features/storage/system_storage/SystemStorage.cpp @@ -70,13 +70,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() #elif COMPONENT_RSPIF - static SPIFReducedBlockDevice default_bd( - MBED_CONF_RSPIF_DRIVER_SPI_MOSI, - MBED_CONF_RSPIF_DRIVER_SPI_MISO, - MBED_CONF_RSPIF_DRIVER_SPI_CLK, - MBED_CONF_RSPIF_DRIVER_SPI_CS, - MBED_CONF_RSPIF_DRIVER_SPI_FREQ - ); + static SPIFReducedBlockDevice default_bd; return &default_bd; diff --git a/tools/test_configs/RSPIFBlockDeviceAndHeapBlockDevice.json b/tools/test_configs/RSPIFBlockDeviceAndHeapBlockDevice.json new file mode 100644 index 0000000000..a53c4c5e0a --- /dev/null +++ b/tools/test_configs/RSPIFBlockDeviceAndHeapBlockDevice.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": "SPIFReducedBlockDevice" + }, + "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", "RSPIF"] + } + } +} From 9763ad3b2de342697074fc0c18820bca2cac9498 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 19 Dec 2019 15:08:36 +0200 Subject: [PATCH 5/5] DataFlashBlockDevice: Makes default configuration to use mbed_lib.json settings DataFlashBlockDevice parameters come from mbed_lib.json if not provided explicitly. --- .../DataFlashBlockDevice.h | 26 +++++++++++++++---- .../storage/system_storage/SystemStorage.cpp | 7 +---- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h b/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h index 9bb4d82513..9c685397ab 100644 --- a/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h @@ -23,6 +23,21 @@ #include "drivers/SPI.h" #include "drivers/DigitalOut.h" +#ifndef MBED_CONF_DATAFLASH_SPI_MOSI +#define MBED_CONF_DATAFLASH_SPI_MOSI NC +#endif +#ifndef MBED_CONF_DATAFLASH_SPI_MISO +#define MBED_CONF_DATAFLASH_SPI_MISO NC +#endif +#ifndef MBED_CONF_DATAFLASH_SPI_CLK +#define MBED_CONF_DATAFLASH_SPI_CLK NC +#endif +#ifndef MBED_CONF_DATAFLASH_SPI_CS +#define MBED_CONF_DATAFLASH_SPI_CS NC +#endif +#ifndef MBED_CONF_DATAFLASH_SPI_FREQ +#define MBED_CONF_DATAFLASH_SPI_FREQ 40000000 +#endif /** BlockDevice for DataFlash flash devices * @@ -72,13 +87,14 @@ public: * @param csel SPI chip select pin * @param nowp GPIO not-write-protect * @param freq Clock speed of the SPI bus (defaults to 40MHz) + * @param nwp Not-write-protected pin */ - DataFlashBlockDevice(PinName mosi, - PinName miso, - PinName sclk, - PinName csel, + DataFlashBlockDevice(PinName mosi = MBED_CONF_DATAFLASH_SPI_MOSI, + PinName miso = MBED_CONF_DATAFLASH_SPI_MISO, + PinName sclk = MBED_CONF_DATAFLASH_SPI_CLK, + PinName csel = MBED_CONF_DATAFLASH_SPI_CS, int freq = MBED_CONF_DATAFLASH_SPI_FREQ, - PinName nowp = NC); + PinName nwp = NC); /** Initialize a block device * diff --git a/features/storage/system_storage/SystemStorage.cpp b/features/storage/system_storage/SystemStorage.cpp index 84190dcf72..305d51fe7f 100644 --- a/features/storage/system_storage/SystemStorage.cpp +++ b/features/storage/system_storage/SystemStorage.cpp @@ -82,12 +82,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() #elif COMPONENT_DATAFLASH - static DataFlashBlockDevice default_bd( - MBED_CONF_DATAFLASH_SPI_MOSI, - MBED_CONF_DATAFLASH_SPI_MISO, - MBED_CONF_DATAFLASH_SPI_CLK, - MBED_CONF_DATAFLASH_SPI_CS - ); + static DataFlashBlockDevice default_bd; return &default_bd;