EthernetNetIf Compatibility.
Dependents: XBeeWiFi_SPI_example
Fork of NetServicesSource by
Diff: drv/serial/usb/UsbSerial.h
- Revision:
- 4:fd826cad83c0
- Parent:
- 0:632c9925f013
diff -r 95e0bc00a1bb -r fd826cad83c0 drv/serial/usb/UsbSerial.h --- a/drv/serial/usb/UsbSerial.h Fri Jun 18 10:38:57 2010 +0000 +++ b/drv/serial/usb/UsbSerial.h Fri Jul 09 14:46:47 2010 +0000 @@ -29,17 +29,19 @@ #include "Stream.h" #include "mbed.h" +#include "drv/usb/UsbDevice.h" +#include "drv/usb/UsbEndpoint.h" + namespace mbed { class UsbSerial : public Stream { public: - UsbSerial(int usbDev, int usbIf, const char *name = NULL); + UsbSerial(UsbDevice* pDevice, int epIn, int epOut, const char* name = NULL); virtual ~UsbSerial(); //Apart from the ctor/dtor, exactly the same protos as Serial - void baud(int baudrate); enum Parity { @@ -49,9 +51,29 @@ Forced1 = 3, Forced0 = 4 }; + + enum IrqType { + RxIrq = 0 + , TxIrq + }; void format(int bits, int parity, int stop); - + + class CDummy; + template <class T> + void attach(T* pCbItem, void (T::*pCbMeth)(), IrqType type = RxIrq) + { + if(type == RxIrq) + { + m_pInCbItem = (CDummy*) pCbItem; + m_pInCbMeth = (void (CDummy::*)()) pCbMeth; + } + else + { + m_pOutCbItem = (CDummy*) pCbItem; + m_pOutCbMeth = (void (CDummy::*)()) pCbMeth; + } + } #if 0 // Inhereted from Stream, for documentation only @@ -107,20 +129,38 @@ */ int writeable(); +#ifdef MBED_RPC virtual const struct rpc_method *get_rpc_methods(); static struct rpc_class *get_rpc_class(); +#endif protected: virtual int _getc(); virtual int _putc(int c); + void onReadable(); + void onWriteable(); + + void onEpInTransfer(); + void onEpOutTransfer(); + private: + UsbEndpoint m_epIn; + UsbEndpoint m_epOut; + + CDummy* m_pInCbItem; + void (CDummy::*m_pInCbMeth)(); + + CDummy* m_pOutCbItem; + void (CDummy::*m_pOutCbMeth)(); + void startTx(); void startRx(); Timeout m_txTimeout; + volatile bool m_timeout; volatile char* m_inBufEven; volatile char* m_inBufOdd;