aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Device/CDC.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-09-10 06:41:57 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-09-10 06:41:57 +0000
commite918d977b1d4465d525ee0f742dbdeec20f7885c (patch)
tree4da2b0cb02f251dcb1527cb2b205a5dc0123e3cd /LUFA/Drivers/USB/Class/Device/CDC.c
parentb221e7d175e4b5ca463fdd6d05b8c3fc71bd7c40 (diff)
downloadlufa-e918d977b1d4465d525ee0f742dbdeec20f7885c.tar.gz
lufa-e918d977b1d4465d525ee0f742dbdeec20f7885c.tar.bz2
lufa-e918d977b1d4465d525ee0f742dbdeec20f7885c.zip
Prevent the CDC Device Class driver from sending empty IN packets on every service task call - only send termination packets when data is in the endpoint.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device/CDC.c')
-rw-r--r--LUFA/Drivers/USB/Class/Device/CDC.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c
index 816a5f13d..aaa821e10 100644
--- a/LUFA/Drivers/USB/Class/Device/CDC.c
+++ b/LUFA/Drivers/USB/Class/Device/CDC.c
@@ -143,11 +143,11 @@ uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
if (!(Endpoint_IsReadWriteAllowed()))
- {
- uint8_t ErrorCode;
-
+ {
Endpoint_ClearIN();
+ uint8_t ErrorCode;
+
if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
return ErrorCode;
}
@@ -161,20 +161,26 @@ uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return ENDPOINT_READYWAIT_NoError;
+ uint8_t ErrorCode;
+
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
+
+ if (!(Endpoint_BytesInEndpoint()))
+ return ENDPOINT_READYWAIT_NoError;
+
+ bool BankFull = !(Endpoint_IsReadWriteAllowed());
- if (Endpoint_BytesInEndpoint())
+ Endpoint_ClearIN();
+
+ if (BankFull)
{
- uint8_t ErrorCode;
-
- Endpoint_ClearIN();
-
if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)
return ErrorCode;
+
+ Endpoint_ClearIN();
}
- Endpoint_ClearIN();
- return Endpoint_WaitUntilReady();
+ return ENDPOINT_READYWAIT_NoError;
}
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)