Removed all user pipe/endpoint interrupt APIs, added internal library support for...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 14 May 2009 10:07:08 +0000 (10:07 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 14 May 2009 10:07:08 +0000 (10:07 +0000)
22 files changed:
Demos/Device/GenericHID/GenericHID.c
Demos/Device/GenericHID/GenericHID.h
Demos/Device/GenericHID/GenericHID.txt
Demos/Device/Keyboard/Keyboard.c
Demos/Device/Keyboard/Keyboard.h
Demos/Device/Keyboard/Keyboard.txt
Demos/Device/MassStorage/MassStorage.c
Demos/Device/MassStorage/MassStorage.h
Demos/Device/MassStorage/MassStorage.txt
Demos/Device/MassStorage/makefile
Demos/Device/Mouse/Mouse.c
Demos/Device/Mouse/Mouse.h
Demos/Device/Mouse/Mouse.txt
Demos/Host/GenericHIDHost/GenericHIDHost.c
LUFA/ChangeLog.txt
LUFA/CompileTimeTokens.txt
LUFA/Drivers/USB/HighLevel/USBInterrupt.c
LUFA/Drivers/USB/HighLevel/USBInterrupt.h
LUFA/Drivers/USB/HighLevel/USBTask.h
LUFA/Drivers/USB/LowLevel/Endpoint.h
LUFA/Drivers/USB/LowLevel/Pipe.h
LUFA/MigrationInformation.txt

index d4e7cca..0369f9f 100644 (file)
 /* Scheduler Task List */\r
 TASK_LIST\r
 {\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        { .Task = USB_USBTask          , .TaskStatus = TASK_STOP },\r
-       #endif\r
-       \r
        { .Task = USB_HID_Report       , .TaskStatus = TASK_STOP },\r
 };\r
 \r
@@ -75,30 +72,13 @@ int main(void)
        Scheduler_Start();\r
 }\r
 \r
-/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the\r
- *  enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled\r
- *  asynchronously when they arrive rather than when the control endpoint is polled manually.\r
- */\r
-EVENT_HANDLER(USB_Reset)\r
-{\r
-       #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-       /* Select the control endpoint */\r
-       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
-\r
-       /* Enable the endpoint SETUP interrupt ISR for the control endpoint */\r
-       USB_INT_Enable(ENDPOINT_INT_SETUP);\r
-       #endif\r
-}\r
-\r
 /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and\r
  *  starts the library USB task to begin the enumeration and USB management process.\r
  */\r
 EVENT_HANDLER(USB_Connect)\r
 {\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        /* Start USB management task */\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);\r
-       #endif\r
 \r
        /* Indicate USB enumerating */\r
        UpdateStatus(Status_USBEnumerating);\r
@@ -111,10 +91,7 @@ EVENT_HANDLER(USB_Disconnect)
 {\r
        /* Stop running HID reporting and USB management tasks */\r
        Scheduler_SetTaskMode(USB_HID_Report, TASK_STOP);\r
-\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);\r
-       #endif\r
 \r
        /* Indicate USB not ready */\r
        UpdateStatus(Status_USBNotReady);\r
@@ -298,32 +275,3 @@ TASK(USB_HID_Report)
                }\r
        }\r
 }\r
-\r
-#if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when an endpoint's status changes (such as\r
- *  a packet has been received) on an endpoint with its corresponding ISR enabling bits set. This is used to send\r
- *  HID packets to the host each time the HID interrupt endpoints polling period elapses, as managed by the USB\r
- *  controller.\r
- */\r
-ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)\r
-{\r
-       /* Save previously selected endpoint before selecting a new endpoint */\r
-       uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
-\r
-       /* Check if the control endpoint has received a request */\r
-       if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP))\r
-       {\r
-               /* Clear the endpoint interrupt */\r
-               Endpoint_ClearEndpointInterrupt(ENDPOINT_CONTROLEP);\r
-\r
-               /* Process the control request */\r
-               USB_USBTask();\r
-\r
-               /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */\r
-               USB_INT_Clear(ENDPOINT_INT_SETUP);\r
-       }\r
-\r
-       /* Restore previously selected endpoint */\r
-       Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
-}\r
-#endif\r
index 817d377..5841595 100644 (file)
@@ -68,9 +68,6 @@
                };\r
 \r
        /* Event Handlers: */\r
