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

Dependencies:   mbed

Committer:
emh203
Date:
Sun Jan 23 18:35:43 2011 +0000
Revision:
0:2dbbafe1b1fb
1st test version.   Test with raw mbed and Samtec USB-RA type A connector wired directly to pins.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emh203 0:2dbbafe1b1fb 1 #include "mbed.h"
emh203 0:2dbbafe1b1fb 2 #include "ff.h"
emh203 0:2dbbafe1b1fb 3
emh203 0:2dbbafe1b1fb 4 DigitalOut myled(LED1);
emh203 0:2dbbafe1b1fb 5 Serial pc(USBTX, USBRX);
emh203 0:2dbbafe1b1fb 6
emh203 0:2dbbafe1b1fb 7 FATFS MyFileSystem;
emh203 0:2dbbafe1b1fb 8 FIL MyFile;
emh203 0:2dbbafe1b1fb 9
emh203 0:2dbbafe1b1fb 10 int main()
emh203 0:2dbbafe1b1fb 11 {
emh203 0:2dbbafe1b1fb 12 unsigned int BytesWritten;
emh203 0:2dbbafe1b1fb 13
emh203 0:2dbbafe1b1fb 14 //mount the SD card (any drive number will map to the SD card)
emh203 0:2dbbafe1b1fb 15 f_mount(0,&MyFileSystem);
emh203 0:2dbbafe1b1fb 16 //Open the file for open and write
emh203 0:2dbbafe1b1fb 17 f_open(&MyFile,"Test1.2.3.4.txt",FA_WRITE|FA_OPEN_ALWAYS);
emh203 0:2dbbafe1b1fb 18 //Write some junk
emh203 0:2dbbafe1b1fb 19 f_write(&MyFile,"Testing!\r\nTesting,1,2,3\r\n",27,&BytesWritten);
emh203 0:2dbbafe1b1fb 20 //Close the file
emh203 0:2dbbafe1b1fb 21 f_close(&MyFile);
emh203 0:2dbbafe1b1fb 22
emh203 0:2dbbafe1b1fb 23 while(1)
emh203 0:2dbbafe1b1fb 24 {
emh203 0:2dbbafe1b1fb 25 pc.printf("all done!!\r\n");
emh203 0:2dbbafe1b1fb 26 wait(1);
emh203 0:2dbbafe1b1fb 27 myled = !myled;
emh203 0:2dbbafe1b1fb 28 }
emh203 0:2dbbafe1b1fb 29 }