Skip to content

Commit ddc5340

Browse files
committed
Merge pull request #414 from mjrgh/patch-1
Fix KL25Z connect problem with some USB 3.0 hosts
2 parents c94c251 + 43113cf commit ddc5340

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

libraries/USBDevice/USBDevice/USBDevice.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,27 @@ bool USBDevice::controlOut(void)
187187
/* Check we should be transferring data OUT */
188188
if (transfer.direction != HOST_TO_DEVICE)
189189
{
190-
return false;
190+
#if defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M) | defined(TARGET_K64F)
191+
/*
192+
* We seem to have a pending device-to-host transfer. The host must have
193+
* sent a new control request without waiting for us to finish processing
194+
* the previous one. This appears to happen when we're connected to certain
195+
* USB 3.0 host chip set. Do a zeor-length send to tell the host we're not
196+
* ready for the new request - that'll make it resend - and then just
197+
* pretend we were successful here so that the pending transfer can finish.
198+
*/
199+
uint8_t buf[1] = { 0 };
200+
EP0write(buf, 0);
201+
202+
/* execute our pending ttransfer */
203+
controlIn();
204+
205+
/* indicate success */
206+
return true;
207+
#else
208+
/* for other platforms, count on the HAL to handle this case */
209+
return false;
210+
#endif
191211
}
192212

193213
/* Read from endpoint */

0 commit comments

Comments
 (0)