Example for HeapBlockDevice use

Committer:
kgilbert
Date:
Tue Oct 10 22:15:12 2017 +0000
Revision:
3:5991e7053465
Parent:
2:e29db7517d42
Add erase step

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kgilbert 0:acdc1ce79ab5 1 #include "mbed.h"
kgilbert 1:fbc7acd77a77 2 #include "HeapBlockDevice.h"
kgilbert 1:fbc7acd77a77 3
kgilbert 3:5991e7053465 4 #define BLOCK_SIZE 512
kgilbert 3:5991e7053465 5
kgilbert 3:5991e7053465 6 HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes
kgilbert 3:5991e7053465 7 uint8_t block[BLOCK_SIZE] = "Hello World!\n";
kgilbert 1:fbc7acd77a77 8
kgilbert 1:fbc7acd77a77 9 int main() {
kgilbert 1:fbc7acd77a77 10 bd.init();
kgilbert 3:5991e7053465 11 bd.erase(0, BLOCK_SIZE);
kgilbert 3:5991e7053465 12 bd.program(block, 0, BLOCK_SIZE);
kgilbert 3:5991e7053465 13 bd.read(block, 0, BLOCK_SIZE);
kgilbert 1:fbc7acd77a77 14 printf("%s", block);
kgilbert 1:fbc7acd77a77 15 bd.deinit();
kgilbert 1:fbc7acd77a77 16 }