X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/a509729b2d92b03a3d33ab0e1e1950ff65a96a09..100a197d0efa177b9f514cbf5292a6a333b03de9:/LUFA/Drivers/USB/LowLevel/USBInterrupt.c diff --git a/LUFA/Drivers/USB/LowLevel/USBInterrupt.c b/LUFA/Drivers/USB/LowLevel/USBInterrupt.c index 21b0a9bb1..34234fe84 100644 --- a/LUFA/Drivers/USB/LowLevel/USBInterrupt.c +++ b/LUFA/Drivers/USB/LowLevel/USBInterrupt.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2010. - + Copyright (C) Dean Camera, 2011. + dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com + www.lufa-lib.org */ /* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -34,19 +34,19 @@ void USB_INT_DisableAllInterrupts(void) { #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); + USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); #elif defined(USB_SERIES_4_AVR) USBCON &= ~(1 << VBUSTE); #endif - + #if defined(USB_CAN_BE_BOTH) OTGIEN = 0; #endif - + #if defined(USB_CAN_BE_HOST) UHIEN = 0; #endif - + #if defined(USB_CAN_BE_DEVICE) UDIEN = 0; #endif @@ -55,25 +55,34 @@ void USB_INT_DisableAllInterrupts(void) void USB_INT_ClearAllInterrupts(void) { #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - USBINT = 0; + USBINT = 0; #endif - + #if defined(USB_CAN_BE_BOTH) - OTGINT = 0; + OTGINT = 0; #endif - + #if defined(USB_CAN_BE_HOST) - UHINT = 0; + UHINT = 0; #endif - + #if defined(USB_CAN_BE_DEVICE) - UDINT = 0; + UDINT = 0; #endif } ISR(USB_GEN_vect, ISR_BLOCK) { #if defined(USB_CAN_BE_DEVICE) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) + { + USB_INT_Clear(USB_INT_SOFI); + + EVENT_USB_Device_StartOfFrame(); + } + #endif + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS)) { @@ -86,7 +95,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) } else { - USB_DeviceState = DEVICE_STATE_Unattached; + USB_DeviceState = DEVICE_STATE_Unattached; EVENT_USB_Device_Disconnect(); } } @@ -98,9 +107,9 @@ ISR(USB_GEN_vect, ISR_BLOCK) USB_INT_Disable(USB_INT_SUSPI); USB_INT_Enable(USB_INT_WAKEUPI); - + USB_CLK_Freeze(); - + if (!(USB_Options & USB_OPT_MANUAL_PLL)) USB_PLL_Off(); @@ -127,19 +136,19 @@ ISR(USB_GEN_vect, ISR_BLOCK) USB_INT_Disable(USB_INT_WAKEUPI); USB_INT_Enable(USB_INT_SUSPI); - + if (USB_ConfigurationNumber) USB_DeviceState = DEVICE_STATE_Configured; else USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; - + #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) EVENT_USB_Device_Connect(); #else - EVENT_USB_Device_WakeUp(); + EVENT_USB_Device_WakeUp(); #endif } - + if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) { USB_INT_Clear(USB_INT_EORSTI); @@ -161,27 +170,29 @@ ISR(USB_GEN_vect, ISR_BLOCK) EVENT_USB_Device_Reset(); } - - if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) + #endif + + #if defined(USB_CAN_BE_HOST) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI)) { - USB_INT_Clear(USB_INT_SOFI); - - EVENT_USB_Device_StartOfFrame(); + USB_INT_Clear(USB_INT_HSOFI); + + EVENT_USB_Host_StartOfFrame(); } #endif - - #if defined(USB_CAN_BE_HOST) + if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI)) { USB_INT_Clear(USB_INT_DDISCI); USB_INT_Clear(USB_INT_DCONNI); USB_INT_Disable(USB_INT_DDISCI); - + EVENT_USB_Host_DeviceUnattached(); USB_ResetInterface(); } - + if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI)) { USB_INT_Clear(USB_INT_VBERRI); @@ -199,35 +210,28 @@ ISR(USB_GEN_vect, ISR_BLOCK) { USB_INT_Clear(USB_INT_SRPI); USB_INT_Disable(USB_INT_SRPI); - + EVENT_USB_Host_DeviceAttached(); USB_INT_Enable(USB_INT_DDISCI); - + USB_HostState = HOST_STATE_Powered; } if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI)) { USB_INT_Clear(USB_INT_BCERRI); - + EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0); EVENT_USB_Host_DeviceUnattached(); USB_ResetInterface(); } - - if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI)) - { - USB_INT_Clear(USB_INT_HSOFI); - - EVENT_USB_Host_StartOfFrame(); - } #endif #if defined(USB_CAN_BE_BOTH) if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI)) - { + { USB_INT_Clear(USB_INT_IDTI); if (USB_DeviceState != DEVICE_STATE_Unattached) @@ -235,7 +239,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) if (USB_HostState != HOST_STATE_Unattached) EVENT_USB_Host_DeviceUnattached(); - + USB_CurrentMode = USB_GetUSBModeFromUID(); USB_ResetInterface(); @@ -247,7 +251,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) #if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE) ISR(USB_COM_vect, ISR_BLOCK) { - uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); + uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); USB_INT_Disable(USB_INT_RXSTPI); @@ -262,3 +266,4 @@ ISR(USB_COM_vect, ISR_BLOCK) Endpoint_SelectEndpoint(PrevSelectedEndpoint); } #endif +