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.
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 00004 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS 00005 Serial pc(USBTX, USBRX); 00006 FILE *fp; 00007 00008 uint32_t do_list(const char *fsrc) 00009 { 00010 DIR *d = opendir(fsrc); 00011 struct dirent *p; 00012 uint32_t counter = 0; 00013 00014 while ((p = readdir(d)) != NULL) { 00015 counter++; 00016 printf("%s\n", p->d_name); 00017 } 00018 closedir(d); 00019 return counter; 00020 } 00021 00022 // bool is_folder(const char *fdir) 00023 // { 00024 // DIR *dir = opendir(fdir); 00025 // if (dir) { 00026 // closedir(dir); 00027 // } 00028 // return (dir != NULL); 00029 00030 // } 00031 00032 // bool is_file(const char *ffile) 00033 // { 00034 // FILE *fp = fopen(ffile, "r"); 00035 // if (fp) { 00036 // fclose(fp); 00037 // } 00038 // return (fp != NULL); 00039 // } 00040 00041 int main() 00042 { 00043 pc.printf("Initializing \n"); 00044 wait(2); 00045 00046 printf("disk_status: %d\n", sd.disk_status()); 00047 printf("card_present: %d\n", sd.card_present()); 00048 printf("card_type: %d\n", (int)sd.card_type()); 00049 00050 printf("\nList /\n"); 00051 do_list("/"); 00052 00053 printf("\nList /sd\n"); 00054 do_list("/sd"); 00055 printf("\nEnd\n"); 00056 }
Generated on Fri Jul 15 2022 10:42:17 by
1.7.2