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.
pull/12143/head
Veijo Pesonen 2019-12-18 17:03:35 +02:00
parent 83101170a3
commit 803ae3444d
4 changed files with 54 additions and 9 deletions

View File

@ -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();

View File

@ -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": {

View File

@ -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;

View File

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