Minor cleanups to DualCDC ClassDriver device demo for clarity.
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 30 Jul 2009 14:12:00 +0000 (14:12 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 30 Jul 2009 14:12:00 +0000 (14:12 +0000)
Demos/Device/ClassDriver/CDC/CDC.c
Demos/Device/ClassDriver/DualCDC/DualCDC.c

index 836a6e0..1bcb464 100644 (file)
@@ -92,6 +92,7 @@ int main(void)
        {\r
                CheckJoystickMovement();\r
                \r
+               /* Must throw away unused bytes from the host, or it will lock up while waiting for the device */\r
                while (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface))\r
                  CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);\r
 \r
index 0de83e1..9e3217c 100644 (file)
@@ -99,13 +99,11 @@ int main(void)
                CheckJoystickMovement();\r
 \r
                /* Discard all received data on the first CDC interface */\r
-               uint16_t BytesToDiscard = CDC_Device_BytesReceived(&VirtualSerial1_CDC_Interface);\r
-               while (BytesToDiscard--)\r
+               while (CDC_Device_BytesReceived(&VirtualSerial1_CDC_Interface))\r
                  CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface);\r
 \r
                /* Echo all received data on the second CDC interface */\r
-               uint16_t BytesToEcho = CDC_Device_BytesReceived(&VirtualSerial2_CDC_Interface);\r
-               while (BytesToEcho--)\r
+               while (CDC_Device_BytesReceived(&VirtualSerial2_CDC_Interface))\r
                  CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface));\r
                  \r
                CDC_Device_USBTask(&VirtualSerial1_CDC_Interface);\r