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 Norimasa Okamoto

Revision:
25:7d6d9fc471bf
Parent:
24:5396b6a93262
--- a/USBHost/USBHost.cpp	Mon Jun 13 17:21:07 2016 +0000
+++ b/USBHost/USBHost.cpp	Fri Jun 17 09:00:35 2016 +0000
@@ -21,24 +21,36 @@
 void usb_test_assert_internal(const char *expr, const char *file, int line);
 #define USB_TEST_ASSERT(EXPR) while(!(EXPR)){usb_test_assert_internal(#EXPR,__FILE__,__LINE__);}
 
-USBHost* USBHost::inst = NULL;
+USBHost* USBHost::inst_0 = NULL;
+USBHost* USBHost::inst_1 = NULL;
 
 USBHost* USBHost::getHostInst(int IF_Number) {
-    if (inst == NULL) {
-        inst = new USBHost(IF_Number);
-        inst->init();
+    if (IF_Number==0)
+    {
+    if (inst_0 == NULL) {
+        inst_0 = new USBHost(IF_Number);
+        inst_0->init();
+    }
+    return inst_0;
     }
-    if(inst->IF_N!=IF_Number) {
-        inst = new USBHost(IF_Number);
-        inst->init();
+    else
+    {
+    if (inst_1 == NULL) {
+        inst_1 = new USBHost(IF_Number);
+        inst_1->init();
     }
-    return inst;
+    return inst_1;
+    }
+
 }
 
 void USBHost::poll()
 {
-    if (inst) {
-        inst->task();
+    if (inst_0) {
+        inst_0->task();
+    }
+    if (inst_1) {
+        inst_1->task();
     }
 }
 
@@ -202,7 +214,7 @@
 USB_TYPE USBHost::controlRead(USBDeviceConnected* dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t * buf, uint32_t len) {
     USBEndpoint* ep = dev->getEpCtl();
     SETUP_PACKET setup(requestType, request, value, index, len);
-
+    wait_ms(100);
     int result = token_setup(ep, &setup, len); // setup stage
     USB_TRACE1(result);
     if (result < 0) {