X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/c830fcb0e1d42c1300ebe78a8b33924054b63a87..fc31973daffea3506051ce51a5f79383ce0867d6:/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c index f6afb6901..92b5396d7 100644 --- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c +++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c @@ -1,23 +1,22 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length) { - uint8_t* DataStream = (uint8_t*)(Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - bool LastPacketFull = false; + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - if (Length > USB_ControlRequest.wLength) - Length = USB_ControlRequest.wLength; - - while (Length || LastPacketFull) + if (!(Length)) + Endpoint_ClearOUT(); + + while (Length) { if (Endpoint_IsSETUPReceived()) return ENDPOINT_RWCSTREAM_HostAborted; if (USB_DeviceState == DEVICE_STATE_Unattached) return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; if (Endpoint_IsOUTReceived()) { - LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize); - while (Length && Endpoint_BytesInEndpoint()) { TEMPLATE_TRANSFER_BYTE(DataStream); @@ -25,9 +24,6 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length) } Endpoint_ClearOUT(); - - if (!(LastPacketFull)) - Length = 0; } } @@ -35,6 +31,8 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length) { if (USB_DeviceState == DEVICE_STATE_Unattached) return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; } return ENDPOINT_RWCSTREAM_NoError;