ChainingBlockDevice example to showcase programming and reading from a chained group of HeapBlockDevices.
Fork of ChainingBlockDevice_ex_1 by
main.cpp@0:daa62d7aa9f9, 2017-10-13 (annotated)
- Committer:
- kgilbert
- Date:
- Fri Oct 13 16:56:09 2017 +0000
- Revision:
- 0:daa62d7aa9f9
- Child:
- 1:8ad9777787ba
Add source for example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kgilbert | 0:daa62d7aa9f9 | 1 | #include "mbed.h" |
kgilbert | 0:daa62d7aa9f9 | 2 | #include "HeapBlockDevice.h" |
kgilbert | 0:daa62d7aa9f9 | 3 | #include "MBRBlockDevice.h" |
kgilbert | 0:daa62d7aa9f9 | 4 | |
kgilbert | 0:daa62d7aa9f9 | 5 | int main(void) { |
kgilbert | 0:daa62d7aa9f9 | 6 | // Create a block device with 64 blocks of size 512 |
kgilbert | 0:daa62d7aa9f9 | 7 | HeapBlockDevice mem(64*512, 512); |
kgilbert | 0:daa62d7aa9f9 | 8 | |
kgilbert | 0:daa62d7aa9f9 | 9 | // Partition into two partitions with ~half the blocks |
kgilbert | 0:daa62d7aa9f9 | 10 | MBRBlockDevice::partition(&mem, 1, 0x83, 0*512, 32*512); |
kgilbert | 0:daa62d7aa9f9 | 11 | MBRBlockDevice::partition(&mem, 2, 0x83, 32*512); |
kgilbert | 0:daa62d7aa9f9 | 12 | |
kgilbert | 0:daa62d7aa9f9 | 13 | // Create a block device that maps to the first 32 blocks (excluding MBR block) |
kgilbert | 0:daa62d7aa9f9 | 14 | MBRBlockDevice part1(&mem, 1); |
kgilbert | 0:daa62d7aa9f9 | 15 | |
kgilbert | 0:daa62d7aa9f9 | 16 | // Create a block device that maps to the last 32 blocks |
kgilbert | 0:daa62d7aa9f9 | 17 | MBRBlockDevice part2(&mem, 2); |
kgilbert | 0:daa62d7aa9f9 | 18 | } |