A library to allow SD Cards to be accessed as a filesystem, using a SPI interface
Dependencies: SDFileSystem mbed
main.cpp@0:a76f1c9096cb, 2014-03-10 (annotated)
- Committer:
- xxwiz
- Date:
- Mon Mar 10 03:43:38 2014 +0000
- Revision:
- 0:a76f1c9096cb
Nucleo SD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xxwiz | 0:a76f1c9096cb | 1 | #include "mbed.h" |
xxwiz | 0:a76f1c9096cb | 2 | #include "SDFileSystem.h" |
xxwiz | 0:a76f1c9096cb | 3 | //Nucleo F030R8 test |
xxwiz | 0:a76f1c9096cb | 4 | //DigitalOut myled(LED1); |
xxwiz | 0:a76f1c9096cb | 5 | // MOSI, MISO, SCLK, CS, name |
xxwiz | 0:a76f1c9096cb | 6 | SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd"); |
xxwiz | 0:a76f1c9096cb | 7 | |
xxwiz | 0:a76f1c9096cb | 8 | int main() { |
xxwiz | 0:a76f1c9096cb | 9 | printf("\nWait for new connection...\n"); |
xxwiz | 0:a76f1c9096cb | 10 | |
xxwiz | 0:a76f1c9096cb | 11 | mkdir("/sd/mydir", 0777); |
xxwiz | 0:a76f1c9096cb | 12 | |
xxwiz | 0:a76f1c9096cb | 13 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); |
xxwiz | 0:a76f1c9096cb | 14 | if(fp == NULL) { |
xxwiz | 0:a76f1c9096cb | 15 | printf("Could not open file for write\n"); |
xxwiz | 0:a76f1c9096cb | 16 | } |
xxwiz | 0:a76f1c9096cb | 17 | fprintf(fp, "Hello fun SD Card World!"); |
xxwiz | 0:a76f1c9096cb | 18 | fclose(fp); |
xxwiz | 0:a76f1c9096cb | 19 | |
xxwiz | 0:a76f1c9096cb | 20 | while(1) { |
xxwiz | 0:a76f1c9096cb | 21 | /* |
xxwiz | 0:a76f1c9096cb | 22 | myled = 1; |
xxwiz | 0:a76f1c9096cb | 23 | wait(1.2); |
xxwiz | 0:a76f1c9096cb | 24 | myled = 0; |
xxwiz | 0:a76f1c9096cb | 25 | wait(1.2);*/ |
xxwiz | 0:a76f1c9096cb | 26 | } |
xxwiz | 0:a76f1c9096cb | 27 | } |