-               /** Indicates that this module will catch the USB_Reset event when thrown by the library. */\r
-               HANDLES_EVENT(USB_Reset);\r
-\r
                /** Indicates that this module will catch the USB_Connect event when thrown by the library. */\r
                HANDLES_EVENT(USB_Connect);\r
 \r
index c78f637..a40b78b 100644 (file)
  *    <td>This token defines the size of the device reports, both sent and received. The value must be an\r
  *        integer ranging from 1 to 255.</td>\r
  *   </tr>\r
- *   <tr>\r
- *    <td>INTERRUPT_CONTROL_ENDPOINT</td>\r
- *    <td>Makefile CDEFS</td>\r
- *    <td>When defined, this causes the demo to enable interrupts for the control endpoint,\r
- *        which services control requests from the host. If not defined, the control endpoint\r
- *        is serviced via polling using the task scheduler.</td>\r
- *   </tr>\r
  *  </table>\r
  */\r
index 928d95b..fe041ef 100644 (file)
 /* Scheduler Task List */\r
 TASK_LIST\r
 {\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
-       { .Task = USB_USBTask          , .TaskStatus = TASK_STOP },\r
-       #endif\r
-       \r
+       { .Task = USB_USBTask          , .TaskStatus = TASK_STOP },     \r
        { .Task = USB_Keyboard_Report  , .TaskStatus = TASK_STOP },\r
 };\r
 \r
@@ -105,10 +102,8 @@ int main(void)
  */\r
 EVENT_HANDLER(USB_Connect)\r
 {\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        /* Start USB management task */\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);\r
-       #endif\r
 \r
        /* Indicate USB enumerating */\r
        UpdateStatus(Status_USBEnumerating);\r
@@ -117,21 +112,6 @@ EVENT_HANDLER(USB_Connect)
        UsingReportProtocol = true;\r
 }\r
 \r
-/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the\r
- *  enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled\r
- *  asynchronously when they arrive rather than when the control endpoint is polled manually.\r
- */\r
-EVENT_HANDLER(USB_Reset)\r
-{\r
-       #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-       /* Select the control endpoint */\r
-       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
-\r
-       /* Enable the endpoint SETUP interrupt ISR for the control endpoint */\r
-       USB_INT_Enable(ENDPOINT_INT_SETUP);\r
-       #endif\r
-}\r
-\r
 /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via\r
  *  the status LEDs.\r
  */\r
@@ -139,10 +119,7 @@ EVENT_HANDLER(USB_Disconnect)
 {\r
        /* Stop running keyboard reporting and USB management tasks */\r
        Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP);\r
-\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);\r
-       #endif\r
        \r
        /* Indicate USB not ready */\r
        UpdateStatus(Status_USBNotReady);\r
@@ -445,30 +422,3 @@ TASK(USB_Keyboard_Report)
                ReceiveNextReport();\r
        }\r
 }\r
-\r
-#if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when an endpoint's status changes (such as\r
- *  a packet has been received) on an endpoint with its corresponding ISR enabling bits set. This is used to send\r
- *  HID packets to the host each time the HID interrupt endpoints polling period elapses, as managed by the USB\r
- *  controller. It is also used to respond to standard and class specific requests send to the device on the control\r
- *  endpoint, by handing them off to the LUFA library when they are received.\r
- */\r
-ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)\r
-{\r
-       /* Save previously selected endpoint before selecting a new endpoint */\r
-       uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
-\r
-       /* Check if the control endpoint has received a request */\r
-       if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP))\r
-       {\r
-               /* Process the control request */\r
-               USB_USBTask();\r
-\r
-               /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */\r
-               USB_INT_Clear(ENDPOINT_INT_SETUP);\r
-       }\r
-       \r
-       /* Restore previously selected endpoint */\r
-       Endpoint_SelectEndpoint(PrevSelectedEndpoint);  \r
-}\r
-#endif\r
index c737019..2cc9c5c 100644 (file)
                /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */\r
                HANDLES_EVENT(USB_Disconnect);\r
 \r
