Skip to content

Commit 43ccdf8

Browse files
committed
Port storege to use minimal-printf
1 parent 8a8778e commit 43ccdf8

File tree

50 files changed

+248
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+248
-248
lines changed

components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using namespace mbed;
4444
#endif /* DATAFLASH_DEBUG */
4545

4646
#if DATAFLASH_DEBUG
47-
#define DEBUG_PRINTF(...) printf(__VA_ARGS__)
47+
#define DEBUG_PRINTF(...) mbed_printf(__VA_ARGS__)
4848
#else
4949
#define DEBUG_PRINTF(...)
5050
#endif

components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@
3838
* DataFlashBlockDevice dataflash2(PTE2, PTE4, PTE1, PTE5, PTE6);
3939
*
4040
* int main() {
41-
* printf("dataflash test\n");
41+
* mbed_printf("dataflash test\n");
4242
*
4343
* // Initialize the SPI flash device and print the memory layout
4444
* dataflash.init();
45-
* printf("dataflash size: %llu\n", dataflash.size());
46-
* printf("dataflash read size: %llu\n", dataflash.get_read_size());
47-
* printf("dataflash program size: %llu\n", dataflash.get_program_size());
48-
* printf("dataflash erase size: %llu\n", dataflash.get_erase_size());
45+
* mbed_printf("dataflash size: %llu\n", dataflash.size());
46+
* mbed_printf("dataflash read size: %llu\n", dataflash.get_read_size());
47+
* mbed_printf("dataflash program size: %llu\n", dataflash.get_program_size());
48+
* mbed_printf("dataflash erase size: %llu\n", dataflash.get_erase_size());
4949
*
5050
* // Write "Hello World!" to the first block
5151
* char *buffer = (char*)malloc(dataflash.get_erase_size());
52-
* sprintf(buffer, "Hello World!\n");
52+
* mbed_sprintf(buffer, "Hello World!\n");
5353
* dataflash.erase(0, dataflash.get_erase_size());
5454
* dataflash.program(buffer, 0, dataflash.get_erase_size());
5555
*
5656
* // Read back what was stored
5757
* dataflash.read(buffer, 0, dataflash.get_erase_size());
58-
* printf("%s", buffer);
58+
* mbed_printf("%s", buffer);
5959
*
6060
* // Deinitialize the device
6161
* dataflash.deinit();

components/storage/blockdevice/COMPONENT_FLASHIAP/COMMON/fslittle_debug.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define FSLITTLE_LOG(_fmt, ...) \
4242
do \
4343
{ \
44-
printf(_fmt, __VA_ARGS__); \
44+
mbed_printf(_fmt, __VA_ARGS__); \
4545
}while(0);
4646

4747
#define noFSLITTLE_DEBUG
@@ -64,7 +64,7 @@ extern uint32_t fslittle_optLogLevel_g;
6464
{ \
6565
if(fslittle_optDebug_g && (fslittle_optLogLevel_g >= FSLITTLE_LOG_DEBUG)) \
6666
{ \
67-
printf(_fmt, __VA_ARGS__); \
67+
mbed_printf(_fmt, __VA_ARGS__); \
6868
} \
6969
}while(0);
7070

@@ -74,7 +74,7 @@ extern uint32_t fslittle_optLogLevel_g;
7474
{ \
7575
if(fslittle_optDebug_g && (fslittle_optLogLevel_g >= FSLITTLE_LOG_ERR)) \
7676
{ \
77-
printf(_fmt, __VA_ARGS__); \
77+
mbed_printf(_fmt, __VA_ARGS__); \
7878
} \
7979
}while(0);
8080

@@ -84,7 +84,7 @@ extern uint32_t fslittle_optLogLevel_g;
8484
{ \
8585
if(fslittle_optDebug_g && (fslittle_optLogLevel_g >= FSLITTLE_LOG_FENTRY)) \
8686
{ \
87-
printf(_fmt, __VA_ARGS__); \
87+
mbed_printf(_fmt, __VA_ARGS__); \
8888
} \
8989
}while(0);
9090

components/storage/blockdevice/COMPONENT_FLASHIAP/COMMON/fslittle_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern "C" {
4747
#define FSLITTLE_TEST_UTEST_MESSAGE(_buf, _max_len, _fmt, ...) \
4848
do \
4949
{ \
50-
snprintf((_buf), (_max_len), (_fmt), __VA_ARGS__); \
50+
mbed_snprintf((_buf), (_max_len), (_fmt), __VA_ARGS__); \
5151
}while(0);
5252

5353

components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace mbed;
3131
#endif
3232

3333
#if FLASHIAP_DEBUG
34-
#define DEBUG_PRINTF(...) printf(__VA_ARGS__)
34+
#define DEBUG_PRINTF(...) mbed_printf(__VA_ARGS__)
3535
#else
3636
#define DEBUG_PRINTF(...)
3737
#endif

components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@
3131
* I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024);
3232
*
3333
* int main() {
34-
* printf("i2cee test\n");
34+
* mbed_printf("i2cee test\n");
3535
*
3636
* // Initialize the device and print the memory layout
3737
* i2cee.init();
38-
* printf("i2cee size: %llu\n", i2cee.size());
39-
* printf("i2cee read size: %llu\n", i2cee.get_read_size());
40-
* printf("i2cee program size: %llu\n", i2cee.get_program_size());
41-
* printf("i2cee erase size: %llu\n", i2cee.get_erase_size());
38+
* mbed_printf("i2cee size: %llu\n", i2cee.size());
39+
* mbed_printf("i2cee read size: %llu\n", i2cee.get_read_size());
40+
* mbed_printf("i2cee program size: %llu\n", i2cee.get_program_size());
41+
* mbed_printf("i2cee erase size: %llu\n", i2cee.get_erase_size());
4242
*
4343
* // Write "Hello World!" to the first block
4444
* char *buffer = (char*)malloc(i2cee.get_erase_size());
45-
* sprintf(buffer, "Hello World!\n");
45+
* mbed_sprintf(buffer, "Hello World!\n");
4646
* i2cee.erase(0, i2cee.get_erase_size());
4747
* i2cee.program(buffer, 0, i2cee.get_erase_size());
4848
*
4949
* // Read back what was stored
5050
* i2cee.read(buffer, 0, i2cee.get_erase_size());
51-
* printf("%s", buffer);
51+
* mbed_printf("%s", buffer);
5252
*
5353
* // Deinitialize the device
5454
* i2cee.deinit();

components/storage/blockdevice/COMPONENT_I2CEE/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ https://en.wikipedia.org/wiki/EEPROM
2020
I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024);
2121

2222
int main() {
23-
printf("i2cee test\n");
23+
mbed_printf("i2cee test\n");
2424

2525
// Initialize the device and print the memory layout
2626
i2cee.init();
27-
printf("i2cee size: %llu\n", i2cee.size());
28-
printf("i2cee read size: %llu\n", i2cee.get_read_size());
29-
printf("i2cee program size: %llu\n", i2cee.get_program_size());
30-
printf("i2cee erase size: %llu\n", i2cee.get_erase_size());
27+
mbed_printf("i2cee size: %llu\n", i2cee.size());
28+
mbed_printf("i2cee read size: %llu\n", i2cee.get_read_size());
29+
mbed_printf("i2cee program size: %llu\n", i2cee.get_program_size());
30+
mbed_printf("i2cee erase size: %llu\n", i2cee.get_erase_size());
3131

3232
// Write "Hello World!" to the first block
3333
char *buffer = (char*)malloc(i2cee.get_erase_size());
34-
sprintf(buffer, "Hello World!\n");
34+
mbed_sprintf(buffer, "Hello World!\n");
3535
i2cee.erase(0, i2cee.get_erase_size());
3636
i2cee.program(buffer, 0, i2cee.get_erase_size());
3737

3838
// Read back what was stored
3939
i2cee.read(buffer, 0, i2cee.get_erase_size());
40-
printf("%s", buffer);
40+
mbed_printf("%s", buffer);
4141

4242
// Deinitialize the device
4343
i2cee.deinit();
@@ -66,7 +66,7 @@ struct t_setting {
6666
};
6767
6868
int main() {
69-
printf("i2cee struct test\n");
69+
mbed_printf("i2cee struct test\n");
7070
7171
// No. of bytes to be stored, but topped up to be multiplied by block size
7272
unsigned int setting_block_size = ceil(sizeof(setting)/(double)BLOCK_SIZE)*BLOCK_SIZE;
@@ -78,7 +78,7 @@ int main() {
7878
i2cee.init();
7979
8080
// Save struct to EEPROM
81-
printf("\nSaving struct version: %u, name: %s\n", setting.version, setting.name);
81+
mbed_printf("\nSaving struct version: %u, name: %s\n", setting.version, setting.name);
8282
memcpy(buffer, &setting, sizeof(setting));
8383
i2cee.program(buffer, 0, setting_block_size);
8484
@@ -89,9 +89,9 @@ int main() {
8989
if (i2cee.read(buffer, 0, setting_block_size ) == 0){ // get data into buffer
9090
// Convert what we read into struct
9191
memcpy(&tmp, buffer, sizeof(tmp)); // copy only size of struct not setting_block_size
92-
printf("\nTemporary struct version: %u, name: %s\n", tmp.version, tmp.name);
92+
mbed_printf("\nTemporary struct version: %u, name: %s\n", tmp.version, tmp.name);
9393
} else {
94-
printf("Error when reading\n");
94+
mbed_printf("Error when reading\n");
9595
}
9696
9797
// Deinitialize the device

components/storage/blockdevice/COMPONENT_I2CEE/TESTS/block_device/i2cee/main.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void test_read_write()
4242
bd_size_t size = (bd.*ATTRS[a].method)();
4343

4444
if (size >= (1ULL << 10 * i)) {
45-
printf("%s: %llu%sbytes (%llubytes)\n",
45+
mbed_printf("%s: %llu%sbytes (%llubytes)\n",
4646
ATTRS[a].name, size >> 10 * i, prefixes[i], size);
4747
break;
4848
}
@@ -71,40 +71,40 @@ void test_read_write()
7171
}
7272

7373
// Write, sync, and read the block
74-
printf("test %0*llx:%llu...\n", addrwidth, block, block_size);
74+
mbed_printf("test %0*llx:%llu...\n", addrwidth, block, block_size);
7575

7676
err = bd.erase(block, block_size);
7777
TEST_ASSERT_EQUAL(0, err);
7878

7979
err = bd.program(write_block, block, block_size);
8080
TEST_ASSERT_EQUAL(0, err);
8181

82-
printf("write %0*llx:%llu ", addrwidth, block, block_size);
82+
mbed_printf("write %0*llx:%llu ", addrwidth, block, block_size);
8383

8484
for (int i = 0; i < block_size && i < 16; i++) {
85-
printf("%02x", write_block[i]);
85+
mbed_printf("%02x", write_block[i]);
8686
}
8787

8888
if (block_size > 16) {
89-
printf("...\n");
89+
mbed_printf("...\n");
9090
}
9191

92-
printf("\n");
92+
mbed_printf("\n");
9393

9494
err = bd.read(read_block, block, block_size);
9595
TEST_ASSERT_EQUAL(0, err);
9696

97-
printf("read %0*llx:%llu ", addrwidth, block, block_size);
97+
mbed_printf("read %0*llx:%llu ", addrwidth, block, block_size);
9898

9999
for (int i = 0; i < block_size && i < 16; i++) {
100-
printf("%02x", read_block[i]);
100+
mbed_printf("%02x", read_block[i]);
101101
}
102102

103103
if (block_size > 16) {
104-
printf("...");
104+
mbed_printf("...");
105105
}
106106

107-
printf("\n");
107+
mbed_printf("\n");
108108

109109
// Find error mask for debugging
110110
memset(error_mask, 0, TEST_ERROR_MASK);
@@ -120,13 +120,13 @@ void test_read_write()
120120
}
121121
}
122122

123-
printf("error %0*llx:%llu ", addrwidth, block, block_size);
123+
mbed_printf("error %0*llx:%llu ", addrwidth, block, block_size);
124124

125125
for (int i = 0; i < TEST_ERROR_MASK; i++) {
126-
printf("%02x", error_mask[i]);
126+
mbed_printf("%02x", error_mask[i]);
127127
}
128128

129-
printf("\n");
129+
mbed_printf("\n");
130130

131131
// Check that the data was unmodified
132132
srand(seed);

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,26 @@ enum qspif_polarity_mode {
5959
*
6060
* int main()
6161
* {
62-
* printf("QSPI SFDP Flash Block Device example\n");
62+
* mbed_printf("QSPI SFDP Flash Block Device example\n");
6363
*
6464
* // Initialize the SPI flash device and print the memory layout
6565
* block_device.init();
6666
* bd_size_t sector_size_at_address_0 = block_device.get_erase_size(0);
6767
*
68-
* printf("QSPIF BD size: %llu\n", block_device.size());
69-
* printf("QSPIF BD read size: %llu\n", block_device.get_read_size());
70-
* printf("QSPIF BD program size: %llu\n", block_device.get_program_size());
71-
* printf("QSPIF BD erase size (at address 0): %llu\n", sector_size_at_address_0);
68+
* mbed_printf("QSPIF BD size: %llu\n", block_device.size());
69+
* mbed_printf("QSPIF BD read size: %llu\n", block_device.get_read_size());
70+
* mbed_printf("QSPIF BD program size: %llu\n", block_device.get_program_size());
71+
* mbed_printf("QSPIF BD erase size (at address 0): %llu\n", sector_size_at_address_0);
7272
*
7373
* // Write "Hello World!" to the first block
7474
* char *buffer = (char *) malloc(sector_size_at_address_0);
75-
* sprintf(buffer, "Hello World!\n");
75+
* mbed_sprintf(buffer, "Hello World!\n");
7676
* block_device.erase(0, sector_size_at_address_0);
7777
* block_device.program(buffer, 0, sector_size_at_address_0);
7878
*
7979
* // Read back what was stored
8080
* block_device.read(buffer, 0, sector_size_at_address_0);
81-
* printf("%s", buffer);
81+
* mbed_printf("%s", buffer);
8282
*
8383
* // Deinitialize the device
8484
* block_device.deinit();

components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,22 @@ void SPIFReducedBlockDevice::_cmdread(
157157
_cs = 1;
158158

159159
if (SPIF_DEBUG) {
160-
printf("spif <- %02x", op);
160+
mbed_printf("spif <- %02x", op);
161161
for (uint32_t i = 0; i < addrc; i++) {
162162
if (i < addrc) {
163-
printf("%02lx", 0xff & (addr >> 8 * (addrc - 1 - i)));
163+
mbed_printf("%02lx", 0xff & (addr >> 8 * (addrc - 1 - i)));
164164
} else {
165-
printf(" ");
165+
mbed_printf(" ");
166166
}
167167
}
168-
printf(" ");
168+
mbed_printf(" ");
169169
for (uint32_t i = 0; i < 16 && i < retc; i++) {
170-
printf("%02x", rets[i]);
170+
mbed_printf("%02x", rets[i]);
171171
}
172172
if (retc > 16) {
173-
printf("...");
173+
mbed_printf("...");
174174
}
175-
printf("\n");
175+
mbed_printf("\n");
176176
}
177177
}
178178

@@ -193,22 +193,22 @@ void SPIFReducedBlockDevice::_cmdwrite(
193193
_cs = 1;
194194

195195
if (SPIF_DEBUG) {
196-
printf("spif -> %02x", op);
196+
mbed_printf("spif -> %02x", op);
197197
for (uint32_t i = 0; i < addrc; i++) {
198198
if (i < addrc) {
199-
printf("%02lx", 0xff & (addr >> 8 * (addrc - 1 - i)));
199+
mbed_printf("%02lx", 0xff & (addr >> 8 * (addrc - 1 - i)));
200200
} else {
201-
printf(" ");
201+
mbed_printf(" ");
202202
}
203203
}
204-
printf(" ");
204+
mbed_printf(" ");
205205
for (uint32_t i = 0; i < 16 && i < argc; i++) {
206-
printf("%02x", args[i]);
206+
mbed_printf("%02x", args[i]);
207207
}
208208
if (argc > 16) {
209-
printf("...");
209+
mbed_printf("...");
210210
}
211-
printf("\n");
211+
mbed_printf("\n");
212212
}
213213
}
214214

components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@
3232
* SPIFReducedBlockDevice rspif(PTE2, PTE4, PTE1, PTE5);
3333
*
3434
* int main() {
35-
* printf("reduced spif test\n");
35+
* mbed_printf("reduced spif test\n");
3636
*
3737
* // Initialize the Reduced SPI flash device and print the memory layout
3838
* rspif.init();
39-
* printf("rspif size: %llu\n", rspif.size());
40-
* printf("rspif read size: %llu\n", rspif.get_read_size());
41-
* printf("rspif program size: %llu\n", rspif.get_program_size());
42-
* printf("rspif erase size: %llu\n", rspif.get_erase_size());
39+
* mbed_printf("rspif size: %llu\n", rspif.size());
40+
* mbed_printf("rspif read size: %llu\n", rspif.get_read_size());
41+
* mbed_printf("rspif program size: %llu\n", rspif.get_program_size());
42+
* mbed_printf("rspif erase size: %llu\n", rspif.get_erase_size());
4343
*
4444
* // Write "Hello World!" to the first block
4545
* char *buffer = (char*)malloc(rspif.get_erase_size());
46-
* sprintf(buffer, "Hello World!\n");
46+
* mbed_sprintf(buffer, "Hello World!\n");
4747
* rspif.erase(0, rspif.get_erase_size());
4848
* rspif.program(buffer, 0, rspif.get_erase_size());
4949
*
5050
* // Read back what was stored
5151
* rspif.read(buffer, 0, rspif.get_erase_size());
52-
* printf("%s", buffer);
52+
* mbed_printf("%s", buffer);
5353
*
5454
* // Deinitialize the device
5555
* rspif.deinit();

0 commit comments

Comments
 (0)