Skip to content

Commit 67676dc

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

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h

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

23+
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_MOSI
24+
#define MBED_CONF_RSPIF_DRIVER_SPI_MOSI NC
25+
#endif
26+
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_MISO
27+
#define MBED_CONF_RSPIF_DRIVER_SPI_MISO NC
28+
#endif
29+
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_CLK
30+
#define MBED_CONF_RSPIF_DRIVER_SPI_CLK NC
31+
#endif
32+
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_CS
33+
#define MBED_CONF_RSPIF_DRIVER_SPI_CS NC
34+
#endif
35+
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_FREQ
36+
#define MBED_CONF_RSPIF_DRIVER_SPI_FREQ 40000000
37+
#endif
38+
2339
/** Reduced BlockDevice for SPI based flash devices
2440
* *Should only be used by Boot Loader*
2541
*
@@ -66,7 +82,11 @@ class SPIFReducedBlockDevice : public mbed::BlockDevice {
6682
* @param csel SPI chip select pin
6783
* @param freq Clock speed of the SPI bus (defaults to 40MHz)
6884
*/
69-
SPIFReducedBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq = 40000000);
85+
SPIFReducedBlockDevice(PinName mosi = MBED_CONF_RSPIF_DRIVER_SPI_MOSI,
86+
PinName miso = MBED_CONF_RSPIF_DRIVER_SPI_MISO,
87+
PinName sclk = MBED_CONF_RSPIF_DRIVER_SPI_CLK,
88+
PinName csel = MBED_CONF_RSPIF_DRIVER_SPI_CS,
89+
int freq = MBED_CONF_RSPIF_DRIVER_SPI_FREQ);
7090

7191
/** Initialize a block device
7292
*

components/storage/blockdevice/COMPONENT_RSPIF/mbed_lib.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "rspif-driver",
33
"config": {
4-
"SPI_MOSI": "NC",
5-
"SPI_MISO": "NC",
6-
"SPI_CLK": "NC",
7-
"SPI_CS": "NC",
8-
"SPI_FREQ": "40000000"
4+
"SPI_MOSI": "SPI_MOSI",
5+
"SPI_MISO": "SPI_MISO",
6+
"SPI_CLK": "SPI_SCK",
7+
"SPI_CS": "SPI_CS",
8+
"SPI_FREQ":"40000000"
99
},
1010
"target_overrides": {
1111
"K82F": {

features/storage/system_storage/SystemStorage.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
7070

7171
#elif COMPONENT_RSPIF
7272

73-
static SPIFReducedBlockDevice default_bd(
74-
MBED_CONF_RSPIF_DRIVER_SPI_MOSI,
75-
MBED_CONF_RSPIF_DRIVER_SPI_MISO,
76-
MBED_CONF_RSPIF_DRIVER_SPI_CLK,
77-
MBED_CONF_RSPIF_DRIVER_SPI_CS,
78-
MBED_CONF_RSPIF_DRIVER_SPI_FREQ
79-
);
73+
static SPIFReducedBlockDevice default_bd;
8074

8175
return &default_bd;
8276

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": "SPIFReducedBlockDevice"
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", "RSPIF"]
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)