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.
Fork of USBFileSystem by
Revision 6:eeeea7fbb0a2, committed 2014-12-19
- Comitter:
- mkilivan
- Date:
- Fri Dec 19 14:41:08 2014 +0000
- Parent:
- 2:9af05743d551
- Commit message:
- Remove USB part
Changed in this revision
diff -r 9af05743d551 -r eeeea7fbb0a2 USBDevice.lib --- a/USBDevice.lib Wed Oct 23 20:32:07 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/mbed_official/code/USBDevice/#d495202c90f4
diff -r 9af05743d551 -r eeeea7fbb0a2 USBFileSystem.cpp --- a/USBFileSystem.cpp Wed Oct 23 20:32:07 2013 +0000 +++ b/USBFileSystem.cpp Fri Dec 19 14:41:08 2014 +0000 @@ -4,10 +4,7 @@ USBFileSystem::USBFileSystem(const char* n) : FATFileSystem_ds(n) { localFunction = NULL; - usbFunction = NULL; - usbfree = true; local_count = 0; - usbMode(1); } @@ -53,14 +50,10 @@ return (local_count == 0); } -bool USBFileSystem::usbSafe( void ){ - return usbfree; -} - int USBFileSystem::disk_status_fat() { int retval = _disk_status(); - if ((retval == 0) && (!usbSafe())) + if (retval == 0) return 4; else return retval; @@ -69,24 +62,14 @@ int USBFileSystem::disk_status_msd() { int retval = _disk_status(); - if ((retval == 0) && (!localSafe())) + if (retval == 0) return 4; else return retval; } int USBFileSystem::disk_write(const uint8_t * data, uint64_t block) { - if (localSafe()) { - if (usbfree && (usbFunction!=NULL) ) - usbFunction(false); - - usbfree = false; - } - - int retval= _disk_write(data, block); - - if (localSafe()) - usb_write.attach_us(this, &USBFileSystem::usbFree, USBWRITE_TIMEOUT * 1000); + int retval= _disk_write(data, block); return retval; } @@ -100,14 +83,10 @@ //Pseudo-IRQ if (open && (local_count == 1)) { - if (usbmode == 1) - disconnect(); if (localFunction != NULL) (*localFunction)(false); } if (!open && (local_count == 0)) { - if (usbmode == 1) - connect(); if (localFunction != NULL) (*localFunction)(true); } @@ -116,17 +95,3 @@ void USBFileSystem::attachLocal(void (*function)(bool)) { localFunction = function; } - -void USBFileSystem::attachUSB(void (*function)(bool)) { - usbFunction = function; -} - -void USBFileSystem::usbFree( void ) { - usbfree = true; - if (usbFunction != NULL) - usbFunction(true); -} - -void USBFileSystem::usbMode(int mode) { - usbmode = mode; -} \ No newline at end of file
diff -r 9af05743d551 -r eeeea7fbb0a2 USBFileSystem.h --- a/USBFileSystem.h Wed Oct 23 20:32:07 2013 +0000 +++ b/USBFileSystem.h Fri Dec 19 14:41:08 2014 +0000 @@ -2,7 +2,6 @@ #define USBFILESYSTEM_H #include "FATFileSystem.h" -#include "USBMSD.h" #include "FATFileHandle.h" class FATFileSystem_ds : public FATFileSystem { @@ -14,15 +13,6 @@ virtual int disk_status( void ) {return disk_status_fat();} }; -class USBMSD_ds : public USBMSD { - public: - USBMSD_ds() {}; - - protected: - virtual int disk_status_msd( void ) = 0; - virtual int disk_status( void ) {return disk_status_msd();} -}; - /** Class which combines FATFileSystem with USBMSD device * * The functions to be implemented by the child class are the same as @@ -53,7 +43,7 @@ * * See the program's wiki for more documentation! */ -class USBFileSystem : public FATFileSystem_ds, public USBMSD_ds { +class USBFileSystem : public FATFileSystem_ds { public: /** * Constructor for USBFileSystem @@ -70,35 +60,12 @@ */ void attachLocal(void (*function)(bool)); - /** Attach a function to be called when USB occupies/frees the filesystem - * - * The function is called with 'true' as argument when it is freed, false when it is occupied - * - * @param function - Function to be called, must have void as return type, and a single boolean argument - */ - void attachUSB(void (*function)(bool)); - /** Check if locally files are opened for write * * @return - true if none are opened for write, false otherwise */ bool localSafe( void ); - /** Check if via USB files files are being written - * - * @return - true if none are being written, false otherwise - */ - bool usbSafe( void ); - - /** Sets the USB mode - * - * Argument = 0: USB is write protected when not available. - * Argument = 1: USB is disconnected when not available (default). - * - * @param mode - USB safety mode - */ - void usbMode( int mode ); - protected: //Functions to be implemented by child: @@ -113,7 +80,6 @@ //Not to be implemented by child: virtual FileHandle* open(const char* name, int flags); void localOpen( bool open ); - void usbFree( void ); private: virtual int disk_status_fat(void); @@ -121,13 +87,9 @@ virtual int disk_write(const uint8_t * buffer, uint64_t sector); int local_count; - int usbmode; - Timeout usb_write; - bool usbfree; void (*localFunction)(bool); - void (*usbFunction)(bool); - + void (*usbFunction)(bool); friend class USBFileHandle; };