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.
Fork of uvchost by
usb/UsbEndpoint.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_ENDPOINT_H |
va009039 | 0:b0f04c137829 | 25 | #define USB_ENDPOINT_H |
va009039 | 0:b0f04c137829 | 26 | |
va009039 | 0:b0f04c137829 | 27 | #include "mbed.h" |
va009039 | 0:b0f04c137829 | 28 | #include "UsbInc.h" |
va009039 | 0:b0f04c137829 | 29 | #include "Usb_td.h" |
va009039 | 0:b0f04c137829 | 30 | |
va009039 | 0:b0f04c137829 | 31 | class UsbDevice; |
va009039 | 0:b0f04c137829 | 32 | |
va009039 | 0:b0f04c137829 | 33 | enum UsbEndpointType |
va009039 | 0:b0f04c137829 | 34 | { |
va009039 | 0:b0f04c137829 | 35 | USB_CONTROL, |
va009039 | 0:b0f04c137829 | 36 | USB_BULK, |
va009039 | 0:b0f04c137829 | 37 | USB_INT, |
va009039 | 0:b0f04c137829 | 38 | USB_ISO |
va009039 | 0:b0f04c137829 | 39 | }; |
va009039 | 0:b0f04c137829 | 40 | |
va009039 | 0:b0f04c137829 | 41 | class UsbEndpoint |
va009039 | 0:b0f04c137829 | 42 | { |
va009039 | 0:b0f04c137829 | 43 | public: |
va009039 | 0:b0f04c137829 | 44 | UsbEndpoint( UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr = -1 ); |
va009039 | 0:b0f04c137829 | 45 | ~UsbEndpoint(); |
va009039 | 0:b0f04c137829 | 46 | void UsbEndpoint_iso(UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr); |
va009039 | 0:b0f04c137829 | 47 | |
va009039 | 0:b0f04c137829 | 48 | void setNextToken(uint32_t token); //Only for control Eps |
va009039 | 0:b0f04c137829 | 49 | |
va009039 | 0:b0f04c137829 | 50 | UsbErr transfer(volatile uint8_t* buf, uint32_t len); |
va009039 | 0:b0f04c137829 | 51 | UsbErr transfer(uint16_t frame, int count, volatile uint8_t* buf, int len); // for isochronous |
va009039 | 0:b0f04c137829 | 52 | int m_itdActive; |
va009039 | 0:b0f04c137829 | 53 | tdqueue <HCITD*> queue_done_itd; |
va009039 | 0:b0f04c137829 | 54 | int status(); //return UsbErr or transfered len |
va009039 | 0:b0f04c137829 | 55 | |
va009039 | 0:b0f04c137829 | 56 | void updateAddr(int addr); |
va009039 | 0:b0f04c137829 | 57 | void updateSize(uint16_t size); |
va009039 | 0:b0f04c137829 | 58 | |
va009039 | 0:b0f04c137829 | 59 | //void setOnCompletion( void(*pCb)completed() ); |
va009039 | 0:b0f04c137829 | 60 | class CDummy; |
va009039 | 0:b0f04c137829 | 61 | template <class T> |
va009039 | 0:b0f04c137829 | 62 | void setOnCompletion( T* pCbItem, void (T::*pCbMeth)() ) |
va009039 | 0:b0f04c137829 | 63 | { |
va009039 | 0:b0f04c137829 | 64 | m_pCbItem = (CDummy*) pCbItem; |
va009039 | 0:b0f04c137829 | 65 | m_pCbMeth = (void (CDummy::*)()) pCbMeth; |
va009039 | 0:b0f04c137829 | 66 | } |
va009039 | 0:b0f04c137829 | 67 | |
va009039 | 0:b0f04c137829 | 68 | //static void completed(){} |
va009039 | 0:b0f04c137829 | 69 | |
va009039 | 0:b0f04c137829 | 70 | protected: |
va009039 | 0:b0f04c137829 | 71 | void onCompletion(); |
va009039 | 0:b0f04c137829 | 72 | public: |
va009039 | 0:b0f04c137829 | 73 | static void sOnCompletion(uint32_t pTd); |
va009039 | 0:b0f04c137829 | 74 | |
va009039 | 0:b0f04c137829 | 75 | private: |
va009039 | 0:b0f04c137829 | 76 | friend class UsbDevice; |
va009039 | 0:b0f04c137829 | 77 | |
va009039 | 0:b0f04c137829 | 78 | UsbDevice* m_pDevice; |
va009039 | 0:b0f04c137829 | 79 | |
va009039 | 0:b0f04c137829 | 80 | bool m_dir; |
va009039 | 0:b0f04c137829 | 81 | bool m_setup; |
va009039 | 0:b0f04c137829 | 82 | UsbEndpointType m_type; |
va009039 | 0:b0f04c137829 | 83 | |
va009039 | 0:b0f04c137829 | 84 | //bool m_done; |
va009039 | 0:b0f04c137829 | 85 | volatile bool m_result; |
va009039 | 0:b0f04c137829 | 86 | volatile int m_status; |
va009039 | 0:b0f04c137829 | 87 | |
va009039 | 0:b0f04c137829 | 88 | volatile uint32_t m_len; |
va009039 | 0:b0f04c137829 | 89 | |
va009039 | 0:b0f04c137829 | 90 | volatile uint8_t* m_pBufStartPtr; |
va009039 | 0:b0f04c137829 | 91 | |
va009039 | 0:b0f04c137829 | 92 | volatile HCED* m_pEd; //Ep descriptor |
va009039 | 0:b0f04c137829 | 93 | |
va009039 | 0:b0f04c137829 | 94 | volatile HCTD* m_pTdHead; //Head trf descriptor |
va009039 | 0:b0f04c137829 | 95 | volatile HCTD* m_pTdTail; //Tail trf descriptor |
va009039 | 0:b0f04c137829 | 96 | |
va009039 | 0:b0f04c137829 | 97 | CDummy* m_pCbItem; |
va009039 | 0:b0f04c137829 | 98 | void (CDummy::*m_pCbMeth)(); |
va009039 | 0:b0f04c137829 | 99 | }; |
va009039 | 0:b0f04c137829 | 100 | #endif |