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