Usb read

Dependencies:   FATFileSystem

Fork of F401RE-USBHost by Norimasa Okamoto

Revision:
13:8774c07f12a5
Parent:
11:61843badd06e
Child:
14:b167f2b97cb7
diff -r b91fdea8c0a7 -r 8774c07f12a5 USBHost/USBHALHost_F401RE.cpp
--- a/USBHost/USBHALHost_F401RE.cpp	Mon Jun 09 09:01:10 2014 +0000
+++ b/USBHost/USBHALHost_F401RE.cpp	Tue Jun 10 13:38:41 2014 +0900
@@ -409,24 +409,17 @@
 }
 
 int USBHALHost::token_iso_in(USBEndpoint* ep, uint8_t* data, int size) {
-    USBDeviceConnected* dev = ep->getDevice();
-    HAL_HCD_HC_Init(&hhcd_USB_OTG_FS, CH_ISO_IN,
-        ep->getAddress(),
-        dev->getAddress(),
-        HCD_SPEED_FULL,
-        EP_TYPE_ISOC, ep->getSize());
-
-    token_done = false;
+    static bool init = false;
+    if (!init) {
+        init = true;
+        USBDeviceConnected* dev = ep->getDevice();
+        HAL_HCD_HC_Init(&hhcd_USB_OTG_FS, CH_ISO_IN,
+            ep->getAddress(), dev->getAddress(),
+            HCD_SPEED_FULL, EP_TYPE_ISOC, ep->getSize());
+    }
     HAL_HCD_HC_SubmitRequest(&hhcd_USB_OTG_FS, CH_ISO_IN, DIR_IN, EP_TYPE_ISOC, 1, data, size, 0);
-    while(!token_done);
-
-    switch(HAL_HCD_HC_GetURBState(&hhcd_USB_OTG_FS, CH_ISO_IN)) {
-        case URB_DONE:
+    while(HAL_HCD_HC_GetURBState(&hhcd_USB_OTG_FS, CH_ISO_IN) == URB_IDLE);
     return HAL_HCD_HC_GetXferCount(&hhcd_USB_OTG_FS, CH_ISO_IN);
-
-        default:
-            return -1;
-    }
 }
 
 #endif