ProfilingBlockDevice example showing logging capabilities

Fork of ChainingBlockDevice_ex_1 by mbed_example

Committer:
kgilbert
Date:
Mon Oct 30 20:36:05 2017 +0000
Revision:
2:20bf5212cdd6
Parent:
1:8ad9777787ba
Add source for example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kgilbert 0:daa62d7aa9f9 1 #include "mbed.h"
kgilbert 0:daa62d7aa9f9 2 #include "HeapBlockDevice.h"
kgilbert 2:20bf5212cdd6 3 #include "ProfilingBlockDevice.h"
kgilbert 2:20bf5212cdd6 4
kgilbert 2:20bf5212cdd6 5 #define BLOCK_SIZE 512
kgilbert 2:20bf5212cdd6 6
kgilbert 2:20bf5212cdd6 7 HeapBlockDevice bd(2048, BLOCK_SIZE); // 2048 bytes with a block size of 512 bytes
kgilbert 2:20bf5212cdd6 8 uint8_t block[BLOCK_SIZE] = "Hello World!\n";
kgilbert 2:20bf5212cdd6 9
kgilbert 2:20bf5212cdd6 10 int main() {
kgilbert 2:20bf5212cdd6 11 ProfilingBlockDevice profiler(&bd);
kgilbert 2:20bf5212cdd6 12 profiler.init();
kgilbert 2:20bf5212cdd6 13 profiler.erase(0, BLOCK_SIZE);
kgilbert 2:20bf5212cdd6 14 profiler.program(block, 0, BLOCK_SIZE);
kgilbert 2:20bf5212cdd6 15 profiler.read(block, 0, BLOCK_SIZE);
kgilbert 0:daa62d7aa9f9 16
kgilbert 2:20bf5212cdd6 17 printf("%s", block);
kgilbert 2:20bf5212cdd6 18 printf("read count: %lld\n", profiler.get_read_count());
kgilbert 2:20bf5212cdd6 19 printf("program count: %lld\n", profiler.get_program_count());
kgilbert 2:20bf5212cdd6 20 printf("erase count: %lld\n", profiler.get_erase_count());
kgilbert 0:daa62d7aa9f9 21 }