Skip to content

Commit 23f8787

Browse files
author
Veijo Pesonen
committed
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
1 parent 3be2b8b commit 23f8787

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121
#include "drivers/DigitalOut.h"
2222
#include "features/storage/blockdevice/BlockDevice.h"
2323

24+
#ifndef MBED_CONF_SPIF_DRIVER_SPI_MOSI
25+
#define MBED_CONF_SPIF_DRIVER_SPI_MOSI NC
26+
#endif
27+
#ifndef MBED_CONF_SPIF_DRIVER_SPI_MISO
28+
#define MBED_CONF_SPIF_DRIVER_SPI_MISO NC
29+
#endif
30+
#ifndef MBED_CONF_SPIF_DRIVER_SPI_CLK
31+
#define MBED_CONF_SPIF_DRIVER_SPI_CLK NC
32+
#endif
33+
#ifndef MBED_CONF_SPIF_DRIVER_SPI_CS
34+
#define MBED_CONF_SPIF_DRIVER_SPI_CS NC
35+
#endif
36+
#ifndef MBED_CONF_SPIF_DRIVER_SPI_FREQ
37+
#define MBED_CONF_SPIF_DRIVER_SPI_FREQ 40000000
38+
#endif
39+
2440
/** Enum spif standard error codes
2541
*
2642
* @enum spif_bd_error
@@ -82,8 +98,14 @@ class SPIFBlockDevice : public mbed::BlockDevice {
8298
* @param sclk SPI clock pin
8399
* @param csel SPI chip select pin
84100
* @param freq Clock speed of the SPI bus (defaults to 40MHz)
101+
*
102+
*
85103
*/
86-
SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq = 40000000);
104+
SPIFBlockDevice(PinName mosi = MBED_CONF_SPIF_DRIVER_SPI_MOSI,
105+
PinName miso = MBED_CONF_SPIF_DRIVER_SPI_MISO,
106+
PinName sclk = MBED_CONF_SPIF_DRIVER_SPI_CLK,
107+
PinName csel = MBED_CONF_SPIF_DRIVER_SPI_CS,
108+
int freq = MBED_CONF_SPIF_DRIVER_SPI_FREQ);
87109

88110
/** Initialize a block device
89111
*

features/storage/system_storage/SystemStorage.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
6464
{
6565
#if COMPONENT_SPIF
6666

67-
static SPIFBlockDevice default_bd(
68-
MBED_CONF_SPIF_DRIVER_SPI_MOSI,
69-
MBED_CONF_SPIF_DRIVER_SPI_MISO,
70-
MBED_CONF_SPIF_DRIVER_SPI_CLK,
71-
MBED_CONF_SPIF_DRIVER_SPI_CS,
72-
MBED_CONF_SPIF_DRIVER_SPI_FREQ
73-
);
67+
static SPIFBlockDevice default_bd;
7468

7569
return &default_bd;
7670

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"config": {
3+
"sim-blockdevice": {
4+
"help": "Simulated block device, requires sufficient heap",
5+
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
6+
"value": "HeapBlockDevice"
7+
},
8+
"test-blockdevice": {
9+
"help": "Used blockdevice",
10+
"macro_name": "MBED_TEST_BLOCKDEVICE",
11+
"value": "SPIFBlockDevice"
12+
},
13+
"test-filesystem": {
14+
"help": "Used filesystem",
15+
"macro_name": "MBED_TEST_FILESYSTEM",
16+
"value": "LittleFileSystem"
17+
}
18+
},
19+
"target_overrides": {
20+
"NRF52840_DK": {
21+
"target.components_remove": ["QSPI", "QSPIF"],
22+
"target.components_add" : ["SPI", "SPIF"]
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)