-               /** Indicates that this module will catch the USB_Reset event when thrown by the library. */\r
-               HANDLES_EVENT(USB_Reset);\r
-\r
                /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */\r
                HANDLES_EVENT(USB_ConfigurationChanged);\r
 \r
index 39df2a1..3fc9bee 100644 (file)
  *\r
  *  <table>\r
  *   <tr>\r
- *    <td><b>Define Name:</b></td>\r
- *    <td><b>Location:</b></td>\r
- *    <td><b>Description:</b></td>\r
- *   </tr>\r
- *   <tr>\r
- *    <td>INTERRUPT_CONTROL_ENDPOINT</td>\r
- *    <td>Makefile CDEFS</td>\r
- *    <td>When defined, this causes the demo to enable interrupts for the control endpoint,\r
- *        which services control requests from the host. If not defined, the control endpoint\r
- *        is serviced via polling using the task scheduler.</td>\r
+ *    <td>\r
+ *     None\r
+ *    </td>\r
  *   </tr>\r
  *  </table>\r
  */\r
index b24018a..c50ca3d 100644 (file)
@@ -85,19 +85,6 @@ int main(void)
        Scheduler_Start();\r
 }\r
 \r
-/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the\r
- *  enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled\r
- *  asynchronously when they arrive rather than when the control endpoint is polled manually.\r
- */\r
-EVENT_HANDLER(USB_Reset)\r
-{\r
-       /* Select the control endpoint */\r
-       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
-\r
-       /* Enable the endpoint SETUP interrupt ISR for the control endpoint */\r
-       USB_INT_Enable(ENDPOINT_INT_SETUP);\r
-}\r
-\r
 /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */\r
 EVENT_HANDLER(USB_Connect)\r
 {\r
@@ -376,21 +363,3 @@ STREAM_CALLBACK(AbortOnMassStoreReset)
        /* Continue with the current stream operation */\r
        return STREAMCALLBACK_Continue;\r
 }\r
-\r
-/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when a control request has been issued to the control endpoint,\r
- *  so that the request can be processed. As several elements of the Mass Storage implementation require asynchronous control requests\r
- *  (such as endpoint stall clearing and Mass Storage Reset requests during data transfers) this is done via interrupts rather than\r
- *  polling so that they can be processed regardless of the rest of the application's state.\r
- */\r
-ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)\r
-{\r
-       /* Check if the control endpoint has received a request */\r
-       if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP))\r
-       {\r
-               /* Process the control request */\r
-               USB_USBTask();\r
-\r
-               /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */\r
-               USB_INT_Clear(ENDPOINT_INT_SETUP);\r
-       }\r
-}\r
index 17acca6..f0baf14 100644 (file)
                STREAM_CALLBACK(AbortOnMassStoreReset);\r
 \r
        /* Event Handlers: */\r
-               /** Indicates that this module will catch the USB_Reset event when thrown by the library. */\r
-               HANDLES_EVENT(USB_Reset);\r
-\r
                /** Indicates that this module will catch the USB_Connect event when thrown by the library. */\r
                HANDLES_EVENT(USB_Connect);\r
 \r
index 9db731c..1d06cb6 100644 (file)
  *  255), with each LUN being allocated an equal portion of the available\r
  *  Dataflash memory.\r
  *\r
+ *  The USB control endpoint is managed entirely by the library using endpoint\r
+ *  interrupts, as the INTERRUPT_CONTROL_ENDPOINT option is enabled. This allows for\r
+ *  the host to reset the Mass Storage device state during long transfers without\r
+ *  the need for complicated polling logic.\r
+ *\r
  *  \section SSec_Options Project Options\r
  *\r
  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.\r
index 3115aae..65a22c6 100644 (file)
@@ -189,6 +189,7 @@ CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_DEVICE_ONLY\r
 CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION\r
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"\r
+CDEFS += -DINTERRUPT_CONTROL_ENDPOINT\r
 \r
 \r
 # Place -D or -U options here for ASM sources\r
