將壽 大谷 / Mbed 2 deprecated SDFileSystem_HelloWorld_same

Dependencies:   mbed SDFileSystem

Committer:
Yukihisa
Date:
Mon Mar 04 13:03:03 2019 +0000
Revision:
2:9adf8313ac9f
Parent:
0:bdbd3d6fc5d5
SD mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:bdbd3d6fc5d5 1 #include "mbed.h"
mbed_official 0:bdbd3d6fc5d5 2 #include "SDFileSystem.h"
mbed_official 0:bdbd3d6fc5d5 3
mbed_official 0:bdbd3d6fc5d5 4 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
mbed_official 0:bdbd3d6fc5d5 5
mbed_official 0:bdbd3d6fc5d5 6 int main() {
mbed_official 0:bdbd3d6fc5d5 7 printf("Hello World!\n");
mbed_official 0:bdbd3d6fc5d5 8
mbed_official 0:bdbd3d6fc5d5 9 mkdir("/sd/mydir", 0777);
mbed_official 0:bdbd3d6fc5d5 10
Yukihisa 2:9adf8313ac9f 11 FILE *fp = fopen("/sd/mydir/sdtest.txt", "a");
mbed_official 0:bdbd3d6fc5d5 12 if(fp == NULL) {
Yukihisa 2:9adf8313ac9f 13 error("Could not open file for write");
mbed_official 0:bdbd3d6fc5d5 14 }
Yukihisa 2:9adf8313ac9f 15 fprintf(fp,"\n");
mbed_official 0:bdbd3d6fc5d5 16 fprintf(fp, "Hello fun SD Card World!");
mbed_official 0:bdbd3d6fc5d5 17 fclose(fp);
mbed_official 0:bdbd3d6fc5d5 18
mbed_official 0:bdbd3d6fc5d5 19 printf("Goodbye World!\n");
mbed_official 0:bdbd3d6fc5d5 20 }