Use an early-abort in the USB_DeviceTask() function rather than wrapping the entire...
authorDean Camera <dean@fourwalledcubicle.com>
Sat, 1 Sep 2012 22:55:56 +0000 (22:55 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sat, 1 Sep 2012 22:55:56 +0000 (22:55 +0000)
LUFA/Drivers/USB/Core/USBTask.c

index 71ae47d..be14611 100644 (file)
@@ -60,17 +60,17 @@ void USB_USBTask(void)
 #if defined(USB_CAN_BE_DEVICE)
 static void USB_DeviceTask(void)
 {
-       if (USB_DeviceState != DEVICE_STATE_Unattached)
-       {
-               uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
+       if (USB_DeviceState == DEVICE_STATE_Unattached)
+         return;
 
-               Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
+       uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
 
-               if (Endpoint_IsSETUPReceived())
-                 USB_Device_ProcessControlRequest();
+       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
 
-               Endpoint_SelectEndpoint(PrevEndpoint);
-       }
+       if (Endpoint_IsSETUPReceived())
+         USB_Device_ProcessControlRequest();
+
+       Endpoint_SelectEndpoint(PrevEndpoint);
 }
 #endif