This library is stripped down version of NetServices library. HTTP server and client function is NOT supported.
drv/usb/UsbHostMgr.h@0:dcf3c92487ca, 2011-07-20 (annotated)
- Committer:
- idinor
- Date:
- Wed Jul 20 11:45:39 2011 +0000
- Revision:
- 0:dcf3c92487ca
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
idinor | 0:dcf3c92487ca | 1 | /* |
idinor | 0:dcf3c92487ca | 2 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
idinor | 0:dcf3c92487ca | 3 | |
idinor | 0:dcf3c92487ca | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
idinor | 0:dcf3c92487ca | 5 | of this software and associated documentation files (the "Software"), to deal |
idinor | 0:dcf3c92487ca | 6 | in the Software without restriction, including without limitation the rights |
idinor | 0:dcf3c92487ca | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
idinor | 0:dcf3c92487ca | 8 | copies of the Software, and to permit persons to whom the Software is |
idinor | 0:dcf3c92487ca | 9 | furnished to do so, subject to the following conditions: |
idinor | 0:dcf3c92487ca | 10 | |
idinor | 0:dcf3c92487ca | 11 | The above copyright notice and this permission notice shall be included in |
idinor | 0:dcf3c92487ca | 12 | all copies or substantial portions of the Software. |
idinor | 0:dcf3c92487ca | 13 | |
idinor | 0:dcf3c92487ca | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
idinor | 0:dcf3c92487ca | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
idinor | 0:dcf3c92487ca | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
idinor | 0:dcf3c92487ca | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
idinor | 0:dcf3c92487ca | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
idinor | 0:dcf3c92487ca | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
idinor | 0:dcf3c92487ca | 20 | THE SOFTWARE. |
idinor | 0:dcf3c92487ca | 21 | */ |
idinor | 0:dcf3c92487ca | 22 | |
idinor | 0:dcf3c92487ca | 23 | //Assigns addresses to connected devices... |
idinor | 0:dcf3c92487ca | 24 | |
idinor | 0:dcf3c92487ca | 25 | #ifndef USB_HOSTMGR_H |
idinor | 0:dcf3c92487ca | 26 | #define USB_HOSTMGR_H |
idinor | 0:dcf3c92487ca | 27 | |
idinor | 0:dcf3c92487ca | 28 | #include "mbed.h" |
idinor | 0:dcf3c92487ca | 29 | #include "UsbInc.h" |
idinor | 0:dcf3c92487ca | 30 | #include "UsbDevice.h" |
idinor | 0:dcf3c92487ca | 31 | |
idinor | 0:dcf3c92487ca | 32 | #define USB_HOSTMGR_MAX_DEVS 2 //2 devices max for now... will be more when hubs are supported |
idinor | 0:dcf3c92487ca | 33 | |
idinor | 0:dcf3c92487ca | 34 | class UsbDevice; |
idinor | 0:dcf3c92487ca | 35 | |
idinor | 0:dcf3c92487ca | 36 | class UsbHostMgr //[0-1] inst |
idinor | 0:dcf3c92487ca | 37 | { |
idinor | 0:dcf3c92487ca | 38 | public: |
idinor | 0:dcf3c92487ca | 39 | UsbHostMgr(); |
idinor | 0:dcf3c92487ca | 40 | ~UsbHostMgr(); |
idinor | 0:dcf3c92487ca | 41 | |
idinor | 0:dcf3c92487ca | 42 | UsbErr init(); //Initialize host |
idinor | 0:dcf3c92487ca | 43 | |
idinor | 0:dcf3c92487ca | 44 | void poll(); //Enumerate connected devices, etc |
idinor | 0:dcf3c92487ca | 45 | |
idinor | 0:dcf3c92487ca | 46 | int devicesCount(); |
idinor | 0:dcf3c92487ca | 47 | |
idinor | 0:dcf3c92487ca | 48 | UsbDevice* getDevice(int item); |
idinor | 0:dcf3c92487ca | 49 | void releaseDevice(UsbDevice* pDev); |
idinor | 0:dcf3c92487ca | 50 | |
idinor | 0:dcf3c92487ca | 51 | |
idinor | 0:dcf3c92487ca | 52 | void UsbIrqhandler(); |
idinor | 0:dcf3c92487ca | 53 | |
idinor | 0:dcf3c92487ca | 54 | protected: |
idinor | 0:dcf3c92487ca | 55 | void onUsbDeviceConnected(int hub, int port); |
idinor | 0:dcf3c92487ca | 56 | void onUsbDeviceDisconnected(int hub, int port); |
idinor | 0:dcf3c92487ca | 57 | |
idinor | 0:dcf3c92487ca | 58 | friend class UsbDevice; |
idinor | 0:dcf3c92487ca | 59 | void resetPort(int hub, int port); |
idinor | 0:dcf3c92487ca | 60 | |
idinor | 0:dcf3c92487ca | 61 | private: |
idinor | 0:dcf3c92487ca | 62 | /* __align(8)*/ volatile HCCA* m_pHcca; |
idinor | 0:dcf3c92487ca | 63 | |
idinor | 0:dcf3c92487ca | 64 | UsbDevice* m_lpDevices[USB_HOSTMGR_MAX_DEVS]; |
idinor | 0:dcf3c92487ca | 65 | }; |
idinor | 0:dcf3c92487ca | 66 | |
idinor | 0:dcf3c92487ca | 67 | #endif |