mbed sd

Dependencies:   SDFileSystem mbed

main.cpp

Committer:
jh_ndm
Date:
2016-07-15
Revision:
0:27143f32cefd
Child:
1:456047999cb0

File content as of revision 0:27143f32cefd:

#include "mbed.h"
#include "SDFileSystem.h"
 
SDFileSystem sd(PA_14, PA_13, PA_12, PA_11, "sd"); // the pinout on the mbed Cool Components workshop board  SDFileSystem sd(PB_03, PB_02, PB_01, PB_00, "sd");
//SDFileSystem sd(PB_03, PB_02, PB_01, PB_00, "sd");
Serial uart1(PA_13,PA_14);
int main() {
    uart1.printf("Hello World!\n");   
 
    mkdir("/sd/mydir", 0777);
    
    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        error("Could not open file for write\n");
    }
    fprintf(fp, "Hello fun SD1 Card World!");
    fclose(fp); 
 
    uart1.printf("Goodbye World!\n");
}