This program is an example of of using the MSCUSBHost code with a raw build of ELM Chan Fat Fs. This was done to add both Long File Name Support along with proper time/date stamps (assuming you have a battery hooked up to keep time). This code exposes the Chan API (see main.cpp) and is NOT a c++ class: http://elm-chan.org/fsw/ff/00index_e.html The diskio.c file has the mapping needed to link the filesystem to the MSC stuff
Diff: main.cpp
- Revision:
- 0:2dbbafe1b1fb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jan 23 18:35:43 2011 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "ff.h"
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+
+FATFS MyFileSystem;
+FIL MyFile;
+
+int main()
+{
+ unsigned int BytesWritten;
+
+ //mount the SD card (any drive number will map to the SD card)
+ f_mount(0,&MyFileSystem);
+ //Open the file for open and write
+ f_open(&MyFile,"Test1.2.3.4.txt",FA_WRITE|FA_OPEN_ALWAYS);
+ //Write some junk
+ f_write(&MyFile,"Testing!\r\nTesting,1,2,3\r\n",27,&BytesWritten);
+ //Close the file
+ f_close(&MyFile);
+
+ while(1)
+ {
+ pc.printf("all done!!\r\n");
+ wait(1);
+ myled = !myled;
+ }
+}
Eli Hughes