mbed sd

Dependencies:   SDFileSystem mbed

Committer:
jh_ndm
Date:
Fri Jul 15 01:21:28 2016 +0000
Revision:
0:27143f32cefd
Child:
1:456047999cb0
dfrobot SD

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jh_ndm 0:27143f32cefd 1 #include "mbed.h"
jh_ndm 0:27143f32cefd 2 #include "SDFileSystem.h"
jh_ndm 0:27143f32cefd 3
jh_ndm 0:27143f32cefd 4 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");
jh_ndm 0:27143f32cefd 5 //SDFileSystem sd(PB_03, PB_02, PB_01, PB_00, "sd");
jh_ndm 0:27143f32cefd 6 Serial uart1(PA_13,PA_14);
jh_ndm 0:27143f32cefd 7 int main() {
jh_ndm 0:27143f32cefd 8 uart1.printf("Hello World!\n");
jh_ndm 0:27143f32cefd 9
jh_ndm 0:27143f32cefd 10 mkdir("/sd/mydir", 0777);
jh_ndm 0:27143f32cefd 11
jh_ndm 0:27143f32cefd 12 FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
jh_ndm 0:27143f32cefd 13 if(fp == NULL) {
jh_ndm 0:27143f32cefd 14 error("Could not open file for write\n");
jh_ndm 0:27143f32cefd 15 }
jh_ndm 0:27143f32cefd 16 fprintf(fp, "Hello fun SD1 Card World!");
jh_ndm 0:27143f32cefd 17 fclose(fp);
jh_ndm 0:27143f32cefd 18
jh_ndm 0:27143f32cefd 19 uart1.printf("Goodbye World!\n");
jh_ndm 0:27143f32cefd 20 }