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