Test SD
Dependencies: FatFileSystem SDFileSystem mbed
main.cpp
- Committer:
- Tomoseec
- Date:
- 2012-12-25
- Revision:
- 0:f46b40e04fdd
File content as of revision 0:f46b40e04fdd:
// 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); } }