USB Host Driver with Socket Modem support. Works with revision 323 of mbed-src but broken with any later version.
Dependencies: FATFileSystem
Fork of F401RE-USBHost by
Diff: USBHost/USBHost.h
- Revision:
- 8:6463cd1964c0
- Parent:
- 7:9a20482c9a7a
- Child:
- 9:7f9f64cf5ded
--- a/USBHost/USBHost.h Tue Jan 28 06:50:12 2014 +0000 +++ b/USBHost/USBHost.h Fri Jan 31 13:45:07 2014 +0000 @@ -3,10 +3,10 @@ #include "mbed.h" #include "USBHALHost.h" #include "USBDeviceConnected.h" +#include "IUSBEnumerator.h" +#include "USBHostConf.h" #include "USBEndpoint.h" -class IUSBEnumerator {}; // dummy - class USBHost : public USBHALHost { public: /** @@ -95,22 +95,63 @@ */ USB_TYPE interruptWrite(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true); - int ControlRead(SETUP_PACKET* setup, uint8_t* data, int size); - int ControlWrite(SETUP_PACKET* setup, uint8_t* data = NULL, int size = 0); - int BulkRead(uint8_t* data, int size, int timeout_ms = -1); - int BulkWrite(const uint8_t* data, int size); - int InterruptRead(uint8_t* data, int size); + /** + * Enumerate a device. + * + * @param dev device which will be enumerated + * + * @returns status of the enumeration + */ + USB_TYPE enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerator); + + /** + * Get a device + * + * @param index index of the device which will be returned + * + * @returns pointer on the "index" device + */ + USBDeviceConnected * getDevice(uint8_t index) { + return (index < DeviceLists_count) ? DeviceLists[index] : NULL; + } + + /** + * register a driver into the host associated with a callback function called when the device is disconnected + * + * @param dev device + * @param intf interface number + * @param tptr pointer to the object to call the member function on + * @param mptr pointer to the member function to be called + */ + template<typename T> + void registerDriver(USBDeviceConnected * dev, uint8_t intf, T* tptr, void (T::*mptr)(void)) { + } + + int BulkRead(USBEndpoint*ep, uint8_t* data, int size, int timeout_ms = -1); int IsochronousRead(USBEndpoint*ep, uint8_t* data, int size); - USBDeviceConnected dev; - private: USBHost(); static USBHost* inst; - virtual bool enumeration(); - USBEndpoint ep_ctl_in_out; - USBEndpoint ep_int_in; - USBEndpoint ep_bulk_in; - USBEndpoint ep_bulk_out; + virtual bool addDevice(int hub, int port, bool lowSpeed); + void root_enumeration(USBDeviceConnected* dev); + void parseConfDescr(USBDeviceConnected* dev, uint8_t* conf_descr, uint32_t len, IUSBEnumerator* pEnumerator); + USBDeviceConnected* DeviceLists[MAX_DEVICE_CONNECTED]; + int DeviceLists_count; + + int ControlRead(USBDeviceConnected* dev, SETUP_PACKET* setup, uint8_t* data, int size); + int ControlWrite(USBDeviceConnected* dev, SETUP_PACKET* setup, uint8_t* data = NULL, int size = 0); + int BulkWrite(USBEndpoint*ep, const uint8_t* data, int size); + int InterruptRead(USBEndpoint*ep, uint8_t* data, int size); + + // USB HUB + bool Hub(USBDeviceConnected* dev); + int SetPortPower(USBDeviceConnected* dev, int port); + int ClearPortPower(USBDeviceConnected* dev, int port); + int PortReset(USBDeviceConnected* dev, int port); + int SetPortFeature(USBDeviceConnected* dev, int feature, int index); + int ClearPortFeature(USBDeviceConnected* dev, int feature, int index); + int SetPortReset(USBDeviceConnected* dev, int port); + int GetPortStatus(USBDeviceConnected* dev, int port, uint32_t* status); };