Seeed Xadow M0 working with SD card add-on
Dependencies: SDFileSystem SSD1308_128x64_I2C USBDevice mbed
Fork of SDFileSystem_HelloWorld by
Revision 1:4ac234866e4c, committed 2014-11-21
- Comitter:
- whatnick
- Date:
- Fri Nov 21 13:15:45 2014 +0000
- Parent:
- 0:bdbd3d6fc5d5
- Commit message:
- SD card tested working
Changed in this revision
diff -r bdbd3d6fc5d5 -r 4ac234866e4c SDFileSystem.lib --- a/SDFileSystem.lib Fri Dec 07 11:25:01 2012 +0000 +++ b/SDFileSystem.lib Fri Nov 21 13:15:45 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4 +http://mbed.org/users/neilt6/code/SDFileSystem/#c9e938f6934f
diff -r bdbd3d6fc5d5 -r 4ac234866e4c SSD1308_128x64_I2C.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SSD1308_128x64_I2C.lib Fri Nov 21 13:15:45 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/wim/code/SSD1308_128x64_I2C/#fa18169dd7e6
diff -r bdbd3d6fc5d5 -r 4ac234866e4c USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Fri Nov 21 13:15:45 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yihui/code/USBDevice/#74ca09725b68
diff -r bdbd3d6fc5d5 -r 4ac234866e4c main.cpp --- a/main.cpp Fri Dec 07 11:25:01 2012 +0000 +++ b/main.cpp Fri Nov 21 13:15:45 2014 +0000 @@ -1,19 +1,43 @@ #include "mbed.h" #include "SDFileSystem.h" - -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board +#include "pinmap.h" +#include "SSD1308.h" + +#define DEBUG +#define HARD_SPI 1 +#define I2C_FREQ 100000 + +I2C i2c(I2C_SDA, I2C_SCL); +//Use Xadow OLED for display +SSD1308 oled = SSD1308(i2c, SSD1308_SA0); + +#ifdef DEBUG +#include "USBSerial.h" // To use USB virtual serial, a driver is needed, check http://mbed.org/handbook/USBSerial +#define LOG(args...) pc.printf(args) +USBSerial pc; +#else +#define LOG(args...) +#endif + +SDFileSystem sd(P0_21, P0_22, P1_15, P1_19, "sd", P0_20, SDFileSystem::SWITCH_POS_NC); // the pinout on the mbed Cool Components workshop board int main() { - printf("Hello World!\n"); - + LOG("Hello World!\n"); + oled.clearDisplay(); + oled.writeString(0,0,"Hello World!"); mkdir("/sd/mydir", 0777); - FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); - if(fp == NULL) { - error("Could not open file for write\n"); - } - fprintf(fp, "Hello fun SD Card World!"); - fclose(fp); - - printf("Goodbye World!\n"); + while(1) + { + FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); + if(fp == NULL) { + LOG("Could not open file for write\n"); + oled.writeString(2,0,"Failed on SD"); + } + fprintf(fp, "Hello fun Xadow SD Card World!"); + fclose(fp); + LOG("Goodbye World!\n"); + oled.writeString(1,0,"Goodbye World!"); + } + }
diff -r bdbd3d6fc5d5 -r 4ac234866e4c mbed.bld --- a/mbed.bld Fri Dec 07 11:25:01 2012 +0000 +++ b/mbed.bld Fri Nov 21 13:15:45 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/63cdd78b2dc1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file