Skip to content

Commit 817d700

Browse files
committed
Subtract one from USB_EP_SIZE in USB_SendSpace
This avoids dealing with ZLP’s in USB_Send, because the max packet size will be EP size - 1.
1 parent c99ab12 commit 817d700

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ u8 USB_SendSpace(u8 ep)
255255
LockEP lock(ep);
256256
if (!ReadWriteAllowed())
257257
return 0;
258-
return USB_EP_SIZE - FifoByteCount();
258+
// subtract 1 from the EP size to never send a full packet,
259+
// this avoids dealing with ZLP's in USB_Send
260+
return USB_EP_SIZE - 1 - FifoByteCount();
259261
}
260262

261263
// Blocking Send of data to an endpoint

0 commit comments

Comments
 (0)