index 8998530..9dc2f9d 100644 (file)
 /* Scheduler Task List */\r
 TASK_LIST\r
 {\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        { .Task = USB_USBTask          , .TaskStatus = TASK_STOP },\r
-       #endif\r
-       \r
        { .Task = USB_Mouse_Report     , .TaskStatus = TASK_STOP },\r
 };\r
 \r
@@ -105,10 +102,8 @@ int main(void)
  */\r
 EVENT_HANDLER(USB_Connect)\r
 {\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        /* Start USB management task */\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);\r
-       #endif\r
        \r
        /* Indicate USB enumerating */\r
        UpdateStatus(Status_USBEnumerating);\r
@@ -117,21 +112,6 @@ EVENT_HANDLER(USB_Connect)
        UsingReportProtocol = true;\r
 }\r
 \r
-/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the\r
- *  enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled\r
- *  asynchronously when they arrive rather than when the control endpoint is polled manually.\r
- */\r
-EVENT_HANDLER(USB_Reset)\r
-{\r
-       #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-       /* Select the control endpoint */\r
-       Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
-\r
-       /* Enable the endpoint SETUP interrupt ISR for the control endpoint */\r
-       USB_INT_Enable(ENDPOINT_INT_SETUP);\r
-       #endif\r
-}\r
-\r
 /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via\r
  *  the status LEDs and stops the USB management and Mouse reporting tasks.\r
  */\r
@@ -139,10 +119,7 @@ EVENT_HANDLER(USB_Disconnect)
 {\r
        /* Stop running mouse reporting and USB management tasks */\r
        Scheduler_SetTaskMode(USB_Mouse_Report, TASK_STOP);\r
-\r
-       #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);\r
-       #endif\r
 \r
        /* Indicate USB not ready */\r
        UpdateStatus(Status_USBNotReady);\r
@@ -381,30 +358,3 @@ TASK(USB_Mouse_Report)
                SendNextReport();\r
        }\r
 }\r
-\r
-#if defined(INTERRUPT_CONTROL_ENDPOINT)\r
-/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when an endpoint's status changes (such as\r
- *  a packet has been received) on an endpoint with its corresponding ISR enabling bits set. This is used to send\r
- *  HID packets to the host each time the HID interrupt endpoints polling period elapses, as managed by the USB\r
- *  controller. It is also used to respond to standard and class specific requests send to the device on the control\r
- *  endpoint, by handing them off to the LUFA library when they are received.\r
- */\r
-ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)\r
-{\r
-       /* Save previously selected endpoint before selecting a new endpoint */\r
-       uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
-\r
-       /* Check if the control endpoint has received a request */\r
-       if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP))\r
-       {\r
-               /* Process the control request */\r
-               USB_USBTask();\r
-\r
-               /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */\r
-               USB_INT_Clear(ENDPOINT_INT_SETUP);\r
-       }\r
-\r
-       /* Restore previously selected endpoint */\r
-       Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
-}\r
-#endif\r
index afa5a6a..3bbbac2 100644 (file)
                /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */\r
                HANDLES_EVENT(USB_Disconnect);\r
 \r
-               /** Indicates that this module will catch the USB_Reset event when thrown by the library. */\r
-               HANDLES_EVENT(USB_Reset);\r
-\r
                /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */\r
                HANDLES_EVENT(USB_ConfigurationChanged);\r
 \r
index a3bf024..07982a7 100644 (file)
  *\r
  *  <table>\r
  *   <tr>\r
- *    <td><b>Define Name:</b></td>\r
- *    <td><b>Location:</b></td>\r
- *    <td><b>Description:</b></td>\r
- *   </tr>\r
- *   <tr>\r
- *    <td>INTERRUPT_CONTROL_ENDPOINT</td>\r
- *    <td>Makefile CDEFS</td>\r
- *    <td>When defined, this causes the demo to enable interrupts for the control endpoint,\r
- *        which services control requests from the host. If not defined, the control endpoint\r
- *        is serviced via polling using the task scheduler.</td>\r
+ *    <td>\r
+ *     None\r
+ *    </td>\r
  *   </tr>\r
  *  </table>\r
  */\r
index 5ac4257..580612c 100644 (file)
@@ -331,12 +331,6 @@ TASK(USB_HID_Host)
                                break;\r
                        }\r
                \r
