SD Card usage example

Dependencies:   mbed SDFileSystem

main.cpp

Committer:
ffxx68
Date:
22 months ago
Revision:
2:f31ded5c20f3
Parent:
0:bdbd3d6fc5d5

File content as of revision 2:f31ded5c20f3:

#include "mbed.h"
#include "SDFileSystem.h"
 
//SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sclk, cs
SDFileSystem sd(PB_5, PB_4, PB_3, PA_10, "sd"); // mosi, miso, sclk, cs

int main() {
     printf("SD Card Testbed\n");   
     
     //Perform a write test
     printf("Writing to SD card... ");
     FILE *fp = fopen("/sd/sdtest.txt", "w");
     if (fp != NULL) {
         fprintf(fp, "We're writing to an SD card!");
         fclose(fp);
         printf("success!\n");
     } else 
        printf("failed!\n");
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 
    
    printf("Goodbye World!\n");
}