Commit 9a8e7f7a authored by Damien George's avatar Damien George
Browse files

stmhal/usbd_cdc_interface: Increase in-endpoint timeout to 500ms.

The previous timeout value of 150ms could lead to data being lost (ie never
received by the host) in some rare cases, eg when the host is under load.
A value of 500ms is quite conservative and allows the host plenty of time
to read our data.
parent 2908c3ca
......@@ -261,8 +261,10 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
if (UserTxBufPtrOut != UserTxBufPtrOutShadow) {
// We have sent data and are waiting for the low-level USB driver to
// finish sending it over the USB in-endpoint.
// SOF occurs every 1ms, so we have a 150 * 1ms = 150ms timeout
if (UserTxBufPtrWaitCount < 150) {
// SOF occurs every 1ms, so we have a 500 * 1ms = 500ms timeout
// We have a relatively large timeout because the USB host may be busy
// doing other things and we must give it a chance to read our data.
if (UserTxBufPtrWaitCount < 500) {
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
// USB in-endpoint is still reading the data
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment