Fabio Fumi / Mbed 2 deprecated SDFileSystem_HelloWorld

Dependencies:   mbed SDFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SDFileSystem.h"
00003  
00004 //SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sclk, cs
00005 SDFileSystem sd(PB_5, PB_4, PB_3, PA_10, "sd"); // mosi, miso, sclk, cs
00006 
00007 int main() {
00008      printf("SD Card Testbed\n");   
00009      
00010      //Perform a write test
00011      printf("Writing to SD card... ");
00012      FILE *fp = fopen("/sd/sdtest.txt", "w");
00013      if (fp != NULL) {
00014          fprintf(fp, "We're writing to an SD card!");
00015          fclose(fp);
00016          printf("success!\n");
00017      } else 
00018         printf("failed!\n");
00019     fprintf(fp, "Hello fun SD Card World!");
00020     fclose(fp); 
00021     
00022     printf("Goodbye World!\n");
00023 }