-                       #if defined(INTERRUPT_DATA_PIPE)                                        \r
-                       /* Select and unfreeze HID data IN pipe */\r
-                       Pipe_SelectPipe(HID_DATA_IN_PIPE);\r
-                       Pipe_Unfreeze();\r
-                       #endif\r
-\r
                        puts_P(PSTR("HID Device Enumerated.\r\n"));\r
                                        \r
                        USB_HostState = HOST_STATE_Ready;\r
index d868055..be15e73 100644 (file)
@@ -14,6 +14,7 @@
   *  - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman)\r
   *  - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues\r
   *  - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman)\r
+  *  - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token\r
   *\r
   *\r
   *  \section Sec_ChangeLog090510 Version 090510\r
index e3afc59..bb235e1 100644 (file)
  *  required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_IsConnected global\r
  *  can be accurately set and the USB_Connect and USB_Disconnect events manually raised by the RAISE_EVENT macro. When defined, this token disables\r
  *  the library's auto-detection of the connection state by the aforementioned suspension and wake up events.\r
+ *\r
+ *  <b>INTERRUPT_CONTROL_ENDPOINT</b> - ( \ref Group_USBManagement ) \n\r
+ *  Some applications prefer to not call the USB_USBTask() management task reguarly while in device mode, as it can complicate code significantly.\r
+ *  Instead, when device mode is used this token can be passed to the library via the -D switch to allow the library to manage the USB control\r
+ *  endpoint entirely via interrupts asynchronously to the user application.\r
  */\r
index 93bd6d0..14d277c 100644 (file)
@@ -174,6 +174,10 @@ ISR(USB_GEN_vect, ISR_BLOCK)
                                           ENDPOINT_DIR_OUT, USB_ControlEndpointSize,\r
                                           ENDPOINT_BANK_SINGLE);\r
 \r
+               #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
+               USB_INT_Enable(USB_INT_ENDPOINT_SETUP);\r
+               #endif\r
+\r
                RAISE_EVENT(USB_Reset);\r
        }\r
        #endif\r
@@ -249,3 +253,16 @@ ISR(USB_GEN_vect, ISR_BLOCK)
        }\r
        #endif\r
 }\r
+\r
+#if defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ISR(USB_COM_vect, ISR_BLOCK)\r
+{\r
+       uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
+\r
+       USB_USBTask();\r
+\r
+       USB_INT_Clear(USB_INT_ENDPOINT_SETUP);\r
+       \r
+       Endpoint_SelectEndpoint(PrevSelectedEndpoint);  \r
+}\r
+#endif\r
index 9a16047..7fbb33e 100644 (file)
   this software.\r
 */\r
 \r
-/** \ingroup Group_USB\r
- *  @defgroup Group_USBInterrupt Endpoint and Pipe Interrupts\r
- *\r
- *  This module manages the main USB interrupt vector, for handling such events as VBUS interrupts\r
- *  (on supported USB AVR models), device connections and disconnections, etc. as well as providing\r
- *  easy to use macros for the management of the unified Endpoint/Pipe interrupt vector.\r
- *\r
- *  @{\r
- */\r
-\r
 #ifndef __USBINTERRUPT_H__\r
 #define __USBINTERRUPT_H__\r
 \r
                #endif\r
 \r
        /* Public Interface - May be used in end-application: */\r
