Dependents: UMTSStickNetIfExample PMK_UMTSStickNetIfExample
LPC1768/drv/usb/UsbEndpoint.h@3:62e3d7a3cc68, 2010-08-05 (annotated)
- Committer:
- donatien
- Date:
- Thu Aug 05 15:18:28 2010 +0000
- Revision:
- 3:62e3d7a3cc68
- Parent:
- 0:45cd39946923
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:45cd39946923 | 1 | |
donatien | 0:45cd39946923 | 2 | /* |
donatien | 0:45cd39946923 | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
donatien | 0:45cd39946923 | 4 | |
donatien | 0:45cd39946923 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
donatien | 0:45cd39946923 | 6 | of this software and associated documentation files (the "Software"), to deal |
donatien | 0:45cd39946923 | 7 | in the Software without restriction, including without limitation the rights |
donatien | 0:45cd39946923 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
donatien | 0:45cd39946923 | 9 | copies of the Software, and to permit persons to whom the Software is |
donatien | 0:45cd39946923 | 10 | furnished to do so, subject to the following conditions: |
donatien | 0:45cd39946923 | 11 | |
donatien | 0:45cd39946923 | 12 | The above copyright notice and this permission notice shall be included in |
donatien | 0:45cd39946923 | 13 | all copies or substantial portions of the Software. |
donatien | 0:45cd39946923 | 14 | |
donatien | 0:45cd39946923 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
donatien | 0:45cd39946923 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
donatien | 0:45cd39946923 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
donatien | 0:45cd39946923 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
donatien | 0:45cd39946923 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 0:45cd39946923 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
donatien | 0:45cd39946923 | 21 | THE SOFTWARE. |
donatien | 0:45cd39946923 | 22 | */ |
donatien | 0:45cd39946923 | 23 | |
donatien | 0:45cd39946923 | 24 | #ifndef USB_ENDPOINT_H |
donatien | 0:45cd39946923 | 25 | #define USB_ENDPOINT_H |
donatien | 0:45cd39946923 | 26 | |
donatien | 0:45cd39946923 | 27 | #include "mbed.h" |
donatien | 0:45cd39946923 | 28 | #include "UsbInc.h" |
donatien | 0:45cd39946923 | 29 | |
donatien | 0:45cd39946923 | 30 | class UsbDevice; |
donatien | 0:45cd39946923 | 31 | |
donatien | 0:45cd39946923 | 32 | enum UsbEndpointType |
donatien | 0:45cd39946923 | 33 | { |
donatien | 0:45cd39946923 | 34 | USB_CONTROL, |
donatien | 0:45cd39946923 | 35 | USB_BULK |
donatien | 0:45cd39946923 | 36 | // USB_INT, |
donatien | 0:45cd39946923 | 37 | // USB_ISO |
donatien | 0:45cd39946923 | 38 | }; |
donatien | 0:45cd39946923 | 39 | |
donatien | 0:45cd39946923 | 40 | class UsbEndpoint |
donatien | 0:45cd39946923 | 41 | { |
donatien | 0:45cd39946923 | 42 | public: |
donatien | 0:45cd39946923 | 43 | UsbEndpoint( UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr = -1 ); |
donatien | 0:45cd39946923 | 44 | ~UsbEndpoint(); |
donatien | 0:45cd39946923 | 45 | |
donatien | 0:45cd39946923 | 46 | void setNextToken(uint32_t token); //Only for control Eps |
donatien | 0:45cd39946923 | 47 | |
donatien | 0:45cd39946923 | 48 | UsbErr transfer(volatile uint8_t* buf, uint32_t len); |
donatien | 0:45cd39946923 | 49 | |
donatien | 0:45cd39946923 | 50 | int status(); //return UsbErr or transfered len |
donatien | 0:45cd39946923 | 51 | |
donatien | 0:45cd39946923 | 52 | void updateAddr(int addr); |
donatien | 0:45cd39946923 | 53 | void updateSize(uint16_t size); |
donatien | 0:45cd39946923 | 54 | |
donatien | 0:45cd39946923 | 55 | //void setOnCompletion( void(*pCb)completed() ); |
donatien | 0:45cd39946923 | 56 | class CDummy; |
donatien | 0:45cd39946923 | 57 | template <class T> |
donatien | 0:45cd39946923 | 58 | void setOnCompletion( T* pCbItem, void (T::*pCbMeth)() ) |
donatien | 0:45cd39946923 | 59 | { |
donatien | 0:45cd39946923 | 60 | m_pCbItem = (CDummy*) pCbItem; |
donatien | 0:45cd39946923 | 61 | m_pCbMeth = (void (CDummy::*)()) pCbMeth; |
donatien | 0:45cd39946923 | 62 | } |
donatien | 0:45cd39946923 | 63 | |
donatien | 0:45cd39946923 | 64 | //static void completed(){} |
donatien | 0:45cd39946923 | 65 | |
donatien | 0:45cd39946923 | 66 | protected: |
donatien | 0:45cd39946923 | 67 | void onCompletion(); |
donatien | 0:45cd39946923 | 68 | public: |
donatien | 0:45cd39946923 | 69 | static void sOnCompletion(uint32_t pTd); |
donatien | 0:45cd39946923 | 70 | |
donatien | 0:45cd39946923 | 71 | private: |
donatien | 0:45cd39946923 | 72 | friend class UsbDevice; |
donatien | 0:45cd39946923 | 73 | |
donatien | 0:45cd39946923 | 74 | UsbDevice* m_pDevice; |
donatien | 0:45cd39946923 | 75 | |
donatien | 0:45cd39946923 | 76 | bool m_dir; |
donatien | 0:45cd39946923 | 77 | bool m_setup; |
donatien | 0:45cd39946923 | 78 | UsbEndpointType m_type; |
donatien | 0:45cd39946923 | 79 | |
donatien | 0:45cd39946923 | 80 | //bool m_done; |
donatien | 0:45cd39946923 | 81 | volatile bool m_result; |
donatien | 0:45cd39946923 | 82 | volatile int m_status; |
donatien | 0:45cd39946923 | 83 | |
donatien | 0:45cd39946923 | 84 | volatile uint32_t m_len; |
donatien | 0:45cd39946923 | 85 | |
donatien | 0:45cd39946923 | 86 | volatile uint8_t* m_pBufStartPtr; |
donatien | 0:45cd39946923 | 87 | |
donatien | 0:45cd39946923 | 88 | volatile HCED* m_pEd; //Ep descriptor |
donatien | 0:45cd39946923 | 89 | volatile HCTD* m_pTdHead; //Head trf descriptor |
donatien | 0:45cd39946923 | 90 | volatile HCTD* m_pTdTail; //Tail trf descriptor |
donatien | 0:45cd39946923 | 91 | |
donatien | 0:45cd39946923 | 92 | //static volatile HCED* m_pNextEd; |
donatien | 0:45cd39946923 | 93 | |
donatien | 0:45cd39946923 | 94 | CDummy* m_pCbItem; |
donatien | 0:45cd39946923 | 95 | void (CDummy::*m_pCbMeth)(); |
donatien | 0:45cd39946923 | 96 | |
donatien | 0:45cd39946923 | 97 | |
donatien | 0:45cd39946923 | 98 | static UsbEndpoint* m_pHeadEp; |
donatien | 0:45cd39946923 | 99 | UsbEndpoint* m_pNextEp; |
donatien | 0:45cd39946923 | 100 | |
donatien | 0:45cd39946923 | 101 | }; |
donatien | 0:45cd39946923 | 102 | |
donatien | 0:45cd39946923 | 103 | #endif |