EthernetNetIf Compatibility.

Dependents:   XBeeWiFi_SPI_example

Fork of NetServicesSource by Donatien Garnier

Committer:
donatien
Date:
Thu Aug 05 15:01:33 2010 +0000
Revision:
11:da4498f591ee
Parent:
4:fd826cad83c0

        

Who changed what in which revision?

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