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