MBRBlockDevice partitioning 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 "MBRBlockDevice.h"
00004     
00005 int main(void) {
00006     // Create a block device with 64 blocks of size 512
00007     HeapBlockDevice mem(64*512, 512);
00008     
00009     // Partition into two partitions with ~half the blocks
00010     MBRBlockDevice::partition(&mem, 1, 0x83, 0*512, 32*512);
00011     MBRBlockDevice::partition(&mem, 2, 0x83, 32*512);
00012     
00013     // Create a block device that maps to the first 32 blocks (excluding MBR block)
00014     MBRBlockDevice part1(&mem, 1);
00015     
00016     // Create a block device that maps to the last 32 blocks
00017     MBRBlockDevice part2(&mem, 2);
00018 }