Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem mbed
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 00004 Serial pc(USBTX, USBRX); 00005 SDFileSystem sd(PC_3, PC_2, PB_10, PE_2, "sd"); // MOSI, MISO, SCK, CS 00006 00007 FILE *fp; 00008 char data[100]; 00009 00010 int main() { 00011 wait(1); 00012 pc.printf("Initializing\r\n"); 00013 00014 fp = fopen("/sd/hello.txt", "r"); //檔名改成跟Write時候一樣的名稱 00015 00016 if (fp == NULL) { 00017 pc.printf("Fail\r\n"); 00018 } 00019 00020 fread( data, sizeof(data), 1, fp ); 00021 fclose(fp); 00022 pc.printf("File successfully read!\r\n"); 00023 pc.printf(" Your data:\n%s\n",data); 00024 }
Generated on Wed Jul 13 2022 12:47:46 by
1.7.2