From 3e4b51e09b0d915969ba04d3c2e29a6c281114b4 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Thu, 14 May 2020 02:12:02 +1200 Subject: [PATCH] Merge pull request #9789 from etracer65/hal_vcp_64byte_receive_fix --- src/main/vcp_hal/usbd_cdc_interface.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/vcp_hal/usbd_cdc_interface.c b/src/main/vcp_hal/usbd_cdc_interface.c index 0522cf2c3c..cfc4400a96 100644 --- a/src/main/vcp_hal/usbd_cdc_interface.c +++ b/src/main/vcp_hal/usbd_cdc_interface.c @@ -299,6 +299,12 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) { rxAvailable = *Len; rxBuffPtr = Buf; + if (!rxAvailable) { + // Received an empty packet, trigger receiving the next packet. + // This will happen after a packet that's exactly 64 bytes is received. + // The USB protocol requires that an empty (0 byte) packet immediately follow. + USBD_CDC_ReceivePacket(&USBD_Device); + } return (USBD_OK); }