ProfilingBlockDevice example showing logging capabilities

Fork of ChainingBlockDevice_ex_1 by mbed_example

Revision:
2:20bf5212cdd6
Parent:
1:8ad9777787ba
--- a/main.cpp	Wed Oct 18 20:03:25 2017 +0000
+++ b/main.cpp	Mon Oct 30 20:36:05 2017 +0000
@@ -1,23 +1,21 @@
 #include "mbed.h"
 #include "HeapBlockDevice.h"
-#include "ChainingBlockDevice.h"
-#include "FATFileSystem.h"
-    
-int main(void) {
-    // Create two smaller block devices with
-    // 64 and 32 blocks of size 512 bytes
-    HeapBlockDevice mem1(64*512, 512);
-    HeapBlockDevice mem2(32*512, 512);
+#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);
     
-    // Create a block device backed by mem1 and mem2
-    // contains 96 blocks of size 512 bytes
-    BlockDevice *bds[] = {&mem1, &mem2};
-    ChainingBlockDevice chainmem(bds);
-    
-    // Format the new chained block device with a FAT filesystem
-    FATFileSystem::format(&chainmem);
-    
-    // Create the FAT filesystem instance, files can now be written to
-    // the FAT filesystem as if to a single 96 x 512 byte storage device
-    FATFileSystem fat("fat", &chainmem);
+    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());
 }
\ No newline at end of file