aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Device/CDC.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-08-13 06:43:17 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-08-13 06:43:17 +0000
commitdf5500e81cc40633eb5edee59410030f0aa77c2d (patch)
tree8277d2d9efb6f0e5396497ed309fd825e4359ee8 /LUFA/Drivers/USB/Class/Device/CDC.c
parentdf29aa37c05ff0251bd17f54c750bac56d7279b7 (diff)
downloadlufa-df5500e81cc40633eb5edee59410030f0aa77c2d.tar.gz
lufa-df5500e81cc40633eb5edee59410030f0aa77c2d.tar.bz2
lufa-df5500e81cc40633eb5edee59410030f0aa77c2d.zip
Added CDC_Device_Flush() command to the CDC Device mode class driver.
Minor updates to the unfinished SideShow demo for clarity. Added unfinished MassStorageHost class driver demo.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device/CDC.c')
-rw-r--r--LUFA/Drivers/USB/Class/Device/CDC.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c
index a6e5e2689..cbb9a8585 100644
--- a/LUFA/Drivers/USB/Class/Device/CDC.c
+++ b/LUFA/Drivers/USB/Class/Device/CDC.c
@@ -115,21 +115,10 @@ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
{
- if (USB_DeviceState != DEVICE_STATE_Configured)
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
return;
- Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
-
- if (!(Endpoint_BytesInEndpoint()))
- return;
-
- if (!(Endpoint_IsReadWriteAllowed()))
- {
- Endpoint_ClearIN();
- Endpoint_WaitUntilReady();
- }
-
- Endpoint_ClearIN();
+ CDC_Device_Flush(CDCInterfaceInfo);
}
void CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, char* const Data, const uint16_t Length)
@@ -157,6 +146,23 @@ void CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, con
Endpoint_Write_Byte(Data);
}
+void CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
+{
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))
+ return;
+
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);
+
+ if (Endpoint_BytesInEndpoint())
+ {
+ Endpoint_ClearIN();
+ Endpoint_WaitUntilReady();
+ }
+
+ Endpoint_ClearIN();
+ Endpoint_WaitUntilReady();
+}
+
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);