MBRBlockDevice partitioning example

Files at this revision

API Documentation at this revision

Comitter:
kgilbert
Date:
Fri Oct 13 16:56:09 2017 +0000
Commit message:
Add source for example

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r daa62d7aa9f9 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 13 16:56:09 2017 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+#include "HeapBlockDevice.h"
+#include "MBRBlockDevice.h"
+    
+int main(void) {
+    // Create a block device with 64 blocks of size 512
+    HeapBlockDevice mem(64*512, 512);
+    
+    // Partition into two partitions with ~half the blocks
+    MBRBlockDevice::partition(&mem, 1, 0x83, 0*512, 32*512);
+    MBRBlockDevice::partition(&mem, 2, 0x83, 32*512);
+    
+    // Create a block device that maps to the first 32 blocks (excluding MBR block)
+    MBRBlockDevice part1(&mem, 1);
+    
+    // Create a block device that maps to the last 32 blocks
+    MBRBlockDevice part2(&mem, 2);
+}
\ No newline at end of file
diff -r 000000000000 -r daa62d7aa9f9 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Oct 13 16:56:09 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#6e0d01cd13e8aca7bf4d697c3699ec9225386881