diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-05-14 10:07:08 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-05-14 10:07:08 +0000 |
commit | 32f0f605efa293430a47d60bb857695ff6937d21 (patch) | |
tree | 9ab514c6088c9f044c029fdf36c880ecdf700a71 /LUFA/Drivers | |
parent | 0d5baf9bb3e88ebcbc53cc9a71566582d585f7dd (diff) | |
download | lufa-32f0f605efa293430a47d60bb857695ff6937d21.tar.gz lufa-32f0f605efa293430a47d60bb857695ff6937d21.tar.bz2 lufa-32f0f605efa293430a47d60bb857695ff6937d21.zip |
Removed all user pipe/endpoint interrupt APIs, added internal library support for interrupt driven control endpoints when in device mode by defining INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBInterrupt.c | 17 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBInterrupt.h | 50 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBTask.h | 3 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.h | 13 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.h | 56 |
5 files changed, 27 insertions, 112 deletions
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c index 93bd6d084..14d277c9a 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 9a1604703..7fbb33efc 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 1718ed691..9cb4e6059 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 4882acc3b..9a553d33f 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 d5c209492..796b4c5a2 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.
|