mbed_example / Mbed OS ProfilingBlockDevice_ex_1

Fork of ChainingBlockDevice_ex_1 by mbed_example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HeapBlockDevice.h"
00003 #include "ProfilingBlockDevice.h"
00004 
00005 #define BLOCK_SIZE 512
00006 
00007 HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes
00008 uint8_t block[BLOCK_SIZE] = "Hello World!\n";
00009 
00010 int main() {
00011     ProfilingBlockDevice profiler(&bd);
00012     profiler.init();
00013     profiler.erase(0, BLOCK_SIZE);
00014     profiler.program(block, 0, BLOCK_SIZE);
00015     profiler.read(block, 0, BLOCK_SIZE);
00016     
00017     printf("%s", block);
00018     printf("read count: %lld\n", profiler.get_read_count());
00019     printf("program count: %lld\n", profiler.get_program_count());
00020     printf("erase count: %lld\n", profiler.get_erase_count());
00021 }