Example for HeapBlockDevice use
Revision 3:5991e7053465, committed 2017-10-10
- Comitter:
- kgilbert
- Date:
- Tue Oct 10 22:15:12 2017 +0000
- Parent:
- 2:e29db7517d42
- Commit message:
- Add erase step
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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
mbed_example