EthernetNetIf Compatibility.
Dependents: XBeeWiFi_SPI_example
Fork of NetServicesSource by
Diff: drv/usb/UsbEndpoint.h
- Revision:
- 4:fd826cad83c0
- Parent:
- 0:632c9925f013
diff -r 95e0bc00a1bb -r fd826cad83c0 drv/usb/UsbEndpoint.h --- a/drv/usb/UsbEndpoint.h Fri Jun 18 10:38:57 2010 +0000 +++ b/drv/usb/UsbEndpoint.h Fri Jul 09 14:46:47 2010 +0000 @@ -25,55 +25,63 @@ #define USB_ENDPOINT_H #include "mbed.h" -#include "USBHostLite/usbhost_inc.h" +#include "UsbInc.h" -typedef int32_t RC; +class UsbDevice; -class EdPool +enum UsbEndpointType { -public: - EdPool(int size); - ~EdPool(); - HCED* get(); -private: - uint8_t* m_pool; - int m_pos; - -}; - -class TdPool -{ -public: - TdPool(int size); - ~TdPool(); - HCTD* get(); -private: - uint8_t* m_pool; - int m_pos; - + USB_CONTROL, + USB_BULK +// USB_INT, +// USB_ISO }; class UsbEndpoint { public: - UsbEndpoint( /* UsbDevice*, */ uint8_t ep, bool dir, uint16_t size ); + UsbEndpoint( UsbDevice* pDevice, uint8_t ep, bool dir, UsbEndpointType type, uint16_t size, int addr = -1 ); ~UsbEndpoint(); - RC transfer(volatile uint8_t* buf, uint32_t len); + void setNextToken(uint32_t token); //Only for control Eps + + UsbErr transfer(volatile uint8_t* buf, uint32_t len); + + int status(); //return UsbErr or transfered len + + void updateAddr(int addr); + void updateSize(uint16_t size); - RC status(); - + //void setOnCompletion( void(*pCb)completed() ); + class CDummy; + template <class T> + void setOnCompletion( T* pCbItem, void (T::*pCbMeth)() ) + { + m_pCbItem = (CDummy*) pCbItem; + m_pCbMeth = (void (CDummy::*)()) pCbMeth; + } + //static void completed(){} +protected: + void onCompletion(); +public: + static void sOnCompletion(uint32_t pTd); + private: - EdPool m_edPool; - TdPool m_tdPool; + friend class UsbDevice; + + UsbDevice* m_pDevice; bool m_dir; + bool m_setup; + UsbEndpointType m_type; - bool m_done; + //bool m_done; + volatile bool m_result; + volatile int m_status; - uint32_t m_len; + volatile uint32_t m_len; volatile uint8_t* m_pBufStartPtr; @@ -83,6 +91,13 @@ //static volatile HCED* m_pNextEd; + CDummy* m_pCbItem; + void (CDummy::*m_pCbMeth)(); + + + static UsbEndpoint* m_pHeadEp; + UsbEndpoint* m_pNextEp; + }; #endif