aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c11
1 files changed, 7 insertions, 4 deletions
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 b85705c22..a2a0c3bd5 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
@@ -4,6 +4,12 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
while (Length)
{
+ if (Endpoint_IsSETUPReceived())
+ return ENDPOINT_RWCSTREAM_HostAborted;
+
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+
if (Endpoint_IsOUTReceived())
{
while (Length && Endpoint_BytesInEndpoint())
@@ -13,10 +19,7 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
}
Endpoint_ClearOUT();
- }
-
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ }
}
while (!(Endpoint_IsINReady()))