-               /* Macros: */\r
-                       /** Vector name for the common endpoint and pipe vector. This can be used to write an ISR handler\r
-                        *  for the endpoint and pipe events, to make certain USB functions interrupt rather than poll\r
-                        *  driven.\r
-                        */\r
-                       #define ENDPOINT_PIPE_vect                       USB_COM_vect\r
-       \r
-                       /** Enables the given USB interrupt vector (such as the ENDPOINT_INT_* and PIPE_INT_* vectors in\r
-                        *  Endpoint.h and Pipe.h).\r
-                        */\r
-                       #define USB_INT_Enable(int)              MACROS{ USB_INT_GET_EN_REG(int)   |=   USB_INT_GET_EN_MASK(int);   }MACROE\r
-\r
-                       /** Disables the given USB interrupt vector.\r
-                        *\r
-                        *  \see \ref USB_INT_Enable()\r
-                        */\r
-                       #define USB_INT_Disable(int)             MACROS{ USB_INT_GET_EN_REG(int)   &= ~(USB_INT_GET_EN_MASK(int));  }MACROE\r
-\r
-                       /** Resets the given USB interrupt flag, so that the interrupt is re-primed for the next firing. */\r
-                       #define USB_INT_Clear(int)               MACROS{ USB_INT_GET_INT_REG(int)  &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
-                       \r
-                       /** Returns boolean false if the given USB interrupt is disabled, or true if the interrupt is currently\r
-                        *  enabled.\r
-                        */\r
-                       #define USB_INT_IsEnabled(int)                 ((USB_INT_GET_EN_REG(int)   &    USB_INT_GET_EN_MASK(int)) ? true : false)\r
-\r
-                       /** Returns boolean true if the given interrupt flag is set (i.e. the condition for the interrupt has occurred,\r
-                        *  but the interrupt vector is not necessarily enabled), otherwise returns false.\r
-                        */\r
-                       #define USB_INT_HasOccurred(int)               ((USB_INT_GET_INT_REG(int)  &    USB_INT_GET_INT_MASK(int)) ? true : false)\r
-               \r
                /* Throwable Events: */\r
                        /** This module raises the USB Connected interrupt when the AVR is attached to a host while in device\r
                         *  USB mode.\r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Macros: */\r
+                       #define USB_INT_Enable(int)              MACROS{ USB_INT_GET_EN_REG(int)   |=   USB_INT_GET_EN_MASK(int);   }MACROE\r
+                       #define USB_INT_Disable(int)             MACROS{ USB_INT_GET_EN_REG(int)   &= ~(USB_INT_GET_EN_MASK(int));  }MACROE\r
+                       #define USB_INT_Clear(int)               MACROS{ USB_INT_GET_INT_REG(int)  &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
+                       #define USB_INT_IsEnabled(int)                 ((USB_INT_GET_EN_REG(int)   &    USB_INT_GET_EN_MASK(int)) ? true : false)\r
+                       #define USB_INT_HasOccurred(int)               ((USB_INT_GET_INT_REG(int)  &    USB_INT_GET_INT_MASK(int)) ? true : false)\r
+\r
                        #define USB_INT_GET_EN_REG(a, b, c, d)           a\r
                        #define USB_INT_GET_EN_MASK(a, b, c, d)          b\r
                        #define USB_INT_GET_INT_REG(a, b, c, d)          c\r
                        #define USB_INT_HSOFI                            UHIEN,  (1 << HSOFE)  , UHINT , (1 << HSOFI)\r
                        #define USB_INT_RSTI                             UHIEN , (1 << RSTE)   , UHINT , (1 << RSTI)\r
                        #define USB_INT_SRPI                             OTGIEN, (1 << SRPE)   , OTGINT, (1 << SRPI)\r
+                       #define USB_INT_ENDPOINT_SETUP                   UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)\r
        \r
                /* Function Prototypes: */\r
                        void USB_INT_ClearAllInterrupts(void);\r
                #endif\r
 \r
 #endif\r
-\r
-/** @} */\r
index 1718ed6..9cb4e60 100644 (file)
                         *    - In host mode, it may be disabled at start-up, enabled on the firing of the \ref USB_DeviceAttached\r
                         *    event and disabled again on the firing of the \ref USB_DeviceUnattached event.\r
                         *\r
+                        *  If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library\r
+                        *  by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.\r
+                        *\r
                         *  \see \ref Group_Events for more information on the USB events.\r
                         *\r
                         *  \ingroup Group_USBManagement\r
index 4882acc..9a553d3 100644 (file)
                        #else\r
                                #define ENDPOINT_TOTAL_ENDPOINTS              1\r
                        #endif\r
-\r
-                       /** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be\r
-                        *  used with the USB_INT_* macros located in USBInterrupt.h.\r
-                        *\r
-                        *  This interrupt will fire if enabled on a CONTROL type endpoint if a new control packet is\r
-                        *  received from the host.\r
-                        *\r
-                        *  \note This interrupt must be enabled and cleared on *each* endpoint which requires it (after the\r
-                        *        endpoint is selected), and will fire the common endpoint interrupt vector.\r
-                        *\r
-                        *  \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
-                        */\r
-                       #define ENDPOINT_INT_SETUP                    UEIENX, (1 << RXSTPE), UEINTX, (1 << RXSTPI)\r
                        \r
                /* Pseudo-Function Macros: */\r
                        #if defined(__DOXYGEN__)\r
