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