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" + } + } +}