Skip to content

Commit bc80824

Browse files
committed
Send ZLP in USB_Send if TRANSFER_RELEASE is set on ep
as suggested by @embmicro
1 parent f667443 commit bc80824

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hardware/arduino/avr/cores/arduino/USBCore.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,15 @@ int USB_Send(u8 ep, const void* d, int len)
302302
while (n--)
303303
Send8(*data++);
304304
}
305-
_sendZlp[ep & USB_ENDPOINTS_MASK] = !ReadWriteAllowed() && (len == 0);
306-
if (!ReadWriteAllowed() || ((len == 0) && (ep & TRANSFER_RELEASE))) // Release full buffer
305+
_sendZlp[ep & USB_ENDPOINTS_MASK] = !ReadWriteAllowed() && (len == 0) && !(ep & TRANSFER_RELEASE);
306+
307+
if (!ReadWriteAllowed()) // Release full buffer
308+
ReleaseTX();
309+
310+
if ((len == 0) && (ep & TRANSFER_RELEASE)) {
311+
while(!ReadWriteAllowed());
307312
ReleaseTX();
313+
}
308314
}
309315
}
310316
TXLED1; // light the TX LED

0 commit comments

Comments
 (0)