Emulation of LocalFileSystem with virtual COM.
Dependents: KL46Z-lpc81isp lpcterm2
#include "USBLocalFileSystem.h" int main() { USBLocalFileSystem* usb_local = new USBLocalFileSystem(); // RamDisk(64KB) while(1) { usb_local->lock(true); usb_local->remount(); char filename[32]; if (usb_local->find(filename, sizeof(filename), "*.TXT")) { FILE* fp = fopen(filename, "r"); if (fp) { int c; while((c = fgetc(fp)) != EOF) { usb_local->putc(c); } fclose(fp); } } usb_local->lock(false); wait_ms(1000*5); } }
Sample application:
Import programKL46Z-lpc81isp
ISP example program.
Import programlpcterm2
semihost server example program
Diff: src/RamDisk.h
- Revision:
- 0:39eb4d5b97df
diff -r 000000000000 -r 39eb4d5b97df src/RamDisk.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/RamDisk.h Sat May 03 11:21:37 2014 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" +#include "StorageInterface.h" +#include "mymap.h" + +class RamDisk : public StorageInterface { +public: + RamDisk(int sectors = 128); // 128*512 64Kbytes + virtual int storage_read(uint8_t* data, uint32_t block); + virtual int storage_write(const uint8_t* data, uint32_t block); + virtual uint32_t storage_sectors(); + virtual uint32_t storage_size(); + + void dump(int mode); + +private: + void format(); + int _sectors; + mymap<int,uint8_t*>_sector_image; +};