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/UsbDevice.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 | /* |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 4 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 6 | of this software and associated documentation files (the "Software"), to deal |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 7 | in the Software without restriction, including without limitation the rights |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 9 | copies of the Software, and to permit persons to whom the Software is |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 10 | furnished to do so, subject to the following conditions: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 11 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 12 | The above copyright notice and this permission notice shall be included in |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 13 | all copies or substantial portions of the Software. |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 14 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 21 | THE SOFTWARE. |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 22 | */ |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 23 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 24 | #ifndef USB_DEVICE_H |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 25 | #define USB_DEVICE_H |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 26 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 27 | #include "mbed.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 28 | #include "UsbInc.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 29 | #include "UsbEndpoint.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 30 | #include "UsbHostMgr.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 31 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 32 | class UsbHostMgr; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 33 | class UsbEndpoint; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 34 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 35 | class UsbDevice |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 36 | { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 37 | protected: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 38 | UsbDevice( UsbHostMgr* pMgr, int hub, int port, int addr ); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 39 | ~UsbDevice(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 40 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 41 | UsbErr enumerate(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 42 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 43 | public: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 44 | bool connected(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 45 | bool enumerated(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 46 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 47 | int getPid(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 48 | int getVid(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 49 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 50 | //UsbErr getConfigurationDescriptor(int config, uint8_t** pBuf); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 51 | //UsbErr getInterfaceDescriptor(int config, int item, uint8_t** pBuf); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 52 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 53 | UsbErr setConfiguration(int config); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 54 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 55 | UsbErr controlSend(byte requestType, byte request, word value, word index, const byte* buf, int len); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 56 | UsbErr controlReceive(byte requestType, byte request, word value, word index, const byte* buf, int len); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 57 | UsbErr GetDescriptor(int type, int index, const byte* buf, int len); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 58 | UsbErr GetString(int index, char* buf, int len); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 59 | UsbErr SetInterfaceAlternate(int interface, int alternate); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 60 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 61 | uint8_t m_DeviceClass; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 62 | uint8_t m_InterfaceClass; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 63 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 64 | protected: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 65 | void fillControlBuf(byte requestType, byte request, word value, word index, int len); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 66 | private: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 67 | friend class UsbEndpoint; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 68 | friend class UsbHostMgr; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 69 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 70 | UsbEndpoint* m_pControlEp; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 71 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 72 | UsbHostMgr* m_pMgr; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 73 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 74 | bool m_connected; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 75 | bool m_enumerated; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 76 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 77 | int m_hub; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 78 | int m_port; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 79 | int m_addr; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 80 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 81 | int m_refs; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 82 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 83 | uint16_t m_vid; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 84 | uint16_t m_pid; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 85 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 86 | byte m_controlBuf[8];//8 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 87 | //byte m_controlDataBuf[/*128*/256]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 88 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 89 | UsbErr hub_init(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 90 | UsbErr hub_poll(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 91 | UsbErr hub_PortReset(int port); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 92 | UsbErr SetPortFeature(int feature, int index); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 93 | UsbErr ClearPortFeature(int feature, int index); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 94 | UsbErr SetPortReset(int port); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 95 | UsbErr GetPortStatus(int port, uint8_t* buf, int size); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 96 | int m_hub_ports; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 97 | }; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 98 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 99 | #endif |