mbed_example
/
HeapBlockDevice_ex_1
Example for HeapBlockDevice use
Diff: main.cpp
- Revision:
- 3:5991e7053465
- Parent:
- 2:e29db7517d42
--- a/main.cpp Tue Oct 10 21:14:20 2017 +0000 +++ b/main.cpp Tue Oct 10 22:15:12 2017 +0000 @@ -1,13 +1,16 @@ #include "mbed.h" #include "HeapBlockDevice.h" -HeapBlockDevice bd(2048, 512); // 2048 bytes with a block size of 512 bytes -uint8_t block[512] = "Hello World!\n"; +#define BLOCK_SIZE 512 + +HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes +uint8_t block[BLOCK_SIZE] = "Hello World!\n"; int main() { bd.init(); - bd.program(block, 0, bd.get_program_size()); - bd.read(block, 0, bd.get_read_size()); + bd.erase(0, BLOCK_SIZE); + bd.program(block, 0, BLOCK_SIZE); + bd.read(block, 0, BLOCK_SIZE); printf("%s", block); bd.deinit(); } \ No newline at end of file