1
Dependencies: SDFileSystem mbed
main.cpp
- Committer:
- yu10078999
- Date:
- 2016-09-10
- Revision:
- 0:4e67ce020359
- Child:
- 1:1c3f6ffb47c6
File content as of revision 0:4e67ce020359:
#include "mbed.h" #include "SDFileSystem.h" Serial pc(USBTX, USBRX); SDFileSystem sd(PC_3, PC_2, PB_10, PE_2, "sd"); // MOSI, MISO, SCK, CS FILE *fp; char data[100]; int main() { wait(1); pc.printf("Initializing\r\n"); fp = fopen("/sd/hello.txt", "r"); //檔名可以任意改 if (fp == NULL) { pc.printf("Fail\r\n"); } fread( data, sizeof(data), 1, fp ); fclose(fp); pc.printf("File successfully read!\r\n"); pc.printf(" Your data:\n%s\n",data); }