Skip to content

Commit 26a3d12

Browse files
author
deepikabhavnani
committed
Add BlockDevice and Filesystem classes inside mbed namespace.
Adding new modules inside the namespace could be breaking change for existing code base hence add `using namespace::class` for classes newly added to mbed namespace to maintian backwards compatibility. MBED_NO_GLOBAL_USING_DIRECTIVE is added to remove auto-addition of namespace Macro guard `MBED_NO_GLOBAL_USING_DIRECTIVE` is added around namespace, to avoid polluting users namespace.
1 parent 323380b commit 26a3d12

38 files changed

+346
-120
lines changed

components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include <inttypes.h>
2121

22+
using namespace mbed;
23+
2224
/* constants */
2325
#define DATAFLASH_READ_SIZE 1
2426
#define DATAFLASH_PROG_SIZE 1

components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
* }
6060
* @endcode
6161
*/
62-
class DataFlashBlockDevice : public BlockDevice {
62+
class DataFlashBlockDevice : public mbed::BlockDevice {
6363
public:
6464
/** Creates a DataFlashBlockDevice on a SPI bus specified by pins
6565
*
@@ -96,7 +96,7 @@ class DataFlashBlockDevice : public BlockDevice {
9696
* @param size Size to read in bytes, must be a multiple of read block size
9797
* @return 0 on success, negative error code on failure
9898
*/
99-
virtual int read(void *buffer, bd_addr_t addr, bd_size_t size);
99+
virtual int read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
100100

101101
/** Program blocks to a block device
102102
*
@@ -107,7 +107,7 @@ class DataFlashBlockDevice : public BlockDevice {
107107
* @param size Size to write in bytes, must be a multiple of program block size
108108
* @return 0 on success, negative error code on failure
109109
*/
110-
virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size);
110+
virtual int program(const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
111111

112112
/** Erase blocks on a block device
113113
*
@@ -117,47 +117,47 @@ class DataFlashBlockDevice : public BlockDevice {
117117
* @param size Size to erase in bytes, must be a multiple of erase block size
118118
* @return 0 on success, negative error code on failure
119119
*/
120-
virtual int erase(bd_addr_t addr, bd_size_t size);
120+
virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
121121

122122
/** Get the size of a readable block
123123
*
124124
* @return Size of a readable block in bytes
125125
*/
126-
virtual bd_size_t get_read_size() const;
126+
virtual mbed::bd_size_t get_read_size() const;
127127

128128
/** Get the size of a programable block
129129
*
130130
* @return Size of a programable block in bytes
131131
* @note Must be a multiple of the read size
132132
*/
133-
virtual bd_size_t get_program_size() const;
133+
virtual mbed::bd_size_t get_program_size() const;
134134

135135
/** Get the size of a eraseable block
136136
*
137137
* @return Size of a eraseable block in bytes
138138
* @note Must be a multiple of the program size
139139
*/
140-
virtual bd_size_t get_erase_size() const;
140+
virtual mbed::bd_size_t get_erase_size() const;
141141

142142
/** Get the size of an erasable block given address
143143
*
144144
* @param addr Address within the erasable block
145145
* @return Size of an erasable block in bytes
146146
* @note Must be a multiple of the program size
147147
*/
148-
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
148+
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;
149149

150150
/** Get the total size of the underlying device
151151
*
152152
* @return Size of the underlying device in bytes
153153
*/
154-
virtual bd_size_t size() const;
154+
virtual mbed::bd_size_t size() const;
155155

156156
private:
157157
// Master side hardware
158-
SPI _spi;
159-
DigitalOut _cs;
160-
DigitalOut _nwp;
158+
mbed::SPI _spi;
159+
mbed::DigitalOut _cs;
160+
mbed::DigitalOut _nwp;
161161

162162
// Device configuration
163163
uint32_t _device_size;

components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "mbed_critical.h"
2121

2222
#include "mbed.h"
23-
23+
using namespace mbed;
2424
#include <inttypes.h>
2525

2626
#define FLASHIAP_READ_SIZE 1

components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/** BlockDevice using the FlashIAP API
2727
*
2828
*/
29-
class FlashIAPBlockDevice : public BlockDevice {
29+
class FlashIAPBlockDevice : public mbed::BlockDevice {
3030
public:
3131

3232
/** Creates a FlashIAPBlockDevice
@@ -58,7 +58,7 @@ class FlashIAPBlockDevice : public BlockDevice {
5858
* @param size Size to read in bytes, must be a multiple of read block size
5959
* @return 0 on success, negative error code on failure
6060
*/
61-
virtual int read(void *buffer, bd_addr_t addr, bd_size_t size);
61+
virtual int read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
6262

6363
/** Program blocks to a block device
6464
*
@@ -69,7 +69,7 @@ class FlashIAPBlockDevice : public BlockDevice {
6969
* @param size Size to write in bytes, must be a multiple of program block size
7070
* @return 0 on success, negative error code on failure
7171
*/
72-
virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size);
72+
virtual int program(const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
7373

7474
/** Erase blocks on a block device
7575
*
@@ -79,47 +79,47 @@ class FlashIAPBlockDevice : public BlockDevice {
7979
* @param size Size to erase in bytes, must be a multiple of erase block size
8080
* @return 0 on success, negative error code on failure
8181
*/
82-
virtual int erase(bd_addr_t addr, bd_size_t size);
82+
virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
8383

8484
/** Get the size of a readable block
8585
*
8686
* @return Size of a readable block in bytes
8787
*/
88-
virtual bd_size_t get_read_size() const;
88+
virtual mbed::bd_size_t get_read_size() const;
8989

9090
/** Get the size of a programable block
9191
*
9292
* @return Size of a programable block in bytes
9393
* @note Must be a multiple of the read size
9494
*/
95-
virtual bd_size_t get_program_size() const;
95+
virtual mbed::bd_size_t get_program_size() const;
9696

9797
/** Get the size of a eraseable block
9898
*
9999
* @return Size of a eraseable block in bytes
100100
* @note Must be a multiple of the program size
101101
*/
102-
virtual bd_size_t get_erase_size() const;
102+
virtual mbed::bd_size_t get_erase_size() const;
103103

104104
/** Get the size of an erasable block given address
105105
*
106106
* @param addr Address within the erasable block
107107
* @return Size of an erasable block in bytes
108108
* @note Must be a multiple of the program size
109109
*/
110-
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
110+
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;
111111

112112
/** Get the total size of the underlying device
113113
*
114114
* @return Size of the underlying device in bytes
115115
*/
116-
virtual bd_size_t size() const;
116+
virtual mbed::bd_size_t size() const;
117117

118118
private:
119119
// Device configuration
120120
mbed::FlashIAP _flash;
121-
bd_addr_t _base;
122-
bd_size_t _size;
121+
mbed::bd_addr_t _base;
122+
mbed::bd_size_t _size;
123123
bool _is_initialized;
124124
uint32_t _init_ref_count;
125125
};

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum qspif_polarity_mode {
4343
QSPIF_POLARITY_MODE_1 /* CPOL=1, CPHA=1 */
4444
};
4545

46-
#define QSPIF_MAX_REGIONS 10
46+
#define QSPIF_MAX_REGIONS 10
4747
#define MAX_NUM_OF_ERASE_TYPES 4
4848
#define QSPIF_MAX_ACTIVE_FLASH_DEVICES 10
4949

@@ -85,7 +85,7 @@ enum qspif_polarity_mode {
8585
* }
8686
* @endcode
8787
*/
88-
class QSPIFBlockDevice : public BlockDevice {
88+
class QSPIFBlockDevice : public mbed::BlockDevice {
8989
public:
9090
/** Create QSPIFBlockDevice - An SFDP based Flash Block Device over QSPI bus
9191
*
@@ -131,7 +131,7 @@ class QSPIFBlockDevice : public BlockDevice {
131131
* @return QSPIF_BD_ERROR_OK(0) - success
132132
* QSPIF_BD_ERROR_DEVICE_ERROR - device driver transaction failed
133133
*/
134-
virtual int read(void *buffer, bd_addr_t addr, bd_size_t size);
134+
virtual int read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
135135

136136
/** Program blocks to a block device
137137
*
@@ -146,7 +146,7 @@ class QSPIFBlockDevice : public BlockDevice {
146146
* QSPIF_BD_ERROR_WREN_FAILED - Write Enable failed
147147
* QSPIF_BD_ERROR_PARSING_FAILED - unexpected format or values in one of the SFDP tables
148148
*/
149-
virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size);
149+
virtual int program(const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
150150

151151
/** Erase blocks on a block device
152152
*
@@ -161,41 +161,41 @@ class QSPIFBlockDevice : public BlockDevice {
161161
* QSPIF_BD_ERROR_PARSING_FAILED - unexpected format or values in one of the SFDP tables
162162
* QSPIF_BD_ERROR_INVALID_ERASE_PARAMS - Trying to erase unaligned address or size
163163
*/
164-
virtual int erase(bd_addr_t addr, bd_size_t size);
164+
virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
165165

166166
/** Get the size of a readable block
167167
*
168168
* @return Size of a readable block in bytes
169169
*/
170-
virtual bd_size_t get_read_size() const;
170+
virtual mbed::bd_size_t get_read_size() const;
171171

172172
/** Get the size of a programable block
173173
*
174174
* @return Size of a program block size in bytes
175175
* @note Must be a multiple of the read size
176176
*/
177-
virtual bd_size_t get_program_size() const;
177+
virtual mbed::bd_size_t get_program_size() const;
178178

179179
/** Get the size of a eraseable block
180180
*
181181
* @return Size of a minimal erase block, common to all regions, in bytes
182182
* @note Must be a multiple of the program size
183183
*/
184-
virtual bd_size_t get_erase_size() const;
184+
virtual mbed::bd_size_t get_erase_size() const;
185185

186186
/** Get the size of minimal eraseable sector size of given address
187187
*
188188
* @param addr Any address within block queried for erase sector size (can be any address within flash size offset)
189189
* @return Size of minimal erase sector size, in given address region, in bytes
190190
* @note Must be a multiple of the program size
191191
*/
192-
virtual bd_size_t get_erase_size(bd_addr_t addr);
192+
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr);
193193

194194
/** Get the total size of the underlying device
195195
*
196196
* @return Size of the underlying device in bytes
197197
*/
198-
virtual bd_size_t size() const;
198+
virtual mbed::bd_size_t size() const;
199199

200200
private:
201201
// Internal functions
@@ -215,17 +215,17 @@ class QSPIFBlockDevice : public BlockDevice {
215215
/* Calls to QSPI Driver APIs */
216216
/********************************/
217217
// Send Program => Write command to Driver
218-
qspi_status_t _qspi_send_program_command(unsigned int prog_instruction, const void *buffer, bd_addr_t addr,
219-
bd_size_t *size);
218+
qspi_status_t _qspi_send_program_command(unsigned int prog_instruction, const void *buffer, mbed::bd_addr_t addr,
219+
mbed::bd_size_t *size);
220220

221221
// Send Read command to Driver
222-
qspi_status_t _qspi_send_read_command(unsigned int read_instruction, void *buffer, bd_addr_t addr, bd_size_t size);
222+
qspi_status_t _qspi_send_read_command(unsigned int read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
223223

224224
// Send Erase Instruction using command_transfer command to Driver
225-
qspi_status_t _qspi_send_erase_command(unsigned int erase_instruction, bd_addr_t addr, bd_size_t size);
225+
qspi_status_t _qspi_send_erase_command(unsigned int erase_instruction, mbed::bd_addr_t addr, mbed::bd_size_t size);
226226

227227
// Send Generic command_transfer command to Driver
228-
qspi_status_t _qspi_send_general_command(unsigned int instruction_int, bd_addr_t addr, const char *tx_buffer,
228+
qspi_status_t _qspi_send_general_command(unsigned int instruction_int, mbed::bd_addr_t addr, const char *tx_buffer,
229229
size_t tx_length, const char *rx_buffer, size_t rx_length);
230230

231231
// Send Bus configure_format command to Driver
@@ -286,7 +286,7 @@ class QSPIFBlockDevice : public BlockDevice {
286286
/* Utilities Functions */
287287
/***********************/
288288
// Find the region to which the given offset belong to
289-
int _utils_find_addr_region(bd_size_t offset);
289+
int _utils_find_addr_region(mbed::bd_size_t offset);
290290

291291
// Iterate on all supported Erase Types of the Region to which the offset belong to.
292292
// Iterates from highest type to lowest
@@ -310,7 +310,7 @@ class QSPIFBlockDevice : public BlockDevice {
310310

311311
// Mutex is used to protect Flash device for some QSPI Driver commands that must be done sequentially with no other commands in between
312312
// e.g. (1)Set Write Enable, (2)Program, (3)Wait Memory Ready
313-
PlatformMutex _mutex;
313+
mbed::PlatformMutex _mutex;
314314

315315
// Command Instructions
316316
unsigned int _read_instruction;

components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "SPIFReducedBlockDevice.h"
1818
#include "mbed_wait_api.h"
1919

20+
using namespace mbed;
21+
2022
// Read/write/erase sizes
2123
#define SPIF_READ_SIZE 1
2224
#define SPIF_PROG_SIZE 1

0 commit comments

Comments
 (0)