Example for HeapBlockDevice use

main.cpp

Committer:
kgilbert
Date:
21 months ago
Revision:
3:5991e7053465
Parent:
2:e29db7517d42

File content as of revision 3:5991e7053465:

#include "mbed.h"
#include "HeapBlockDevice.h"

#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.erase(0, BLOCK_SIZE);
    bd.program(block, 0, BLOCK_SIZE);
    bd.read(block, 0, BLOCK_SIZE);
    printf("%s", block);
    bd.deinit();
}