![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dependencies: mbed SDFileSystem
main.cpp@0:324e550ad72a, 2011-10-17 (annotated)
- Committer:
- gbeardall
- Date:
- Mon Oct 17 10:42:23 2011 +0000
- Revision:
- 0:324e550ad72a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gbeardall | 0:324e550ad72a | 1 | // example writing to SD card, sford |
gbeardall | 0:324e550ad72a | 2 | |
gbeardall | 0:324e550ad72a | 3 | #include "mbed.h" |
gbeardall | 0:324e550ad72a | 4 | #include "SDFileSystem.h" |
gbeardall | 0:324e550ad72a | 5 | |
gbeardall | 0:324e550ad72a | 6 | SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board |
gbeardall | 0:324e550ad72a | 7 | |
gbeardall | 0:324e550ad72a | 8 | int main() { |
gbeardall | 0:324e550ad72a | 9 | printf("Hello World!\n"); |
gbeardall | 0:324e550ad72a | 10 | |
gbeardall | 0:324e550ad72a | 11 | mkdir("/sd/mydir", 0777); |
gbeardall | 0:324e550ad72a | 12 | |
gbeardall | 0:324e550ad72a | 13 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); |
gbeardall | 0:324e550ad72a | 14 | if(fp == NULL) { |
gbeardall | 0:324e550ad72a | 15 | error("Could not open file for write\n"); |
gbeardall | 0:324e550ad72a | 16 | } |
gbeardall | 0:324e550ad72a | 17 | fprintf(fp, "Hello fun SD Card World!"); |
gbeardall | 0:324e550ad72a | 18 | fclose(fp); |
gbeardall | 0:324e550ad72a | 19 | |
gbeardall | 0:324e550ad72a | 20 | printf("Goodbye World!\n"); |
gbeardall | 0:324e550ad72a | 21 | } |