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
main.cpp
- Committer:
- emh203
- Date:
- 2011-01-23
- Revision:
- 0:2dbbafe1b1fb
File content as of revision 0:2dbbafe1b1fb:
#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; } }