diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2010-01-28 06:37:26 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2010-01-28 06:37:26 +0000 |
| commit | 5a160ecf0daa3dc40f9d21157bb930a226dc16c4 (patch) | |
| tree | d8eca51e0d147fa740b47d6ef1bd9eada3248e85 | |
| parent | 1c03684fbdf97c7d569df04ad1d4a8dad039a1b8 (diff) | |
Be doubly-certain that the incomming CDC class driver's endpoint/pipe is flushed only once when the bank is empty.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1073 d5102386-fcda-11dd-9fdb-3debd5008f28
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.c | 13 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Host/CDC.c | 23 |
2 files changed, 26 insertions, 10 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c index 16bc0154..b8a673f0 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.c +++ b/LUFA/Drivers/USB/Class/Device/CDC.c @@ -190,10 +190,17 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);
- if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint()))
- Endpoint_ClearOUT();
+ if (Endpoint_IsOUTReceived())
+ {
+ if (!(Endpoint_BytesInEndpoint()))
+ Endpoint_ClearOUT();
- return Endpoint_BytesInEndpoint();
+ return Endpoint_BytesInEndpoint();
+ }
+ else
+ {
+ return 0;
+ }
}
uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index 8ad37de7..85864b05 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -309,13 +309,22 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo Pipe_SetPipeToken(PIPE_TOKEN_IN);
Pipe_Unfreeze();
- if (Pipe_IsINReceived() && !(Pipe_BytesInPipe()))
- Pipe_ClearIN();
-
- BytesInPipe = Pipe_BytesInPipe();
- Pipe_Freeze();
-
- return BytesInPipe;
+ if (Pipe_IsINReceived())
+ {
+ if (!(Pipe_BytesInPipe()))
+ Pipe_ClearIN();
+
+ BytesInPipe = Pipe_BytesInPipe();
+ Pipe_Freeze();
+
+ return BytesInPipe;
+ }
+ else
+ {
+ Pipe_Freeze();
+
+ return 0;
+ }
}
uint8_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
|