index d5c2094..796b4c5 100644 (file)
                         */\r
                        #define PIPE_EPSIZE_MASK                0x7FF\r
 \r
-                       /** Interrupt definition for the pipe SETUP bank ready interrupt (for CONTROL type pipes). Should be\r
-                        *  used with the USB_INT_* macros located in USBInterrupt.h.\r
-                        *\r
-                        *  This interrupt will fire if enabled on an CONTROL type pipe when the pipe is ready for a new\r
-                        *  control request.\r
-                        *\r
-                        *  \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe\r
-                        *        is selected), and will fire the common pipe interrupt vector.\r
-                        *\r
-                        *  \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
-                        */\r
-                       #define PIPE_INT_SETUP                 UPIENX, (1 << TXSTPE) , UPINTX, (1 << TXSTPI)\r
-\r
-                       /** Interrupt definition for the pipe error interrupt. Should be used with the USB_INT_* macros\r
-                        *  located in USBInterrupt.h.\r
-                        *\r
-                        *  This interrupt will fire if enabled on a particular pipe if an error occurs on that pipe, such\r
-                        *  as a CRC mismatch error.\r
-                        *\r
-                        *  \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe\r
-                        *        is selected), and will fire the common pipe interrupt vector.\r
-                        *\r
-                        *  \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
-                        *\r
-                        *  \see \ref Pipe_GetErrorFlags() for more information on the pipe errors.\r
-                        */\r
-                       #define PIPE_INT_ERROR                 UPIENX, (1 << PERRE), UPINTX, (1 << PERRI)\r
-\r
-                       /** Interrupt definition for the pipe NAK received interrupt. Should be used with the USB_INT_* macros\r
-                        *  located in USBInterrupt.h.\r
-                        *\r
-                        *  This interrupt will fire if enabled on a particular pipe if an attached device returns a NAK in\r
-                        *  response to a sent packet.\r
-                        *\r
-                        *  \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe\r
-                        *        is selected), and will fire the common pipe interrupt vector.\r
-                        *\r
-                        *  \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
-                        *\r
-                        *  \see \ref Pipe_IsNAKReceived() for more information on pipe NAKs.\r
-                        */\r
-                       #define PIPE_INT_NAK                   UPIENX, (1 << NAKEDE), UPINTX, (1 << NAKEDI)\r
-\r
-                       /** Interrupt definition for the pipe STALL received interrupt. Should be used with the USB_INT_* macros\r
-                        *  located in USBInterrupt.h.\r
-                        *\r
-                        *  This interrupt will fire if enabled on a particular pipe if an attached device returns a STALL on the\r
-                        *  currently selected pipe. This will also fire if the pipe is an isochronous pipe and a CRC error occurs.\r
-                        *\r
-                        *  \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe\r
-                        *        is selected), and will fire the common pipe interrupt vector.\r
-                        *\r
-                        *  \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
-                        */\r
-                       #define PIPE_INT_STALL                 UPIENX, (1 << RXSTALLE), UPINTX, (1 << RXSTALLI)\r
-\r
                /* Pseudo-Function Macros: */\r
                        #if defined(__DOXYGEN__)\r
                                /** Indicates the number of bytes currently stored in the current pipes's selected bank.\r
index d7eb2df..c1a2e3c 100644 (file)
@@ -14,7 +14,8 @@
  *\r
  *  <b>Device Mode</b>\r
  *    - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing\r
- *      projects using interrupts on non-control endpoints should switch to polling.\r
+ *      projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can\r
+ *      manage the control endpoint via interrupts automatically by compiling with the INTERRUPT_CONTROL_ENDPOINT token defined.\r
  *    - The Endpoint_ClearEndpointInterrupt() macro has been deleted and references to it should be removed.\r
  *\r
  *  <b>Device Mode</b>\r