Skip to content

Commit 09bbe72

Browse files
committed
stmhal: Fix USB CDC not flushing packets when an exact multiple of 64.
Need to send a zero-sized packet after sending an exact multiple of 64 bytes (not just after sending 64 bytes exactly). Addresses issue adafruit#494, part 2.
1 parent 0fb80c3 commit 09bbe72

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

stmhal/usbd_cdc_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void USBD_CDC_HAL_TIM_PeriodElapsedCallback(void) {
313313
// the host waits for all data to arrive (ie, waits for a packet < max packet size).
314314
// To flush a packet of exactly max packet size, we need to send a zero-size packet.
315315
// See eg http://www.cypress.com/?id=4&rID=92719
316-
UserTxNeedEmptyPacket = (buffsize == CDC_DATA_FS_MAX_PACKET_SIZE && UserTxBufPtrOutShadow == UserTxBufPtrIn);
316+
UserTxNeedEmptyPacket = (buffsize > 0 && buffsize % CDC_DATA_FS_MAX_PACKET_SIZE == 0 && UserTxBufPtrOutShadow == UserTxBufPtrIn);
317317
}
318318
}
319319
}

0 commit comments

Comments
 (0)