Add option to the USB XMEGAs to set the USB bus interrupt priority level.
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 15 Jul 2011 08:29:25 +0000 (08:29 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 15 Jul 2011 08:29:25 +0000 (08:29 +0000)
LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h

index c67575b..dcb506b 100644 (file)
@@ -72,6 +72,13 @@ void USB_Init(
        NVM.CMD  = NVM_CMD_READ_CALIB_ROW_gc;\r
        USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));\r
        \r
        NVM.CMD  = NVM_CMD_READ_CALIB_ROW_gc;\r
        USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));\r
        \r
+       if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH)\r
+         USB.INTCTRLA = (3 << USB_INTLVL_gp);\r
+       else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED)\r
+         USB.INTCTRLA = (2 << USB_INTLVL_gp);\r
+       else\r
+         USB.INTCTRLA = (1 << USB_INTLVL_gp);\r
+\r
        SetGlobalInterruptMask(CurrentGlobalInt);\r
 \r
        USB_ResetInterface();   \r
        SetGlobalInterruptMask(CurrentGlobalInt);\r
 \r
        USB_ResetInterface();   \r
@@ -98,10 +105,6 @@ void USB_ResetInterface(void)
        USB_INT_DisableAllInterrupts();\r
        USB_INT_ClearAllInterrupts();\r
 \r
        USB_INT_DisableAllInterrupts();\r
        USB_INT_ClearAllInterrupts();\r
 \r
-       // TODO: Config define for priority\r
-       USB.INTCTRLA = (2 << USB_INTLVL_gp);\r
-       PMIC.CTRL   |= (1 << PMIC_MEDLVLEX_bp);\r
-\r
        USB_Controller_Reset();\r
        USB_Init_Device();\r
 }\r
        USB_Controller_Reset();\r
        USB_Init_Device();\r
 }\r
index 45cfe59..f6c4a7a 100644 (file)
                #endif\r
 \r
        /* Public Interface - May be used in end-application: */\r
                #endif\r
 \r
        /* Public Interface - May be used in end-application: */\r
-               /* Macros: */                   \r
+               /* Macros: */\r
+                       /** \name USB Controller Option Masks */\r
+                       //@{\r
+                       /** Sets the USB bus interrupt priority level to be low priority. The USB bus interrupt is used for Start of Frame events, bus suspend\r
+                        *  and resume events, bus reset events and other events related to the management of the USB bus.\r
+                        */\r
+                       #define USB_OPT_BUSEVENT_PRILOW           ((0 << 1) | (0 << 1))\r
+\r
+                       /** Sets the USB bus interrupt priority level to be medium priority. The USB bus interrupt is used for Start of Frame events, bus suspend\r
+                        *  and resume events, bus reset events and other events related to the management of the USB bus.\r
+                        */\r
+                       #define USB_OPT_BUSEVENT_PRIMED           ((0 << 1) | (1 << 1))\r
+\r
+                       /** Sets the USB bus interrupt priority level to be high priority. The USB bus interrupt is used for Start of Frame events, bus suspend\r
+                        *  and resume events, bus reset events and other events related to the management of the USB bus.\r
+                        */\r
+                       #define USB_OPT_BUSEVENT_PRIHIGH          ((1 << 1) | (0 << 1))\r
+                       //@}\r
+\r
                        /** \name Endpoint/Pipe Type Masks */\r
                        //@{\r
                        /** Mask for a CONTROL type endpoint or pipe.\r
                        /** \name Endpoint/Pipe Type Masks */\r
                        //@{\r
                        /** Mask for a CONTROL type endpoint or pipe.\r