Add erase to example

Use defined blocksize constant
pull/5292/head
Kevin Gilbert 2017-10-10 17:19:24 -05:00 committed by GitHub
parent 37b3b40e2a
commit 86fa6771bd
1 changed files with 7 additions and 4 deletions

View File

@ -34,13 +34,16 @@
* #include "mbed.h" * #include "mbed.h"
* #include "HeapBlockDevice.h" * #include "HeapBlockDevice.h"
* *
* HeapBlockDevice bd(2048, 512); // 2048 bytes with a block size of 512 bytes * #define BLOCK_SIZE 512
* uint8_t block[512] = "Hello World!\n"; *
* HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes
* uint8_t block[BLOCK_SIZE] = "Hello World!\n";
* *
* int main() { * int main() {
* bd.init(); * bd.init();
* bd.program(block, 0, bd.get_program_size()); * bd.erase(0, BLOCK_SIZE);
* bd.read(block, 0, bd.get_read_size()); * bd.program(block, 0, BLOCK_SIZE);
* bd.read(block, 0, BLOCK_SIZE);
* printf("%s", block); * printf("%s", block);
* bd.deinit(); * bd.deinit();
* } * }