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