mbed_example
/
MBRBlockDevice_ex_2
MBRBlockDevice FAT filesystem on a SD card
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "SDBlockDevice.h" 00003 #include "MBRBlockDevice.h" 00004 #include "FATFileSystem.h" 00005 00006 // Pin mappings for K64F 00007 PinName s0 = PTE3; // MOSI 00008 PinName s1 = PTE1; // MISO 00009 PinName s2 = PTE2; // SCLK 00010 PinName s3 = PTE4; // CS 00011 00012 int main(void) { 00013 // Create an SD card 00014 SDBlockDevice sd(s0, s1, s2, s3); 00015 00016 // Create a partition with 1 GB of space 00017 MBRBlockDevice::partition(&sd, 1, 0x83, 0, 1024*1024); 00018 00019 // Create the block device that represents the partition 00020 MBRBlockDevice part1(&sd, 1); 00021 00022 // Format the partition with a FAT filesystem 00023 FATFileSystem::format(&part1); 00024 00025 // Create the FAT filesystem instance, files can now be written to 00026 // the FAT filesystem in partition 1 00027 FATFileSystem fat("fat", &part1); 00028 }
Generated on Wed Jul 27 2022 03:17:18 by 1.7.2