Skip to content

Commit 803ae34

Browse files
author
Veijo Pesonen
committed
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.
1 parent 8310117 commit 803ae34

File tree

4 files changed

+54
-9
lines changed

4 files changed

+54
-9
lines changed

components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@
2929
#include "platform/PlatformMutex.h"
3030
#include "hal/static_pinmap.h"
3131

32+
#ifndef MBED_CONF_SD_SPI_MOSI
33+
#define MBED_CONF_SD_SPI_MOSI NC
34+
#endif
35+
#ifndef MBED_CONF_SD_SPI_MISO
36+
#define MBED_CONF_SD_SPI_MISO NC
37+
#endif
38+
#ifndef MBED_CONF_SD_SPI_CLK
39+
#define MBED_CONF_SD_SPI_CLK NC
40+
#endif
41+
#ifndef MBED_CONF_SD_SPI_CS
42+
#define MBED_CONF_SD_SPI_CS NC
43+
#endif
44+
#ifndef MBED_CONF_SD_INIT_FREQUENCY
45+
#define MBED_CONF_SD_INIT_FREQUENCY 100000
46+
#endif
47+
#ifndef MBED_CONF_SD_TRX_FREQUENCY
48+
#define MBED_CONF_SD_TRX_FREQUENCY 1000000
49+
#endif
50+
#ifndef MBED_CONF_SD_CRC_ENABLED
51+
#define MBED_CONF_SD_CRC_ENABLED 0
52+
#endif
53+
3254
/** SDBlockDevice class
3355
*
3456
* Access an SD Card using SPI bus
@@ -44,15 +66,23 @@ class SDBlockDevice : public mbed::BlockDevice {
4466
* @param hz Clock speed of the SPI bus (defaults to 1MHz)
4567
* @param crc_on Enable cyclic redundancy check (defaults to disabled)
4668
*/
47-
SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName cs, uint64_t hz = 1000000, bool crc_on = 0);
69+
SDBlockDevice(PinName mosi = MBED_CONF_SD_SPI_MOSI,
70+
PinName miso = MBED_CONF_SD_SPI_MISO,
71+
PinName sclk = MBED_CONF_SD_SPI_CLK,
72+
PinName cs = MBED_CONF_SD_SPI_CS,
73+
uint64_t hz = MBED_CONF_SD_TRX_FREQUENCY,
74+
bool crc_on = MBED_CONF_SD_CRC_ENABLED);
4875

4976
/** Creates an SDBlockDevice on a SPI bus specified by pins (using static pin-map)
5077
*
5178
* @param spi_pinmap Static SPI pin-map
5279
* @param hz Clock speed of the SPI bus (defaults to 1MHz)
5380
* @param crc_on Enable cyclic redundancy check (defaults to disabled)
5481
*/
55-
SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_t hz = 1000000, bool crc_on = 0);
82+
SDBlockDevice(const spi_pinmap_t &spi_pinmap,
83+
PinName cs = MBED_CONF_SD_SPI_CS,
84+
uint64_t hz = MBED_CONF_SD_TRX_FREQUENCY,
85+
bool crc_on = MBED_CONF_SD_CRC_ENABLED);
5686

5787
virtual ~SDBlockDevice();
5888

components/storage/blockdevice/COMPONENT_SD/mbed_lib.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"CMD_TIMEOUT": 10000,
1010
"CMD0_IDLE_STATE_RETRIES": 5,
1111
"INIT_FREQUENCY": 100000,
12-
"CRC_ENABLED": 1,
12+
"TRX_FREQUENCY": 1000000,
13+
"CRC_ENABLED": 0,
1314
"TEST_BUFFER": 8192
1415
},
1516
"target_overrides": {

features/storage/system_storage/SystemStorage.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
120120
MBED_CONF_SD_SPI_CS
121121
);
122122
#else
123-
static SDBlockDevice default_bd(
124-
MBED_CONF_SD_SPI_MOSI,
125-
MBED_CONF_SD_SPI_MISO,
126-
MBED_CONF_SD_SPI_CLK,
127-
MBED_CONF_SD_SPI_CS
128-
);
123+
static SDBlockDevice default_bd;
129124
#endif
130125

131126
return &default_bd;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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": "SDBlockDevice"
12+
},
13+
"test-filesystem": {
14+
"help": "Used filesystem",
15+
"macro_name": "MBED_TEST_FILESYSTEM",
16+
"value": "LittleFileSystem"
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)