aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Template
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Template')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c9
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c19
2 files changed, 24 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 d66edafd6..b85705c22 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
@@ -14,9 +14,16 @@ 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()));
+ while (!(Endpoint_IsINReady()))
+ {
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ }
return ENDPOINT_RWCSTREAM_NoError;
}
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 2796c6425..43a9f3d42 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
@@ -8,7 +8,11 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
while (Length && !(Endpoint_IsOUTReceived()))
{
- while (!(Endpoint_IsINReady()));
+ while (!(Endpoint_IsINReady()))
+ {
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ }
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{
@@ -25,11 +29,20 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
if (LastPacketFull)
{
- while (!(Endpoint_IsINReady()));
+ while (!(Endpoint_IsINReady()))
+ {
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ }
+
Endpoint_ClearIN();
}
- while (!(Endpoint_IsOUTReceived()));
+ while (!(Endpoint_IsOUTReceived()))
+ {
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ }
return ENDPOINT_RWCSTREAM_NoError;
}