ProfilingBlockDevice example showing logging capabilities

Fork of ChainingBlockDevice_ex_1 by mbed_example

main.cpp

Committer:
kgilbert
Date:
2017-10-30
Revision:
2:20bf5212cdd6
Parent:
1:8ad9777787ba

File content as of revision 2:20bf5212cdd6:

#include "mbed.h"
#include "HeapBlockDevice.h"
#include "ProfilingBlockDevice.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() {
    ProfilingBlockDevice profiler(&bd);
    profiler.init();
    profiler.erase(0, BLOCK_SIZE);
    profiler.program(block, 0, BLOCK_SIZE);
    profiler.read(block, 0, BLOCK_SIZE);
    
    printf("%s", block);
    printf("read count: %lld\n", profiler.get_read_count());
    printf("program count: %lld\n", profiler.get_program_count());
    printf("erase count: %lld\n", profiler.get_erase_count());
}