An example using the SDFileSystem library to create a directory and write a fiel to an SD card, using its SPI interface
Dependencies: mbed SDFileSystem
main.cpp
00001 // example writing to SD card, sford 00002 00003 #include "mbed.h" 00004 #include "SDFileSystem.h" 00005 00006 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board 00007 00008 int main() { 00009 printf("Hello World!\n"); 00010 00011 mkdir("/sd/mydir", 0777); 00012 00013 FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); 00014 if(fp == NULL) { 00015 error("Could not open file for write\n"); 00016 } 00017 fprintf(fp, "Hello fun SD Card World!"); 00018 fclose(fp); 00019 00020 printf("Goodbye World!\n"); 00021 }
Generated on Tue Jul 12 2022 13:07:47 by 1.7.2