Colin Hogben
/
sd_test_5
SDFileSystem test for mbed OS 5
Revision 0:648259a2341c, committed 2016-08-16
- Comitter:
- infinnovation
- Date:
- Tue Aug 16 22:03:01 2016 +0000
- Commit message:
- Test SDFileSystem with mbed OS 5
Changed in this revision
diff -r 000000000000 -r 648259a2341c SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Tue Aug 16 22:03:01 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/infinnovation/code/SDFileSystem/#cf988cb4fad9
diff -r 000000000000 -r 648259a2341c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Aug 16 22:03:01 2016 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "SDFileSystem.h" + +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS +Serial pc(USBTX, USBRX); +FILE *fp; + +uint32_t do_list(const char *fsrc) +{ + DIR *d = opendir(fsrc); + struct dirent *p; + uint32_t counter = 0; + + while ((p = readdir(d)) != NULL) { + counter++; + printf("%s\n", p->d_name); + } + closedir(d); + return counter; +} + +// bool is_folder(const char *fdir) +// { +// DIR *dir = opendir(fdir); +// if (dir) { +// closedir(dir); +// } +// return (dir != NULL); + +// } + +// bool is_file(const char *ffile) +// { +// FILE *fp = fopen(ffile, "r"); +// if (fp) { +// fclose(fp); +// } +// return (fp != NULL); +// } + +int main() +{ + pc.printf("Initializing \n"); + wait(2); + + printf("disk_status: %d\n", sd.disk_status()); + printf("card_present: %d\n", sd.card_present()); + printf("card_type: %d\n", (int)sd.card_type()); + + printf("\nList /\n"); + do_list("/"); + + printf("\nList /sd\n"); + do_list("/sd"); + printf("\nEnd\n"); +}
diff -r 000000000000 -r 648259a2341c mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Aug 16 22:03:01 2016 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#0993ae540c5c4b5ce3004bead1aefc0c6d1b3ea0