Mike R / USBDevice

Dependents:   frdm_Slider_Keyboard idd_hw2_figlax_PanType idd_hw2_appachu_finger_chording idd_hw3_AngieWangAntonioDeLimaFernandesDanielLim_BladeSymphony ... more

Fork of USBDevice by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mjr
Date:
Fri Jul 25 18:14:22 2014 +0000
Parent:
28:0596f144dad5
Child:
30:2f8f4c3822a1
Commit message:
Revised USB 3.0 port fix to send zero-length reply

Changed in this revision

USBDevice/USBDevice.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/USBDevice/USBDevice.cpp	Thu Jul 24 05:49:45 2014 +0000
+++ b/USBDevice/USBDevice.cpp	Fri Jul 25 18:14:22 2014 +0000
@@ -187,9 +187,27 @@
     /* Check we should be transferring data OUT */
     if (transfer.direction != HOST_TO_DEVICE)
     {
-        controlIn();
-        if (transfer.direction != HOST_TO_DEVICE)
-            return false;
+#if defined(TARGET_KL25Z)
+        /*
+         * We seem to have a pending device-to-host transfer.  The host must have
+         * sent a new control request without waiting for us to finish processing
+         * the previous one.  This appears to happen when we're connected to certain 
+         * USB 3.0 host chip set. Do a zeor-length send to tell the host we're not
+         * ready for the new request - that'll make it resend - and then just
+         * pretend we were successful here so that the pending transfer can finish.
+         */
+         uint8_t buf[1] = { 0 };
+         EP0write(buf, 0);
+         
+         /* execute our pending ttransfer */
+         controlIn();
+         
+         /* indicate success */
+         return true;
+ #else
+         /* for other platforms, count on the HAL to handle this case */
+         return false;
+ #endif
     }
 
     /* Read from endpoint */
@@ -681,7 +699,7 @@
     /* Endpoint 0 OUT data event */
     if (!controlOut())
     {
-        /* Protocol stall; this will stall both endpoints */ //$$$
+        /* Protocol stall; this will stall both endpoints */
         EP0stall();
     }
 }