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