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 MBRBlockDevice_ex_1 by
Revision 1:8ad9777787ba, committed 2017-10-18
- Comitter:
- kgilbert
- Date:
- Wed Oct 18 20:03:25 2017 +0000
- Parent:
- 0:daa62d7aa9f9
- Commit message:
- Add source for example
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Oct 13 16:56:09 2017 +0000 +++ b/main.cpp Wed Oct 18 20:03:25 2017 +0000 @@ -1,18 +1,23 @@ #include "mbed.h" #include "HeapBlockDevice.h" -#include "MBRBlockDevice.h" +#include "ChainingBlockDevice.h" +#include "FATFileSystem.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 two smaller block devices with + // 64 and 32 blocks of size 512 bytes + HeapBlockDevice mem1(64*512, 512); + HeapBlockDevice mem2(32*512, 512); - // Create a block device that maps to the first 32 blocks (excluding MBR block) - MBRBlockDevice part1(&mem, 1); + // Create a block device backed by mem1 and mem2 + // contains 96 blocks of size 512 bytes + BlockDevice *bds[] = {&mem1, &mem2}; + ChainingBlockDevice chainmem(bds); - // Create a block device that maps to the last 32 blocks - MBRBlockDevice part2(&mem, 2); + // 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); } \ No newline at end of file