Simple USBHost library for STM32F746NG Discovery board. Only either the Fastspeed or the Highspeed port can be used( not both together)
Dependents: DISCO-F746NG_USB_Host
Fork of KL46Z-USBHost by
Diff: USBHost/USBHost.h
- Revision:
- 9:7f9f64cf5ded
- Parent:
- 8:6463cd1964c0
- Child:
- 10:40c7f6788902
diff -r 6463cd1964c0 -r 7f9f64cf5ded USBHost/USBHost.h --- a/USBHost/USBHost.h Fri Jan 31 13:45:07 2014 +0000 +++ b/USBHost/USBHost.h Mon Feb 03 13:00:16 2014 +0000 @@ -5,7 +5,8 @@ #include "USBDeviceConnected.h" #include "IUSBEnumerator.h" #include "USBHostConf.h" -#include "USBEndpoint.h" +#include "dbg.h" +#include "myqueue.h" class USBHost : public USBHALHost { public: @@ -43,6 +44,7 @@ * @returns status of the control write */ USB_TYPE controlWrite(USBDeviceConnected * dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t * buf, uint32_t len); + /** * Bulk read * @@ -96,6 +98,19 @@ USB_TYPE interruptWrite(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true); /** + * Isochronous read + * + * @param dev the isochronous transfer will be done for this device + * @param ep USBEndpoint which will be used to write a packet + * @param buf pointer on a buffer which will be written + * @param len length of the transfer + * @param blocking if true, the read is blocking (wait for completion) + * + * @returns status of the interrupt read + */ + USB_TYPE isochronousRead(USBDeviceConnected* dev, USBEndpoint* ep, uint8_t* buf, uint32_t len, bool blocking = true); + + /** * Enumerate a device. * * @param dev device which will be enumerated @@ -112,7 +127,7 @@ * @returns pointer on the "index" device */ USBDeviceConnected * getDevice(uint8_t index) { - return (index < DeviceLists_count) ? DeviceLists[index] : NULL; + return DeviceLists.empty() ? NULL : DeviceLists.at(index); } /** @@ -127,8 +142,13 @@ 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); + // KL46Z-USBHost extensions + int interruptReadNB(USBEndpoint* ep, uint8_t* data, int size); + int interruptWriteNB(USBEndpoint* ep, const uint8_t* data, int size); + int bulkReadNB(USBEndpoint*ep, uint8_t* data, int size); + int bulkWriteNB(USBEndpoint*ep, const uint8_t* data, int size); + int isochronousReadNB(USBEndpoint*ep, uint8_t* data, int size); + static void poll(); private: USBHost(); @@ -136,13 +156,13 @@ 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; + myqueue<USBDeviceConnected*>DeviceLists; 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); + int bulkReadBLOCK(USBEndpoint*ep, uint8_t* data, int size, int timeout_ms); + void task(); + myqueue<USBEndpoint*>ep_queue; // USB HUB bool Hub(USBDeviceConnected* dev);