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