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: USBDevice USBMSD_SD mbed
Fork of USBMSD_SD_HelloWorld_Mbed by
main.cpp@12:a12eb1fc05f3, 2011-11-30 (annotated)
- Committer:
- samux 
- Date:
- Wed Nov 30 17:50:35 2011 +0000
- Revision:
- 12:a12eb1fc05f3
- Parent:
- 11:a26e7b7a1221
- Child:
- 13:32b8a767cf0e
demo for chris OK
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| samux | 2:27a7e7f8d399 | 1 | #include "mbed.h" | 
| samux | 7:6494da2a5c60 | 2 | #include "SDFileSystem.h" | 
| samux | 2:27a7e7f8d399 | 3 | |
| samux | 12:a12eb1fc05f3 | 4 | SDFileSystem sd(p11, p12, p13, p14, "sd"); | 
| samux | 2:27a7e7f8d399 | 5 | |
| samux | 12:a12eb1fc05f3 | 6 | DigitalIn button(p16); | 
| samux | 10:cf8fd2b6ca23 | 7 | |
| samux | 2:27a7e7f8d399 | 8 | int main() { | 
| samux | 12:a12eb1fc05f3 | 9 | if (button) { | 
| samux | 12:a12eb1fc05f3 | 10 | sd.connect(); | 
| samux | 12:a12eb1fc05f3 | 11 | } else { | 
| samux | 12:a12eb1fc05f3 | 12 | mkdir("/sd/mydir", 0777); | 
| samux | 11:a26e7b7a1221 | 13 | |
| samux | 12:a12eb1fc05f3 | 14 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); | 
| samux | 12:a12eb1fc05f3 | 15 | if (fp == NULL) { | 
| samux | 12:a12eb1fc05f3 | 16 | error("Could not open file for write\n"); | 
| samux | 12:a12eb1fc05f3 | 17 | } | 
| samux | 12:a12eb1fc05f3 | 18 | fprintf(fp, "Hello fun SD Card World!"); | 
| samux | 12:a12eb1fc05f3 | 19 | fclose(fp); | 
| samux | 12:a12eb1fc05f3 | 20 | |
| samux | 10:cf8fd2b6ca23 | 21 | } | 
| samux | 12:a12eb1fc05f3 | 22 | while (1); | 
| samux | 9:9c343b9ee6d8 | 23 | } | 
