Use an early-abort in the USB_DeviceTask() function rather than wrapping the entire implementation in a conditional.

This commit is contained in:
Dean Camera 2012-09-01 22:55:56 +00:00
parent c4aeb6d5ab
commit b9f3ff39a4
1 changed files with 8 additions and 8 deletions

View 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