From f07e766755b2489c76f0f353b7fe2d4a11300e61 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 15 Jul 2011 08:10:51 +0000 Subject: Complete USB XMEGA interrupt control subsystem code in the core USB driver. Automatically load in the USB calibration bytes from the User Signature Row on start-up. Create internal SRAM variable for the endpoint control and status register table, used by the XMEGA USB controller hardware. --- LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c | 61 ++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) (limited to 'LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c') diff --git a/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c b/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c index cb8062256..b52a716d6 100644 --- a/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c +++ b/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c @@ -33,13 +33,68 @@ void USB_INT_DisableAllInterrupts(void) { - // TODO + USB.INTCTRLA = 0; + USB.INTCTRLB = 0; } void USB_INT_ClearAllInterrupts(void) { - // TODO + USB.INTFLAGSACLR = 0xFF; + USB.INTFLAGSBCLR = 0xFF; } -// TODO: USB ISR +ISR(USB_BUSEVENT_vect) +{ + #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 (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend)) + { + USB_INT_Clear(USB_INT_BUSEVENTI_Suspend); + + #if !defined(NO_LIMITED_CONTROLLER_CONNECT) + USB_DeviceState = DEVICE_STATE_Unattached; + EVENT_USB_Device_Disconnect(); + #else + USB_DeviceState = DEVICE_STATE_Suspended; + EVENT_USB_Device_Suspend(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Resume)) + { + USB_INT_Clear(USB_INT_BUSEVENTI_Resume); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + #if !defined(NO_LIMITED_CONTROLLER_CONNECT) + EVENT_USB_Device_Connect(); + #else + EVENT_USB_Device_WakeUp(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Reset)) + { + USB_INT_Clear(USB_INT_BUSEVENTI_Reset); + + USB_DeviceState = DEVICE_STATE_Default; + USB_Device_ConfigurationNumber = 0; + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, + ENDPOINT_BANK_SINGLE); + + EVENT_USB_Device_Reset(); + } +} -- cgit v1.2.3