aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-05-06 11:13:24 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-05-06 11:13:24 +0000
commitcde2afc50e25054a0ba21c4454e7101d7ac02a35 (patch)
tree6cccd0f8fc206054b4dbc412491c4937b02571c1
parentc3db72afdc9928afbf2a8986f6970aa85dd9902a (diff)
downloadlufa-cde2afc50e25054a0ba21c4454e7101d7ac02a35.tar.gz
lufa-cde2afc50e25054a0ba21c4454e7101d7ac02a35.tar.bz2
lufa-cde2afc50e25054a0ba21c4454e7101d7ac02a35.zip
Ensure that the CDC class drivers return 0 if the number of unread bytes is queried and the bank has become empty.
-rw-r--r--Bootloaders/TeensyHID/makefile2
-rw-r--r--LUFA/Drivers/USB/Class/Device/CDC.c11
-rw-r--r--LUFA/Drivers/USB/Class/Host/CDC.c16
3 files changed, 19 insertions, 10 deletions
diff --git a/Bootloaders/TeensyHID/makefile b/Bootloaders/TeensyHID/makefile
index 9a9f5ff0d..404b55f9c 100644
--- a/Bootloaders/TeensyHID/makefile
+++ b/Bootloaders/TeensyHID/makefile
@@ -68,7 +68,7 @@ BOARD =
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
-F_CPU = 8000000
+F_CPU = 16000000
# Input clock frequency.
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c
index 4cdea9485..ade2a1b50 100644
--- a/LUFA/Drivers/USB/Class/Device/CDC.c
+++ b/LUFA/Drivers/USB/Class/Device/CDC.c
@@ -195,9 +195,14 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface
if (Endpoint_IsOUTReceived())
{
if (!(Endpoint_BytesInEndpoint()))
- Endpoint_ClearOUT();
-
- return Endpoint_BytesInEndpoint();
+ {
+ Endpoint_ClearOUT();
+ return 0;
+ }
+ else
+ {
+ return Endpoint_BytesInEndpoint();
+ }
}
else
{
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c
index cc1ff8a0b..bc8e089a8 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.c
+++ b/LUFA/Drivers/USB/Class/Host/CDC.c
@@ -315,12 +315,16 @@ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
if (Pipe_IsINReceived())
{
if (!(Pipe_BytesInPipe()))
- Pipe_ClearIN();
-
- BytesInPipe = Pipe_BytesInPipe();
- Pipe_Freeze();
-
- return BytesInPipe;
+ {
+ Pipe_ClearIN();
+ Pipe_Freeze();
+ return 0;
+ }
+ else
+ {
+ Pipe_Freeze();
+ return Pipe_BytesInPipe();
+ }
}
else
{