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
src/SDStorage.h@0:39eb4d5b97df, 2014-05-03 (annotated)
- Committer:
- va009039
- Date:
- Sat May 03 11:21:37 2014 +0000
- Revision:
- 0:39eb4d5b97df
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:39eb4d5b97df | 1 | #include "mbed.h" |
va009039 | 0:39eb4d5b97df | 2 | #include "StorageInterface.h" |
va009039 | 0:39eb4d5b97df | 3 | #include "SWSPI.h" |
va009039 | 0:39eb4d5b97df | 4 | |
va009039 | 0:39eb4d5b97df | 5 | class SDStorage : public StorageInterface { |
va009039 | 0:39eb4d5b97df | 6 | public: |
va009039 | 0:39eb4d5b97df | 7 | SDStorage(PinName mosi, PinName miso, PinName sclk, PinName cs); |
va009039 | 0:39eb4d5b97df | 8 | |
va009039 | 0:39eb4d5b97df | 9 | virtual int storage_read(uint8_t* data, uint32_t block); |
va009039 | 0:39eb4d5b97df | 10 | virtual int storage_write(const uint8_t* data, uint32_t block); |
va009039 | 0:39eb4d5b97df | 11 | virtual uint32_t storage_sectors(); |
va009039 | 0:39eb4d5b97df | 12 | virtual uint32_t storage_size(); |
va009039 | 0:39eb4d5b97df | 13 | |
va009039 | 0:39eb4d5b97df | 14 | int storage_initialize(); |
va009039 | 0:39eb4d5b97df | 15 | |
va009039 | 0:39eb4d5b97df | 16 | protected: |
va009039 | 0:39eb4d5b97df | 17 | int _cmd(int cmd, int arg); |
va009039 | 0:39eb4d5b97df | 18 | int _cmdx(int cmd, int arg); |
va009039 | 0:39eb4d5b97df | 19 | int _cmd8(); |
va009039 | 0:39eb4d5b97df | 20 | int _cmd58(); |
va009039 | 0:39eb4d5b97df | 21 | int initialise_card(); |
va009039 | 0:39eb4d5b97df | 22 | int initialise_card_v1(); |
va009039 | 0:39eb4d5b97df | 23 | int initialise_card_v2(); |
va009039 | 0:39eb4d5b97df | 24 | |
va009039 | 0:39eb4d5b97df | 25 | int _read(uint8_t * buffer, uint32_t length); |
va009039 | 0:39eb4d5b97df | 26 | int _write(const uint8_t *buffer, uint32_t length); |
va009039 | 0:39eb4d5b97df | 27 | uint64_t _sd_sectors(); |
va009039 | 0:39eb4d5b97df | 28 | uint64_t _sectors; |
va009039 | 0:39eb4d5b97df | 29 | SWSPI _spi; |
va009039 | 0:39eb4d5b97df | 30 | DigitalOut _cs; |
va009039 | 0:39eb4d5b97df | 31 | int cdv; |
va009039 | 0:39eb4d5b97df | 32 | }; |