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
pull/12143/head
Veijo Pesonen 2019-12-19 13:23:21 +02:00
parent 3be2b8bf12
commit 23f87877a1
3 changed files with 49 additions and 8 deletions

View File

@ -21,6 +21,22 @@
#include "drivers/DigitalOut.h" #include "drivers/DigitalOut.h"
#include "features/storage/blockdevice/BlockDevice.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 standard error codes
* *
* @enum spif_bd_error * @enum spif_bd_error
@ -82,8 +98,14 @@ public:
* @param sclk SPI clock pin * @param sclk SPI clock pin
* @param csel SPI chip select pin * @param csel SPI chip select pin
* @param freq Clock speed of the SPI bus (defaults to 40MHz) * @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 /** Initialize a block device
* *

View File

@ -64,13 +64,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
{ {
#if COMPONENT_SPIF #if COMPONENT_SPIF
static SPIFBlockDevice default_bd( 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
);
return &default_bd; return &default_bd;

View File

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