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
USBMSD2/DiskInterface.h
- Committer:
- va009039
- Date:
- 2014-06-21
- Revision:
- 6:528036abfb02
- Parent:
- 0:39eb4d5b97df
File content as of revision 6:528036abfb02:
// DiskInterface.h 2013/9/21 #pragma once class DiskInterface { public: /* * read a block on a storage chip * * @param data pointer where will be stored read data * @param block block number * @returns 0 if successful */ virtual int disk_read(uint8_t * data, uint64_t block) = 0; /* * write a block on a storage chip * * @param data data to write * @param block block number * @returns 0 if successful */ virtual int disk_write(const uint8_t * data, uint64_t block) = 0; /* * Disk initilization */ virtual int disk_initialize() = 0; /* * Return the number of blocks * * @returns number of blocks */ virtual uint64_t disk_sectors() = 0; /* * Return memory size * * @returns memory size */ virtual uint64_t disk_size() = 0; /* * To check the status of the storage chip * * @returns status: 0: OK, 1: disk not initialized, 2: no medium in the drive, 4: write protected */ virtual int disk_status() = 0; };