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