X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/2c806f6ceee42db9094eb11f3f32524b98440726..7aa8dc1de069b0f9c9e0b2bd379713d49dfee377:/LUFA/Drivers/USB/Core/USBTask.c diff --git a/LUFA/Drivers/USB/Core/USBTask.c b/LUFA/Drivers/USB/Core/USBTask.c index 3f9556033..be14611aa 100644 --- a/LUFA/Drivers/USB/Core/USBTask.c +++ b/LUFA/Drivers/USB/Core/USBTask.c @@ -7,7 +7,7 @@ */ /* - Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted @@ -45,32 +45,32 @@ volatile uint8_t USB_DeviceState; void USB_USBTask(void) { - #if defined(USB_HOST_ONLY) - USB_HostTask(); - #elif defined(USB_DEVICE_ONLY) - USB_DeviceTask(); - #else + #if defined(USB_CAN_BE_BOTH) if (USB_CurrentMode == USB_MODE_Device) USB_DeviceTask(); else if (USB_CurrentMode == USB_MODE_Host) USB_HostTask(); + #elif defined(USB_CAN_BE_HOST) + USB_HostTask(); + #elif defined(USB_CAN_BE_DEVICE) + USB_DeviceTask(); #endif } #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; + + uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - if (Endpoint_IsSETUPReceived()) - USB_Device_ProcessControlRequest(); + if (Endpoint_IsSETUPReceived()) + USB_Device_ProcessControlRequest(); - Endpoint_SelectEndpoint(PrevEndpoint); - } + Endpoint_SelectEndpoint(PrevEndpoint); } #endif