Skip to content
Snippets Groups Projects
Commit 4c41dec5 authored by Cristian Maglie's avatar Cristian Maglie Committed by Cristian Maglie
Browse files

Bootloader: fixed blocking read from USB-CDC

For some reason the blocking read from the original USB-CDC driver
is not reliable. As a workaround it has been reimplemented using a
polling loop with the non-blocking read function that, instead, is
much more reliable.

Eventually the USB_Read_blocking(..) in cdc_enumerate.c will be fixed
in the future.
parent 3a1c4549
No related branches found
No related tags found
No related merge requests found
......@@ -750,5 +750,16 @@ uint32_t cdc_read_buf_xmd(void* data, uint32_t length)
return 0;
/* Blocking read till specified number of bytes is received */
return USB_Read_blocking(&pCdc, (char *)data, length);
// XXX: USB_Read_blocking is not reliable
// return USB_Read_blocking(&pCdc, (char *)data, length);
char *dst = (char *)data;
uint32_t remaining = length;
while (remaining) {
uint32_t readed = USB_Read(&pCdc, (char *)dst, remaining);
remaining -= readed;
dst += readed;
}
return length;
}
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment