aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
index 43a9f3d42..6c1445ee0 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
@@ -6,36 +6,28 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
if (Length > USB_ControlRequest.wLength)
Length = USB_ControlRequest.wLength;
- while (Length && !(Endpoint_IsOUTReceived()))
+ while (Length || LastPacketFull)
{
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return ENDPOINT_RWCSTREAM_DeviceDisconnected;
- }
-
- while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
- {
- TEMPLATE_TRANSFER_BYTE(DataStream);
- Length--;
- }
+ if (Endpoint_IsSETUPReceived())
+ return ENDPOINT_RWCSTREAM_HostAborted;
+
+ if (Endpoint_IsOUTReceived())
+ break;
- LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
- Endpoint_ClearIN();
- }
-
- if (Endpoint_IsOUTReceived())
- return ENDPOINT_RWCSTREAM_HostAborted;
-
- if (LastPacketFull)
- {
- while (!(Endpoint_IsINReady()))
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+
+ if (Endpoint_IsINReady())
{
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
+ {
+ TEMPLATE_TRANSFER_BYTE(DataStream);
+ Length--;
+ }
+
+ LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
+ Endpoint_ClearIN();
}
-
- Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()))