ram version see usbmsd_sd.cpp ram ok fs CANNOT be installed - too small use for illustrative purpose only
Dependencies: USBDevice USBMSD_SD mbed
Fork of USBMSD_SD_HelloWorld_Mbed by
main.cpp@14:757226626acb, 2011-12-06 (annotated)
- Committer:
- samux
- Date:
- Tue Dec 06 12:07:12 2011 +0000
- Revision:
- 14:757226626acb
- Parent:
- 13:32b8a767cf0e
- Child:
- 16:c753717bfd4d
protection enabled when usb cable plugged. filesystem has no access when plugged
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 |
13:32b8a767cf0e | 4 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
samux |
2:27a7e7f8d399 | 5 | |
samux |
12:a12eb1fc05f3 | 6 | DigitalIn button(p16); |
samux |
10:cf8fd2b6ca23 | 7 | |
samux |
2:27a7e7f8d399 | 8 | int main() { |
samux |
14:757226626acb | 9 | char dir[30]; |
samux |
14:757226626acb | 10 | char file[30]; |
samux |
14:757226626acb | 11 | int count =0; |
samux |
14:757226626acb | 12 | |
samux |
14:757226626acb | 13 | sd.connect(); |
samux |
14:757226626acb | 14 | |
samux |
14:757226626acb | 15 | while (1) { |
samux |
14:757226626acb | 16 | sprintf(dir, "/sd/dir%d", count++); |
samux |
14:757226626acb | 17 | mkdir(dir, 0777); |
samux |
11:a26e7b7a1221 | 18 | |
samux |
14:757226626acb | 19 | sprintf(file, "%s/test.txt", dir); |
samux |
14:757226626acb | 20 | FILE *fp = fopen(file, "w"); |
samux |
14:757226626acb | 21 | if (fp != NULL) { |
samux |
14:757226626acb | 22 | printf("will write !!\r\n"); |
samux |
14:757226626acb | 23 | fprintf(fp, "Hello fun SD Card World!"); |
samux |
14:757226626acb | 24 | fclose(fp); |
samux |
14:757226626acb | 25 | } else { |
samux |
14:757226626acb | 26 | printf("Could not open file for write\r\n"); |
samux |
12:a12eb1fc05f3 | 27 | } |
samux |
14:757226626acb | 28 | wait(3); |
samux |
10:cf8fd2b6ca23 | 29 | } |
samux |
9:9c343b9ee6d8 | 30 | } |