USBMSD SD card Hello World for Mbed platforms

Dependencies:   mbed USBMSD_SD USBDevice

Committer:
samux
Date:
Mon Dec 05 14:34:29 2011 +0000
Revision:
13:32b8a767cf0e
Parent:
12:a12eb1fc05f3
Child:
14:757226626acb
big cleaning up. all is working!!!

Who changed what in which revision?

UserRevisionLine numberNew 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 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 }