\r
while (Length && !(Endpoint_IsOUTReceived()))\r
{\r
- while (!(Endpoint_IsINReady()));\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ }\r
\r
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
{\r
\r
if (LastPacketFull)\r
{\r
- while (!(Endpoint_IsINReady()));\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected; \r
+ }\r
+ \r
Endpoint_ClearIN();\r
}\r
\r
- while (!(Endpoint_IsOUTReceived()));\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected; \r
+ }\r
\r
return ENDPOINT_RWCSTREAM_NoError;\r
}\r