![](/media/cache/profiles/c51ce410c124a10e0db5e4b97fc2af39.50x50_q85.jpg)
An example using the SDFileSystem library to create a directory and write a fiel to an SD card, using its SPI interface
Dependencies: mbed SDFileSystem
main.cpp@0:aee5cf626b88, 2010-06-03 (annotated)
- Committer:
- simon
- Date:
- Thu Jun 03 16:35:25 2010 +0000
- Revision:
- 0:aee5cf626b88
- Child:
- 1:27aaaa9f462b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:aee5cf626b88 | 1 | #include "mbed.h" |
simon | 0:aee5cf626b88 | 2 | #include "SDFileSystem.h" |
simon | 0:aee5cf626b88 | 3 | |
simon | 0:aee5cf626b88 | 4 | SDFileSystem sd(p11, p12, p13, p27, "sd"); |
simon | 0:aee5cf626b88 | 5 | |
simon | 0:aee5cf626b88 | 6 | int main() { |
simon | 0:aee5cf626b88 | 7 | printf("Hello World!\n"); |
simon | 0:aee5cf626b88 | 8 | |
simon | 0:aee5cf626b88 | 9 | FILE *fp = fopen("/sd/sdtest.txt", "w"); |
simon | 0:aee5cf626b88 | 10 | if(fp == NULL) { |
simon | 0:aee5cf626b88 | 11 | error("Could not open file for write\n"); |
simon | 0:aee5cf626b88 | 12 | } |
simon | 0:aee5cf626b88 | 13 | fprintf(fp, "Hello fun SD Card World!"); |
simon | 0:aee5cf626b88 | 14 | fclose(fp); |
simon | 0:aee5cf626b88 | 15 | |
simon | 0:aee5cf626b88 | 16 | printf("Goodbye World!\n"); |
simon | 0:aee5cf626b88 | 17 | } |