Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: KL46Z-lpc81isp lpcterm2
USBLocalFileSystem.cpp
00001 #include "USBLocalFileSystem.h" 00002 #include "RamDisk.h" 00003 #include "SDStorage.h" 00004 #include "USB_CDC.h" 00005 00006 USBLocalFileSystem::USBLocalFileSystem(const char* name) 00007 { 00008 RamDisk* storage = new RamDisk; 00009 init(storage, name); 00010 } 00011 00012 USBLocalFileSystem::USBLocalFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) 00013 { 00014 SDStorage* storage = new SDStorage(mosi, miso, sclk, cs); 00015 storage->storage_initialize(); 00016 init(storage, name); 00017 } 00018 00019 USBLocalFileSystem::USBLocalFileSystem(StorageInterface* storage, const char* name) 00020 { 00021 init(storage, name); 00022 } 00023 00024 void USBLocalFileSystem::init(StorageInterface* storage, const char* name) 00025 { 00026 _name = name; 00027 _storage = storage; 00028 _usb = new USBStorage2(_storage); 00029 _local = new LocalStorage(_storage); 00030 } 00031 00032 void USBLocalFileSystem::remount() 00033 { 00034 if (_local) { 00035 delete _local; 00036 } 00037 _local = new LocalStorage(_storage); 00038 } 00039 00040 int USBLocalFileSystem::lock(bool f) 00041 { 00042 return _usb->block(f); 00043 } 00044 00045 bool USBLocalFileSystem::find(char* name, size_t size, const char* pat) 00046 { 00047 return LocalStorage::find(name, size, _name, pat); 00048 } 00049 00050 int USBLocalFileSystem::readable() 00051 { 00052 return _usb->readable(); 00053 } 00054 00055 int USBLocalFileSystem::writeable() 00056 { 00057 return _usb->writeable(); 00058 } 00059 00060 int USBLocalFileSystem::getc() 00061 { 00062 return _usb->getc(); 00063 } 00064 00065 int USBLocalFileSystem::putc(int c) 00066 { 00067 _usb->putc(c); 00068 return c; 00069 } 00070 00071 int USBLocalFileSystem::puts(const char* str) 00072 { 00073 while(*str) { 00074 putc(*str++); 00075 } 00076 return 0; 00077 } 00078 00079 void USBLocalFileSystem::attachSendBreak(void (*fptr)(uint16_t duration)) 00080 { 00081 getUsb()->getCDC()->attachSendBreak(fptr); 00082 } 00083 00084 void USBLocalFileSystem::attachControlLineState(void (*fptr)(int dts, int dtr)) 00085 { 00086 getUsb()->getCDC()->attachControlLineStateChanged(fptr); 00087 } 00088 00089 void USBLocalFileSystem::attachSettingChanged(void (*fptr)(int baud, int bits, int parity, int stop)) 00090 { 00091 getUsb()->getCDC()->attach(fptr); 00092 } 00093
Generated on Tue Jul 12 2022 19:39:32 by
