Be doubly-certain that the incomming CDC class driver's endpoint/pipe is flushed...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 28 Jan 2010 06:37:26 +0000 (06:37 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 28 Jan 2010 06:37:26 +0000 (06:37 +0000)
LUFA/Drivers/USB/Class/Device/CDC.c
LUFA/Drivers/USB/Class/Host/CDC.c

index 16bc015..b8a673f 100644 (file)
@@ -190,10 +190,17 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface
 \r
        Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);\r
 \r
-       if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint()))\r
-         Endpoint_ClearOUT();\r
+       if (Endpoint_IsOUTReceived())\r
+       {\r
+               if (!(Endpoint_BytesInEndpoint()))\r
+                 Endpoint_ClearOUT();\r
 \r
-       return Endpoint_BytesInEndpoint();\r
+               return Endpoint_BytesInEndpoint();\r
+       }\r
+       else\r
+       {\r
+               return 0;\r
+       }\r
 }\r
 \r
 uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)\r
index 8ad37de..85864b0 100644 (file)
@@ -309,13 +309,22 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
        Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
        Pipe_Unfreeze();\r
 \r
-       if (Pipe_IsINReceived() && !(Pipe_BytesInPipe()))\r
-         Pipe_ClearIN();\r
-       \r
-       BytesInPipe = Pipe_BytesInPipe();\r
-       Pipe_Freeze();\r
-       \r
-       return BytesInPipe;\r
+       if (Pipe_IsINReceived())\r
+       {\r
+               if (!(Pipe_BytesInPipe()))\r
+                 Pipe_ClearIN();\r
+               \r
+               BytesInPipe = Pipe_BytesInPipe();\r
+               Pipe_Freeze();\r
+               \r
+               return BytesInPipe;\r
+       }\r
+       else\r
+       {\r
+               Pipe_Freeze();\r
+               \r
+               return 0;\r
+       }\r
 }\r
 \r
 uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r