Add LUFA-111009-BETA tag.
[pub/USBasp.git] / LUFA / Platform / UC3 / InterruptManagement.h
index 67dc3ea..dd70675 100644 (file)
-/*\r
-             LUFA Library\r
-     Copyright (C) Dean Camera, 2011.\r
-\r
-  dean [at] fourwalledcubicle [dot] com\r
-           www.lufa-lib.org\r
-*/\r
-\r
-/*\r
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
-  Permission to use, copy, modify, distribute, and sell this\r
-  software and its documentation for any purpose is hereby granted\r
-  without fee, provided that the above copyright notice appear in\r
-  all copies and that both that the copyright notice and this\r
-  permission notice and warranty disclaimer appear in supporting\r
-  documentation, and that the name of the author not be used in\r
-  advertising or publicity pertaining to distribution of the\r
-  software without specific, written prior permission.\r
-\r
-  The author disclaim all warranties with regard to this\r
-  software, including all implied warranties of merchantability\r
-  and fitness.  In no event shall the author be liable for any\r
-  special, indirect or consequential damages or any damages\r
-  whatsoever resulting from loss of use, data or profits, whether\r
-  in an action of contract, negligence or other tortious action,\r
-  arising out of or in connection with the use or performance of\r
-  this software.\r
-*/\r
-\r
-/** \file\r
- *  \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers.\r
- *\r
- *  Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt\r
- *  handlers within the device.\r
- */\r
-\r
-/** \ingroup Group_PlatformDrivers\r
- *  \defgroup Group_PlatformDrivers_UC3Interrupts UC3 Interrupt Controller Driver - LUFA/Platform/UC3/InterruptManagement.h\r
- *  \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers.\r
- *\r
- *  \section Sec_Dependencies Module Source Dependencies\r
- *  The following files must be built with any user project that uses this module:\r
- *    - LUFA/Platform/UC3/InterruptManagement.c\r
- *    - LUFA/Platform/UC3/Exception.S\r
- *\r
- *  \section Sec_ModDescription Module Description\r
- *  Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt\r
- *  handlers within the device.\r
- *\r
- *  Usage Example:\r
- *  \code\r
- *             #include <LUFA/Platform/UC3/InterruptManagement.h>\r
- *\r
- *             ISR(USB_Group_IRQ_Handler)\r
- *             {\r
- *                     // USB group handler code here\r
- *             }\r
- *\r
- *             void main(void)\r
- *             {\r
- *                     INTC_Init();\r
- *                     INTC_RegisterGroupHandler(INTC_IRQ_GROUP(AVR32_USBB_IRQ), AVR32_INTC_INT0, USB_Group_IRQ_Handler);\r
- *             }\r
- *  \endcode\r
- *\r
- *  @{\r
- */\r
-\r
-#ifndef _UC3_INTERRUPT_MANAGEMENT_H_\r
-#define _UC3_INTERRUPT_MANAGEMENT_H_\r
-\r
-       /* Includes: */\r
-               #include <LUFA/Common/Common.h>\r
-\r
-       /* Enable C linkage for C++ Compilers: */\r
-               #if defined(__cplusplus)\r
-                       extern "C" {\r
-               #endif\r
-\r
-       /* Private Interface - For use in library only: */\r
-       #if !defined(__DOXYGEN__)\r
-               /* Type Defines: */\r
-                       typedef void (*InterruptHandlerPtr_t)(void);\r
-\r
-               /* External Variables: */\r
-                       extern const void            EVBA_Table;\r
-                       extern const uint32_t        Autovector_Table[];\r
-                       extern InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS];\r
-       #endif\r
-\r
-       /* Public Interface - May be used in end-application: */\r
-               /* Macros: */\r
-                       /** Converts a given interrupt index into its assocated interrupt group.\r
-                        *\r
-                        *  \param[in] IRQIndex  Index of the interrupt request to convert.\r
-                        *\r
-                        *  \return Interrupt group number associated with the interrupt index.\r
-                        */\r
-                       #define INTC_IRQ_GROUP(IRQIndex)  (IRQIndex / 32)\r
-\r
-                       /** Converts a given interrupt index into its assocated interrupt line.\r
-                        *\r
-                        *  \param[in] IRQIndex  Index of the interrupt request to convert.\r
-                        *\r
-                        *  \return Interrupt line number associated with the interrupt index.\r
-                        */\r
-                       #define INTC_IRQ_LINE(IRQIndex)   (IRQIndex % 32)\r
-\r
-               /* Function Prototypes: */\r
-                       /** Initializes the interrupt controller, nulling out all interrupt handlers ready for new registration. This\r
-                        *  function should be called once on startup to ensure the interrupt controller is ready for use.\r
-                        */\r
-                       void INTC_Init(void);\r
-\r
-               /* Inline Functions: */\r
-                       /** Registers a handler for a given interrupt group. On the AVR32 UC3 devices, interrupts are grouped by\r
-                        *  peripheral. To save on SRAM used, a single ISR handles all interrupt lines within a single group - to\r
-                        *  determine the exact line that has interrupted within the group ISR handler, use \ref INTC_GetGroupInterrupts().\r
-                        *\r
-                        *  If multiple interrupts with the same group are registered, the last registered handler will become the\r
-                        *  handler called for interrupts raised within that group.\r
-                        *\r
-                        *  To obtain the group number of a specific interrupt index, use the \ref INTC_IRQ_GROUP() macro.\r
-                        *\r
-                        *  \param[in] GroupNumber       Group number of the interrupt group to register a handler for.\r
-                        *  \param[in] InterruptLevel    Priority level for the specified interrupt, a \c AVR32_INTC_INT* mask.\r
-                        *  \param[in] Handler           Address of the ISR handler for the interrupt group.\r
-                        */\r
-                       static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber,\r
-                                                                    const uint8_t InterruptLevel,\r
-                                                                    const InterruptHandlerPtr_t Handler) ATTR_ALWAYS_INLINE;\r
-                       static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber,\r
-                                                                    const uint8_t InterruptLevel,\r
-                                                                    const InterruptHandlerPtr_t Handler)\r
-                       {\r
-                               InterruptHandlers[GroupNumber] = Handler;\r
-                               AVR32_INTC.ipr[GroupNumber]    = Autovector_Table[InterruptLevel];\r
-                       }\r
-                       \r
-                       /** Retrieves the pending interrupts for a given interrupt group. The result of this function should be masked\r
-                        *  against interrupt request indexes converted to a request line number via the \ref INTC_IRQ_LINE() macro. To\r
-                        *  obtain the group number of a given interrupt request, use the \ref INTC_IRQ_GROUP() macro.\r
-                        *\r
-                        *  \param[in] GroupNumber Group number of the interrupt group to check.\r
-                        *\r
-                        *  \return Mask of pending interrupt lines for the given interrupt group.\r
-                        */\r
-                       static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber) ATTR_ALWAYS_INLINE;\r
-                       static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber)\r
-                       {\r
-                               return AVR32_INTC.irr[GroupNumber];\r
-                       }\r
-       \r
-       /* Disable C linkage for C++ Compilers: */\r
-               #if defined(__cplusplus)\r
-                       }\r
-               #endif\r
-\r
-#endif\r
-\r
-/** @} */\r
+/*
+             LUFA Library
+     Copyright (C) Dean Camera, 2011.
+
+  dean [at] fourwalledcubicle [dot] com
+           www.lufa-lib.org
+*/
+
+/*
+  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+  Permission to use, copy, modify, distribute, and sell this
+  software and its documentation for any purpose is hereby granted
+  without fee, provided that the above copyright notice appear in
+  all copies and that both that the copyright notice and this
+  permission notice and warranty disclaimer appear in supporting
+  documentation, and that the name of the author not be used in
+  advertising or publicity pertaining to distribution of the
+  software without specific, written prior permission.
+
+  The author disclaim all warranties with regard to this
+  software, including all implied warranties of merchantability
+  and fitness.  In no event shall the author be liable for any
+  special, indirect or consequential damages or any damages
+  whatsoever resulting from loss of use, data or profits, whether
+  in an action of contract, negligence or other tortious action,
+  arising out of or in connection with the use or performance of
+  this software.
+*/
+
+/** \file
+ *  \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers.
+ *
+ *  Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt
+ *  handlers within the device.
+ */
+
+/** \ingroup Group_PlatformDrivers
+ *  \defgroup Group_PlatformDrivers_UC3Interrupts UC3 Interrupt Controller Driver - LUFA/Platform/UC3/InterruptManagement.h
+ *  \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers.
+ *
+ *  \section Sec_Dependencies Module Source Dependencies
+ *  The following files must be built with any user project that uses this module:
+ *    - LUFA/Platform/UC3/InterruptManagement.c
+ *    - LUFA/Platform/UC3/Exception.S
+ *
+ *  \section Sec_ModDescription Module Description
+ *  Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt
+ *  handlers within the device.
+ *
+ *  Usage Example:
+ *  \code
+ *             #include <LUFA/Platform/UC3/InterruptManagement.h>
+ *
+ *             ISR(USB_Group_IRQ_Handler)
+ *             {
+ *                     // USB group handler code here
+ *             }
+ *
+ *             void main(void)
+ *             {
+ *                     INTC_Init();
+ *                     INTC_RegisterGroupHandler(INTC_IRQ_GROUP(AVR32_USBB_IRQ), AVR32_INTC_INT0, USB_Group_IRQ_Handler);
+ *             }
+ *  \endcode
+ *
+ *  @{
+ */
+
+#ifndef _UC3_INTERRUPT_MANAGEMENT_H_
+#define _UC3_INTERRUPT_MANAGEMENT_H_
+
+       /* Includes: */
+               #include <LUFA/Common/Common.h>
+
+       /* Enable C linkage for C++ Compilers: */
+               #if defined(__cplusplus)
+                       extern "C" {
+               #endif
+
+       /* Private Interface - For use in library only: */
+       #if !defined(__DOXYGEN__)
+               /* Type Defines: */
+                       typedef void (*InterruptHandlerPtr_t)(void);
+
+               /* External Variables: */
+                       extern const void            EVBA_Table;
+                       extern const uint32_t        Autovector_Table[];
+                       extern InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS];
+       #endif
+
+       /* Public Interface - May be used in end-application: */
+               /* Macros: */
+                       /** Converts a given interrupt index into its assocated interrupt group.
+                        *
+                        *  \param[in] IRQIndex  Index of the interrupt request to convert.
+                        *
+                        *  \return Interrupt group number associated with the interrupt index.
+                        */
+                       #define INTC_IRQ_GROUP(IRQIndex)  (IRQIndex / 32)
+
+                       /** Converts a given interrupt index into its assocated interrupt line.
+                        *
+                        *  \param[in] IRQIndex  Index of the interrupt request to convert.
+                        *
+                        *  \return Interrupt line number associated with the interrupt index.
+                        */
+                       #define INTC_IRQ_LINE(IRQIndex)   (IRQIndex % 32)
+
+               /* Function Prototypes: */
+                       /** Initializes the interrupt controller, nulling out all interrupt handlers ready for new registration. This
+                        *  function should be called once on startup to ensure the interrupt controller is ready for use.
+                        */
+                       void INTC_Init(void);
+
+               /* Inline Functions: */
+                       /** Registers a handler for a given interrupt group. On the AVR32 UC3 devices, interrupts are grouped by
+                        *  peripheral. To save on SRAM used, a single ISR handles all interrupt lines within a single group - to
+                        *  determine the exact line that has interrupted within the group ISR handler, use \ref INTC_GetGroupInterrupts().
+                        *
+                        *  If multiple interrupts with the same group are registered, the last registered handler will become the
+                        *  handler called for interrupts raised within that group.
+                        *
+                        *  To obtain the group number of a specific interrupt index, use the \ref INTC_IRQ_GROUP() macro.
+                        *
+                        *  \param[in] GroupNumber       Group number of the interrupt group to register a handler for.
+                        *  \param[in] InterruptLevel    Priority level for the specified interrupt, a \c AVR32_INTC_INT* mask.
+                        *  \param[in] Handler           Address of the ISR handler for the interrupt group.
+                        */
+                       static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber,
+                                                                    const uint8_t InterruptLevel,
+                                                                    const InterruptHandlerPtr_t Handler) ATTR_ALWAYS_INLINE;
+                       static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber,
+                                                                    const uint8_t InterruptLevel,
+                                                                    const InterruptHandlerPtr_t Handler)
+                       {
+                               InterruptHandlers[GroupNumber] = Handler;
+                               AVR32_INTC.ipr[GroupNumber]    = Autovector_Table[InterruptLevel];
+                       }
+                       
+                       /** Retrieves the pending interrupts for a given interrupt group. The result of this function should be masked
+                        *  against interrupt request indexes converted to a request line number via the \ref INTC_IRQ_LINE() macro. To
+                        *  obtain the group number of a given interrupt request, use the \ref INTC_IRQ_GROUP() macro.
+                        *
+                        *  \param[in] GroupNumber Group number of the interrupt group to check.
+                        *
+                        *  \return Mask of pending interrupt lines for the given interrupt group.
+                        */
+                       static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber) ATTR_ALWAYS_INLINE;
+                       static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber)
+                       {
+                               return AVR32_INTC.irr[GroupNumber];
+                       }
+       
+       /* Disable C linkage for C++ Compilers: */
+               #if defined(__cplusplus)
+                       }
+               #endif
+
+#endif
+
+/** @} */