X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/b221e7d175e4b5ca463fdd6d05b8c3fc71bd7c40..e918d977b1d4465d525ee0f742dbdeec20f7885c:/LUFA/Drivers/USB/Class/Device/CDC.c 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)