Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ChainingBlockDevice_ex_1 by
Revision 2:20bf5212cdd6, committed 2017-10-30
- Comitter:
- kgilbert
- Date:
- Mon Oct 30 20:36:05 2017 +0000
- Parent:
- 1:8ad9777787ba
- Commit message:
- Add source for example
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8ad9777787ba -r 20bf5212cdd6 main.cpp
--- 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
