Test SD
Dependencies: FatFileSystem SDFileSystem mbed
Diff: main.cpp
- Revision:
- 0:f46b40e04fdd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 25 08:37:27 2012 +0000 @@ -0,0 +1,39 @@ +// example writing to SD card, sford + +#include "mbed.h" +#include "SDFileSystem.h" +#include "TextLCD.h" + +TextLCD lcd(p24, p25, p26, p27, p28, p29, p30);//NGX mX-Base-Board Ver1.2 Type +//(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, PinName d2, PinName d3, int columns, int rows) + +DigitalOut led(LED1); + +SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board + // mosi, miso, sclk, cs + +int main() { + + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Hello SD!\n"); + + mkdir("/sd/Tomodir", 0777); + + FILE *fp = fopen("/sd/Tomodir/Tomo.txt", "w"); + if(fp == NULL) { + error("Could not open file for write\n"); + } + fprintf(fp, "heehaw!"); + fclose(fp); + + lcd.locate(0,1); + lcd.printf("Goodbye SD!\n"); + + while(1) { + led = 1; + wait(0.2); + led = 0; + wait(0.2); + } +}