aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-09-19 05:58:27 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-09-19 05:58:27 +0000
commite7e1c21bc5476896f99569dc73ffe1f663f1245a (patch)
tree8698a9d588825dd73b5f3c170310706aaadc2971 /LUFA/Drivers/USB/LowLevel/USBInterrupt.c
parent01fecac0a70b02ccb197091935052fcfc9955b26 (diff)
downloadlufa-e7e1c21bc5476896f99569dc73ffe1f663f1245a.tar.gz
lufa-e7e1c21bc5476896f99569dc73ffe1f663f1245a.tar.bz2
lufa-e7e1c21bc5476896f99569dc73ffe1f663f1245a.zip
Clean up USBController.c/.h to more clearly seperate out host and device setup and reset paths.
Make USBInterrupt.c process all pending USB host mode interrupts before resetting the bus, so that no interrupts are lost when in UID auto-selection mode.
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/USBInterrupt.c')
-rw-r--r--LUFA/Drivers/USB/LowLevel/USBInterrupt.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/USBInterrupt.c b/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
index 52951fc39..311a7be4e 100644
--- a/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
+++ b/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
@@ -168,6 +168,8 @@ ISR(USB_GEN_vect, ISR_BLOCK)
#endif
#if defined(USB_CAN_BE_HOST)
+ bool MustResetInterface = false;
+
if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))
{
USB_INT_Clear(USB_INT_DDISCI);
@@ -175,8 +177,8 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Disable(USB_INT_DDISCI);
EVENT_USB_Host_DeviceUnattached();
-
- USB_ResetInterface();
+
+ MustResetInterface = true;
}
if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))
@@ -211,7 +213,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
EVENT_USB_Host_DeviceUnattached();
- USB_ResetInterface();
+ MustResetInterface = true;
}
if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))
@@ -236,8 +238,11 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_CurrentMode = USB_GetUSBModeFromUID();
EVENT_USB_UIDChange();
- USB_ResetInterface();
+ MustResetInterface = true;
}
+
+ if (MustResetInterface)
+ USB_ResetInterface();
#endif
}