X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/cf2776531c04b0ebe4fdd9d4ef5324dacefd5639..4530a546a16b48fdc34c20102bb72c3968487f4e:/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..c968d7f0c 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) @@ -221,7 +227,7 @@ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDC .wLength = sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), }; - Endpoint_Write_Stream_LE(&Notification, sizeof(Notification), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NO_STREAM_CALLBACK); Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost, sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), NO_STREAM_CALLBACK);