diff --git a/Demos/Device/ClassDriver/CDC/CDC.c b/Demos/Device/ClassDriver/CDC/CDC.c index 836a6e098fe5ce8c7ecd70a851948c4bf55300aa..1bcb4640a74b601ea9cac68cb8aec6e4cc37cb6b 100644 --- a/Demos/Device/ClassDriver/CDC/CDC.c +++ b/Demos/Device/ClassDriver/CDC/CDC.c @@ -92,6 +92,7 @@ int main(void) { CheckJoystickMovement(); + /* Must throw away unused bytes from the host, or it will lock up while waiting for the device */ while (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface)) CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); diff --git a/Demos/Device/ClassDriver/DualCDC/DualCDC.c b/Demos/Device/ClassDriver/DualCDC/DualCDC.c index 0de83e1d9f2cc924fb24d12cb1b68f1c29afff6c..9e3217cf76d767b6cbcd9232228071997959f5a7 100644 --- a/Demos/Device/ClassDriver/DualCDC/DualCDC.c +++ b/Demos/Device/ClassDriver/DualCDC/DualCDC.c @@ -99,13 +99,11 @@ int main(void) CheckJoystickMovement(); /* Discard all received data on the first CDC interface */ - uint16_t BytesToDiscard = CDC_Device_BytesReceived(&VirtualSerial1_CDC_Interface); - while (BytesToDiscard--) + while (CDC_Device_BytesReceived(&VirtualSerial1_CDC_Interface)) CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface); /* Echo all received data on the second CDC interface */ - uint16_t BytesToEcho = CDC_Device_BytesReceived(&VirtualSerial2_CDC_Interface); - while (BytesToEcho--) + while (CDC_Device_BytesReceived(&VirtualSerial2_CDC_Interface)) CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface)); CDC_Device_USBTask(&VirtualSerial1_CDC_Interface);