SD card file helloworld demo using new mbed RTOS ver 5 file driver setup. Pins setup for LPC1768 - read comment in code about project's json file requirements for adding the SD filesystem driver
SD card r/w demo for mbed OS version 5 on LPC1768.
File drivers are added in json file with "target.components_add": ["SD"] for use in most recent OS 5 version.
Test messages are sent to serial port with printf's.
Diff: main.cpp
- Revision:
- 0:3588d7473dce
- Child:
- 1:3a59eb72e0cf
diff -r 000000000000 -r 3588d7473dce main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 11 12:39:11 2019 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" +// Need "target.components_add": ["SD"] in json project file! +#include "SDBlockDevice.h" +#include "FATFileSystem.h" + +SDBlockDevice sd(p5, p6, p7, p8); +FATFileSystem fs("SD"); + +int main() { + sd.init(); + fs.mount(&sd); + + FILE* fd = fopen("/SD/hi.txt", "w"); + fprintf(fd, "hello!\n\r"); + fclose(fd); + + sd.deinit(); + fs.unmount(); +} \ No newline at end of file