Move check for devices not supporting internal serials in demos which make use of...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / CDC.c
index 003a6b3..816a5f1 100644 (file)
@@ -118,6 +118,11 @@ void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
        if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
          return;\r
 \r
+       Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);\r
+\r
+       if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint()))\r
+         Endpoint_ClearOUT();\r
+         \r
        CDC_Device_Flush(CDCInterfaceInfo);\r
 }\r
 \r
@@ -174,6 +179,9 @@ uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
 \r
 uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
 {\r
+       if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+         return 0;\r
+\r
        Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);\r
 \r
        if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint()))\r