diff --git a/Demos/Device/GenericHID/GenericHID.c b/Demos/Device/GenericHID/GenericHID.c index d4e7cca732..0369f9f521 100644 --- a/Demos/Device/GenericHID/GenericHID.c +++ b/Demos/Device/GenericHID/GenericHID.c @@ -39,10 +39,7 @@ /* Scheduler Task List */ TASK_LIST { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) { .Task = USB_USBTask , .TaskStatus = TASK_STOP }, - #endif - { .Task = USB_HID_Report , .TaskStatus = TASK_STOP }, }; @@ -75,30 +72,13 @@ int main(void) Scheduler_Start(); } -/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the - * enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled - * asynchronously when they arrive rather than when the control endpoint is polled manually. - */ -EVENT_HANDLER(USB_Reset) -{ - #if defined(INTERRUPT_CONTROL_ENDPOINT) - /* Select the control endpoint */ - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - /* Enable the endpoint SETUP interrupt ISR for the control endpoint */ - USB_INT_Enable(ENDPOINT_INT_SETUP); - #endif -} - /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ EVENT_HANDLER(USB_Connect) { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); - #endif /* Indicate USB enumerating */ UpdateStatus(Status_USBEnumerating); @@ -111,10 +91,7 @@ EVENT_HANDLER(USB_Disconnect) { /* Stop running HID reporting and USB management tasks */ Scheduler_SetTaskMode(USB_HID_Report, TASK_STOP); - - #if !defined(INTERRUPT_CONTROL_ENDPOINT) Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); - #endif /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); @@ -298,32 +275,3 @@ TASK(USB_HID_Report) } } } - -#if defined(INTERRUPT_CONTROL_ENDPOINT) -/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when an endpoint's status changes (such as - * a packet has been received) on an endpoint with its corresponding ISR enabling bits set. This is used to send - * HID packets to the host each time the HID interrupt endpoints polling period elapses, as managed by the USB - * controller. - */ -ISR(ENDPOINT_PIPE_vect, ISR_BLOCK) -{ - /* Save previously selected endpoint before selecting a new endpoint */ - uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); - - /* Check if the control endpoint has received a request */ - if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP)) - { - /* Clear the endpoint interrupt */ - Endpoint_ClearEndpointInterrupt(ENDPOINT_CONTROLEP); - - /* Process the control request */ - USB_USBTask(); - - /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */ - USB_INT_Clear(ENDPOINT_INT_SETUP); - } - - /* Restore previously selected endpoint */ - Endpoint_SelectEndpoint(PrevSelectedEndpoint); -} -#endif diff --git a/Demos/Device/GenericHID/GenericHID.h b/Demos/Device/GenericHID/GenericHID.h index 817d377481..5841595e34 100644 --- a/Demos/Device/GenericHID/GenericHID.h +++ b/Demos/Device/GenericHID/GenericHID.h @@ -68,9 +68,6 @@ }; /* Event Handlers: */ - /** Indicates that this module will catch the USB_Reset event when thrown by the library. */ - HANDLES_EVENT(USB_Reset); - /** Indicates that this module will catch the USB_Connect event when thrown by the library. */ HANDLES_EVENT(USB_Connect); diff --git a/Demos/Device/GenericHID/GenericHID.txt b/Demos/Device/GenericHID/GenericHID.txt index c78f637539..a40b78b1f3 100644 --- a/Demos/Device/GenericHID/GenericHID.txt +++ b/Demos/Device/GenericHID/GenericHID.txt @@ -60,12 +60,5 @@ * This token defines the size of the device reports, both sent and received. The value must be an * integer ranging from 1 to 255. * - * - * INTERRUPT_CONTROL_ENDPOINT - * Makefile CDEFS - * When defined, this causes the demo to enable interrupts for the control endpoint, - * which services control requests from the host. If not defined, the control endpoint - * is serviced via polling using the task scheduler. - * * */ diff --git a/Demos/Device/Keyboard/Keyboard.c b/Demos/Device/Keyboard/Keyboard.c index 928d95b624..fe041ef086 100644 --- a/Demos/Device/Keyboard/Keyboard.c +++ b/Demos/Device/Keyboard/Keyboard.c @@ -40,10 +40,7 @@ /* Scheduler Task List */ TASK_LIST { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) - { .Task = USB_USBTask , .TaskStatus = TASK_STOP }, - #endif - + { .Task = USB_USBTask , .TaskStatus = TASK_STOP }, { .Task = USB_Keyboard_Report , .TaskStatus = TASK_STOP }, }; @@ -105,10 +102,8 @@ int main(void) */ EVENT_HANDLER(USB_Connect) { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); - #endif /* Indicate USB enumerating */ UpdateStatus(Status_USBEnumerating); @@ -117,21 +112,6 @@ EVENT_HANDLER(USB_Connect) UsingReportProtocol = true; } -/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the - * enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled - * asynchronously when they arrive rather than when the control endpoint is polled manually. - */ -EVENT_HANDLER(USB_Reset) -{ - #if defined(INTERRUPT_CONTROL_ENDPOINT) - /* Select the control endpoint */ - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - /* Enable the endpoint SETUP interrupt ISR for the control endpoint */ - USB_INT_Enable(ENDPOINT_INT_SETUP); - #endif -} - /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs. */ @@ -139,10 +119,7 @@ EVENT_HANDLER(USB_Disconnect) { /* Stop running keyboard reporting and USB management tasks */ Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP); - - #if !defined(INTERRUPT_CONTROL_ENDPOINT) Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); - #endif /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); @@ -445,30 +422,3 @@ TASK(USB_Keyboard_Report) ReceiveNextReport(); } } - -#if defined(INTERRUPT_CONTROL_ENDPOINT) -/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when an endpoint's status changes (such as - * a packet has been received) on an endpoint with its corresponding ISR enabling bits set. This is used to send - * HID packets to the host each time the HID interrupt endpoints polling period elapses, as managed by the USB - * controller. It is also used to respond to standard and class specific requests send to the device on the control - * endpoint, by handing them off to the LUFA library when they are received. - */ -ISR(ENDPOINT_PIPE_vect, ISR_BLOCK) -{ - /* Save previously selected endpoint before selecting a new endpoint */ - uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); - - /* Check if the control endpoint has received a request */ - if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP)) - { - /* Process the control request */ - USB_USBTask(); - - /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */ - USB_INT_Clear(ENDPOINT_INT_SETUP); - } - - /* Restore previously selected endpoint */ - Endpoint_SelectEndpoint(PrevSelectedEndpoint); -} -#endif diff --git a/Demos/Device/Keyboard/Keyboard.h b/Demos/Device/Keyboard/Keyboard.h index c73701905c..2cc9c5ca8e 100644 --- a/Demos/Device/Keyboard/Keyboard.h +++ b/Demos/Device/Keyboard/Keyboard.h @@ -105,9 +105,6 @@ /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */ HANDLES_EVENT(USB_Disconnect); - /** Indicates that this module will catch the USB_Reset event when thrown by the library. */ - HANDLES_EVENT(USB_Reset); - /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */ HANDLES_EVENT(USB_ConfigurationChanged); diff --git a/Demos/Device/Keyboard/Keyboard.txt b/Demos/Device/Keyboard/Keyboard.txt index 39df2a1714..3fc9bee3a1 100644 --- a/Demos/Device/Keyboard/Keyboard.txt +++ b/Demos/Device/Keyboard/Keyboard.txt @@ -52,16 +52,9 @@ * * * - * - * - * - * - * - * - * - * + * * *
Define Name:Location:Description:
INTERRUPT_CONTROL_ENDPOINTMakefile CDEFSWhen defined, this causes the demo to enable interrupts for the control endpoint, - * which services control requests from the host. If not defined, the control endpoint - * is serviced via polling using the task scheduler. + * None + *
*/ diff --git a/Demos/Device/MassStorage/MassStorage.c b/Demos/Device/MassStorage/MassStorage.c index b24018a10e..c50ca3ddee 100644 --- a/Demos/Device/MassStorage/MassStorage.c +++ b/Demos/Device/MassStorage/MassStorage.c @@ -85,19 +85,6 @@ int main(void) Scheduler_Start(); } -/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the - * enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled - * asynchronously when they arrive rather than when the control endpoint is polled manually. - */ -EVENT_HANDLER(USB_Reset) -{ - /* Select the control endpoint */ - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - /* Enable the endpoint SETUP interrupt ISR for the control endpoint */ - USB_INT_Enable(ENDPOINT_INT_SETUP); -} - /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */ EVENT_HANDLER(USB_Connect) { @@ -376,21 +363,3 @@ STREAM_CALLBACK(AbortOnMassStoreReset) /* Continue with the current stream operation */ return STREAMCALLBACK_Continue; } - -/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when a control request has been issued to the control endpoint, - * so that the request can be processed. As several elements of the Mass Storage implementation require asynchronous control requests - * (such as endpoint stall clearing and Mass Storage Reset requests during data transfers) this is done via interrupts rather than - * polling so that they can be processed regardless of the rest of the application's state. - */ -ISR(ENDPOINT_PIPE_vect, ISR_BLOCK) -{ - /* Check if the control endpoint has received a request */ - if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP)) - { - /* Process the control request */ - USB_USBTask(); - - /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */ - USB_INT_Clear(ENDPOINT_INT_SETUP); - } -} diff --git a/Demos/Device/MassStorage/MassStorage.h b/Demos/Device/MassStorage/MassStorage.h index 17acca6b7f..f0baf1461f 100644 --- a/Demos/Device/MassStorage/MassStorage.h +++ b/Demos/Device/MassStorage/MassStorage.h @@ -134,9 +134,6 @@ STREAM_CALLBACK(AbortOnMassStoreReset); /* Event Handlers: */ - /** Indicates that this module will catch the USB_Reset event when thrown by the library. */ - HANDLES_EVENT(USB_Reset); - /** Indicates that this module will catch the USB_Connect event when thrown by the library. */ HANDLES_EVENT(USB_Connect); diff --git a/Demos/Device/MassStorage/MassStorage.txt b/Demos/Device/MassStorage/MassStorage.txt index 9db731c31e..1d06cb66d0 100644 --- a/Demos/Device/MassStorage/MassStorage.txt +++ b/Demos/Device/MassStorage/MassStorage.txt @@ -58,6 +58,11 @@ * 255), with each LUN being allocated an equal portion of the available * Dataflash memory. * + * The USB control endpoint is managed entirely by the library using endpoint + * interrupts, as the INTERRUPT_CONTROL_ENDPOINT option is enabled. This allows for + * the host to reset the Mass Storage device state during long transfers without + * the need for complicated polling logic. + * * \section SSec_Options Project Options * * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. diff --git a/Demos/Device/MassStorage/makefile b/Demos/Device/MassStorage/makefile index 3115aae161..65a22c6a32 100644 --- a/Demos/Device/MassStorage/makefile +++ b/Demos/Device/MassStorage/makefile @@ -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 CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" +CDEFS += -DINTERRUPT_CONTROL_ENDPOINT # Place -D or -U options here for ASM sources diff --git a/Demos/Device/Mouse/Mouse.c b/Demos/Device/Mouse/Mouse.c index 8998530d89..9dc2f9d04e 100644 --- a/Demos/Device/Mouse/Mouse.c +++ b/Demos/Device/Mouse/Mouse.c @@ -39,10 +39,7 @@ /* Scheduler Task List */ TASK_LIST { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) { .Task = USB_USBTask , .TaskStatus = TASK_STOP }, - #endif - { .Task = USB_Mouse_Report , .TaskStatus = TASK_STOP }, }; @@ -105,10 +102,8 @@ int main(void) */ EVENT_HANDLER(USB_Connect) { - #if !defined(INTERRUPT_CONTROL_ENDPOINT) /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); - #endif /* Indicate USB enumerating */ UpdateStatus(Status_USBEnumerating); @@ -117,21 +112,6 @@ EVENT_HANDLER(USB_Connect) UsingReportProtocol = true; } -/** Event handler for the USB_Reset event. This fires when the USB interface is reset by the USB host, before the - * enumeration process begins, and enables the control endpoint interrupt so that control requests can be handled - * asynchronously when they arrive rather than when the control endpoint is polled manually. - */ -EVENT_HANDLER(USB_Reset) -{ - #if defined(INTERRUPT_CONTROL_ENDPOINT) - /* Select the control endpoint */ - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - /* Enable the endpoint SETUP interrupt ISR for the control endpoint */ - USB_INT_Enable(ENDPOINT_INT_SETUP); - #endif -} - /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and Mouse reporting tasks. */ @@ -139,10 +119,7 @@ EVENT_HANDLER(USB_Disconnect) { /* Stop running mouse reporting and USB management tasks */ Scheduler_SetTaskMode(USB_Mouse_Report, TASK_STOP); - - #if !defined(INTERRUPT_CONTROL_ENDPOINT) Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); - #endif /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); @@ -381,30 +358,3 @@ TASK(USB_Mouse_Report) SendNextReport(); } } - -#if defined(INTERRUPT_CONTROL_ENDPOINT) -/** ISR for the general Pipe/Endpoint interrupt vector. This ISR fires when an endpoint's status changes (such as - * a packet has been received) on an endpoint with its corresponding ISR enabling bits set. This is used to send - * HID packets to the host each time the HID interrupt endpoints polling period elapses, as managed by the USB - * controller. It is also used to respond to standard and class specific requests send to the device on the control - * endpoint, by handing them off to the LUFA library when they are received. - */ -ISR(ENDPOINT_PIPE_vect, ISR_BLOCK) -{ - /* Save previously selected endpoint before selecting a new endpoint */ - uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); - - /* Check if the control endpoint has received a request */ - if (Endpoint_HasEndpointInterrupted(ENDPOINT_CONTROLEP)) - { - /* Process the control request */ - USB_USBTask(); - - /* Handshake the endpoint setup interrupt - must be after the call to USB_USBTask() */ - USB_INT_Clear(ENDPOINT_INT_SETUP); - } - - /* Restore previously selected endpoint */ - Endpoint_SelectEndpoint(PrevSelectedEndpoint); -} -#endif diff --git a/Demos/Device/Mouse/Mouse.h b/Demos/Device/Mouse/Mouse.h index afa5a6a55d..3bbbac2346 100644 --- a/Demos/Device/Mouse/Mouse.h +++ b/Demos/Device/Mouse/Mouse.h @@ -105,9 +105,6 @@ /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */ HANDLES_EVENT(USB_Disconnect); - /** Indicates that this module will catch the USB_Reset event when thrown by the library. */ - HANDLES_EVENT(USB_Reset); - /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */ HANDLES_EVENT(USB_ConfigurationChanged); diff --git a/Demos/Device/Mouse/Mouse.txt b/Demos/Device/Mouse/Mouse.txt index a3bf024d5f..07982a713b 100644 --- a/Demos/Device/Mouse/Mouse.txt +++ b/Demos/Device/Mouse/Mouse.txt @@ -53,16 +53,9 @@ * * * - * - * - * - * - * - * - * - * + * * *
Define Name:Location:Description:
INTERRUPT_CONTROL_ENDPOINTMakefile CDEFSWhen defined, this causes the demo to enable interrupts for the control endpoint, - * which services control requests from the host. If not defined, the control endpoint - * is serviced via polling using the task scheduler. + * None + *
*/ diff --git a/Demos/Host/GenericHIDHost/GenericHIDHost.c b/Demos/Host/GenericHIDHost/GenericHIDHost.c index 5ac4257a6a..580612c972 100644 --- a/Demos/Host/GenericHIDHost/GenericHIDHost.c +++ b/Demos/Host/GenericHIDHost/GenericHIDHost.c @@ -331,12 +331,6 @@ TASK(USB_HID_Host) break; } - #if defined(INTERRUPT_DATA_PIPE) - /* Select and unfreeze HID data IN pipe */ - Pipe_SelectPipe(HID_DATA_IN_PIPE); - Pipe_Unfreeze(); - #endif - puts_P(PSTR("HID Device Enumerated.\r\n")); USB_HostState = HOST_STATE_Ready; diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index d868055782..be15e73f87 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -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) * - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues * - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman) + * - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token * * * \section Sec_ChangeLog090510 Version 090510 diff --git a/LUFA/CompileTimeTokens.txt b/LUFA/CompileTimeTokens.txt index e3afc59bde..bb235e1722 100644 --- a/LUFA/CompileTimeTokens.txt +++ b/LUFA/CompileTimeTokens.txt @@ -158,4 +158,9 @@ * 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 * can be accurately set and the USB_Connect and USB_Disconnect events manually raised by the RAISE_EVENT macro. When defined, this token disables * the library's auto-detection of the connection state by the aforementioned suspension and wake up events. + * + * INTERRUPT_CONTROL_ENDPOINT - ( \ref Group_USBManagement ) \n + * Some applications prefer to not call the USB_USBTask() management task reguarly while in device mode, as it can complicate code significantly. + * 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 + * endpoint entirely via interrupts asynchronously to the user application. */ diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c index 93bd6d084b..14d277c9a4 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c @@ -174,6 +174,10 @@ ISR(USB_GEN_vect, ISR_BLOCK) ENDPOINT_DIR_OUT, USB_ControlEndpointSize, ENDPOINT_BANK_SINGLE); + #if defined(INTERRUPT_CONTROL_ENDPOINT) + USB_INT_Enable(USB_INT_ENDPOINT_SETUP); + #endif + RAISE_EVENT(USB_Reset); } #endif @@ -249,3 +253,16 @@ ISR(USB_GEN_vect, ISR_BLOCK) } #endif } + +#if defined(INTERRUPT_CONTROL_ENDPOINT) +ISR(USB_COM_vect, ISR_BLOCK) +{ + uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); + + USB_USBTask(); + + USB_INT_Clear(USB_INT_ENDPOINT_SETUP); + + Endpoint_SelectEndpoint(PrevSelectedEndpoint); +} +#endif diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h index 9a16047030..7fbb33efc8 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.h +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.h @@ -28,16 +28,6 @@ this software. */ -/** \ingroup Group_USB - * @defgroup Group_USBInterrupt Endpoint and Pipe Interrupts - * - * This module manages the main USB interrupt vector, for handling such events as VBUS interrupts - * (on supported USB AVR models), device connections and disconnections, etc. as well as providing - * easy to use macros for the management of the unified Endpoint/Pipe interrupt vector. - * - * @{ - */ - #ifndef __USBINTERRUPT_H__ #define __USBINTERRUPT_H__ @@ -56,37 +46,6 @@ #endif /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Vector name for the common endpoint and pipe vector. This can be used to write an ISR handler - * for the endpoint and pipe events, to make certain USB functions interrupt rather than poll - * driven. - */ - #define ENDPOINT_PIPE_vect USB_COM_vect - - /** Enables the given USB interrupt vector (such as the ENDPOINT_INT_* and PIPE_INT_* vectors in - * Endpoint.h and Pipe.h). - */ - #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE - - /** Disables the given USB interrupt vector. - * - * \see \ref USB_INT_Enable() - */ - #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE - - /** Resets the given USB interrupt flag, so that the interrupt is re-primed for the next firing. */ - #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE - - /** Returns boolean false if the given USB interrupt is disabled, or true if the interrupt is currently - * enabled. - */ - #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false) - - /** Returns boolean true if the given interrupt flag is set (i.e. the condition for the interrupt has occurred, - * but the interrupt vector is not necessarily enabled), otherwise returns false. - */ - #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false) - /* Throwable Events: */ /** This module raises the USB Connected interrupt when the AVR is attached to a host while in device * USB mode. @@ -196,6 +155,12 @@ /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ + #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE + #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE + #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE + #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false) + #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false) + #define USB_INT_GET_EN_REG(a, b, c, d) a #define USB_INT_GET_EN_MASK(a, b, c, d) b #define USB_INT_GET_INT_REG(a, b, c, d) c @@ -214,6 +179,7 @@ #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI) #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI) #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI) + #define USB_INT_ENDPOINT_SETUP UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI) /* Function Prototypes: */ void USB_INT_ClearAllInterrupts(void); @@ -226,5 +192,3 @@ #endif #endif - -/** @} */ diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h index 1718ed6916..9cb4e60597 100644 --- a/LUFA/Drivers/USB/HighLevel/USBTask.h +++ b/LUFA/Drivers/USB/HighLevel/USBTask.h @@ -183,6 +183,9 @@ * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref USB_DeviceAttached * event and disabled again on the firing of the \ref USB_DeviceUnattached event. * + * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library + * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch. + * * \see \ref Group_Events for more information on the USB events. * * \ingroup Group_USBManagement diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 4882acc3b7..9a553d33ff 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -140,19 +140,6 @@ #else #define ENDPOINT_TOTAL_ENDPOINTS 1 #endif - - /** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be - * used with the USB_INT_* macros located in USBInterrupt.h. - * - * This interrupt will fire if enabled on a CONTROL type endpoint if a new control packet is - * received from the host. - * - * \note This interrupt must be enabled and cleared on *each* endpoint which requires it (after the - * endpoint is selected), and will fire the common endpoint interrupt vector. - * - * \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector. - */ - #define ENDPOINT_INT_SETUP UEIENX, (1 << RXSTPE), UEINTX, (1 << RXSTPI) /* Pseudo-Function Macros: */ #if defined(__DOXYGEN__) diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index d5c2094926..796b4c5a26 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -158,62 +158,6 @@ */ #define PIPE_EPSIZE_MASK 0x7FF - /** Interrupt definition for the pipe SETUP bank ready interrupt (for CONTROL type pipes). Should be - * used with the USB_INT_* macros located in USBInterrupt.h. - * - * This interrupt will fire if enabled on an CONTROL type pipe when the pipe is ready for a new - * control request. - * - * \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe - * is selected), and will fire the common pipe interrupt vector. - * - * \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector. - */ - #define PIPE_INT_SETUP UPIENX, (1 << TXSTPE) , UPINTX, (1 << TXSTPI) - - /** Interrupt definition for the pipe error interrupt. Should be used with the USB_INT_* macros - * located in USBInterrupt.h. - * - * This interrupt will fire if enabled on a particular pipe if an error occurs on that pipe, such - * as a CRC mismatch error. - * - * \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe - * is selected), and will fire the common pipe interrupt vector. - * - * \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector. - * - * \see \ref Pipe_GetErrorFlags() for more information on the pipe errors. - */ - #define PIPE_INT_ERROR UPIENX, (1 << PERRE), UPINTX, (1 << PERRI) - - /** Interrupt definition for the pipe NAK received interrupt. Should be used with the USB_INT_* macros - * located in USBInterrupt.h. - * - * This interrupt will fire if enabled on a particular pipe if an attached device returns a NAK in - * response to a sent packet. - * - * \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe - * is selected), and will fire the common pipe interrupt vector. - * - * \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector. - * - * \see \ref Pipe_IsNAKReceived() for more information on pipe NAKs. - */ - #define PIPE_INT_NAK UPIENX, (1 << NAKEDE), UPINTX, (1 << NAKEDI) - - /** Interrupt definition for the pipe STALL received interrupt. Should be used with the USB_INT_* macros - * located in USBInterrupt.h. - * - * This interrupt will fire if enabled on a particular pipe if an attached device returns a STALL on the - * currently selected pipe. This will also fire if the pipe is an isochronous pipe and a CRC error occurs. - * - * \note This interrupt must be enabled and cleared on *each* pipe which requires it (after the pipe - * is selected), and will fire the common pipe interrupt vector. - * - * \see \ref ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector. - */ - #define PIPE_INT_STALL UPIENX, (1 << RXSTALLE), UPINTX, (1 << RXSTALLI) - /* Pseudo-Function Macros: */ #if defined(__DOXYGEN__) /** Indicates the number of bytes currently stored in the current pipes's selected bank. diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt index d7eb2dfcc5..c1a2e3c430 100644 --- a/LUFA/MigrationInformation.txt +++ b/LUFA/MigrationInformation.txt @@ -14,7 +14,8 @@ * * Device Mode * - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing - * projects using interrupts on non-control endpoints should switch to polling. + * projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can + * manage the control endpoint via interrupts automatically by compiling with the INTERRUPT_CONTROL_ENDPOINT token defined. * - The Endpoint_ClearEndpointInterrupt() macro has been deleted and references to it should be removed. * * Device Mode