this software.\r
*/\r
\r
-#ifndef _CLOCK_MANAGEMENT_H_\r
-#define _CLOCK_MANAGEMENT_H_\r
+/** \file\r
+ * \brief Module Clock Driver for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ */\r
+\r
+/** \ingroup Group_PlatformDrivers\r
+ * \defgroup Group_PlatformDrivers_UC3Clocks UC3 Clock Management Driver - LUFA/Platform/UC3/ClockManagement.h\r
+ * \brief Module Clock 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
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * #include <LUFA/Platform/UC3/ClockManagement.h>\r
+ *\r
+ * void main(void)\r
+ * {\r
+ * // Start the master external oscillator which will be used as the main clock reference\r
+ * AVR32CLK_StartExternalOscillator(0, EXOSC_MODE_8MHZ_OR_MORE, EXOSC_START_0CLK);\r
+ * \r
+ * // Start the PLL for the CPU clock, switch CPU to it\r
+ * AVR32CLK_StartPLL(0, CLOCK_SRC_OSC0, 12000000, F_CPU);\r
+ * AVR32CLK_SetCPUClockSource(CLOCK_SRC_PLL0, F_CPU);\r
+ *\r
+ * // Start the PLL for the USB Generic Clock module\r
+ * AVR32CLK_StartPLL(1, CLOCK_SRC_OSC0, 12000000, 48000000);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _UC3_CLOCK_MANAGEMENT_H_\r
+#define _UC3_CLOCK_MANAGEMENT_H_\r
\r
/* Includes: */\r
#include <avr32/io.h>\r
\r
#include <LUFA/Common/Common.h>\r
\r
- /* Macros: */\r
- enum Extern_OSC_ClockStartup_t\r
- {\r
- EXOSC_START_0CLK = 0,\r
- EXOSC_START_64CLK = 1,\r
- EXOSC_START_128CLK = 2,\r
- EXOSC_START_2048CLK = 3,\r
- EXOSC_START_4096CLK = 4,\r
- EXOSC_START_8192CLK = 5,\r
- EXOSC_START_16384CLK = 6,\r
- };\r
- \r
- enum Extern_OSC_ClockMode_t\r
- {\r
- EXOSC_MODE_CLOCK = 0,\r
- EXOSC_MODE_900KHZ_MAX = 1,\r
- EXOSC_MODE_3MHZ_MAX = 2,\r
- EXOSC_MODE_8MHZ_MAX = 3,\r
- EXOSC_MODE_8MHZ_OR_MORE = 4, \r
- };\r
- \r
- enum\r
- {\r
- CLOCK_SRC_SLOW_CLK = 0,\r
- CLOCK_SRC_OSC0 = 1,\r
- CLOCK_SRC_OSC1 = 2,\r
- CLOCK_SRC_PLL0 = 3,\r
- CLOCK_SRC_PLL1 = 4,\r
- };\r
-\r
- /* Inline Functions: */\r
- static inline bool AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
- const uint8_t Type,\r
- const uint8_t Startup)\r
- {\r
- AVR32_PM.OSCCTRL0.startup = Startup;\r
- AVR32_PM.OSCCTRL0.mode = Type;\r
- AVR32_PM.mcctrl |= (1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
-\r
- while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_OSC0RDY_OFFSET + Channel))));\r
- return true;\r
- }\r
-\r
- static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel)\r
- {\r
- AVR32_PM.mcctrl &= ~(1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
- }\r
-\r
- static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
- const uint8_t Source,\r
- const uint32_t SourceFreq,\r
- const uint32_t Frequency)\r
- {\r
- switch (Source)\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Enum for the possible external oscillator types. */\r
+ enum Extern_OSC_ClockTypes_t\r
+ {\r
+ EXOSC_MODE_CLOCK = 0, /**< External clock (non-crystal) mode. */\r
+ EXOSC_MODE_900KHZ_MAX = 1, /**< External crystal oscillator equal to or slower than 900KHz. */\r
+ EXOSC_MODE_3MHZ_MAX = 2, /**< External crystal oscillator equal to or slower than 3MHz. */\r
+ EXOSC_MODE_8MHZ_MAX = 3, /**< External crystal oscillator equal to or slower than 8MHz. */\r
+ EXOSC_MODE_8MHZ_OR_MORE = 4, /**< External crystal oscillator equal to or faster than 8MHz. */ \r
+ };\r
+\r
+ /** Enum for the possible external oscillator statup times. */\r
+ enum Extern_OSC_ClockStartup_t\r
+ {\r
+ EXOSC_START_0CLK = 0, /**< Immediate startup, no delay. */\r
+ EXOSC_START_64CLK = 1, /**< Wait 64 clock cyles before startup for stability. */\r
+ EXOSC_START_128CLK = 2, /**< Wait 128 clock cyles before startup for stability. */\r
+ EXOSC_START_2048CLK = 3, /**< Wait 2048 clock cyles before startup for stability. */\r
+ EXOSC_START_4096CLK = 4, /**< Wait 4096 clock cyles before startup for stability. */\r
+ EXOSC_START_8192CLK = 5, /**< Wait 8192 clock cyles before startup for stability. */\r
+ EXOSC_START_16384CLK = 6, /**< Wait 16384 clock cyles before startup for stability. */\r
+ };\r
+ \r
+ /** Enum for the possible module clock sources. */\r
+ enum System_ClockSource_t\r
+ {\r
+ CLOCK_SRC_SLOW_CLK = 0, /**< Clock sourced from the internal slow clock. */\r
+ CLOCK_SRC_OSC0 = 1, /**< Clock sourced from the Oscillator 0 clock. */\r
+ CLOCK_SRC_OSC1 = 2, /**< Clock sourced from the Oscillator 1 clock. */\r
+ CLOCK_SRC_PLL0 = 3, /**< Clock sourced from the PLL 0 clock. */\r
+ CLOCK_SRC_PLL1 = 4, /**< Clock sourced from the PLL 1 clock. */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Starts the given external oscillator of the UC3 microcontroller, with the given options. This routine blocks until\r
+ * the oscillator is ready for use.\r
+ *\r
+ * \param[in] Channel Index of the external oscillator to start.\r
+ * \param[in] Type Type of clock attached to the given oscillator channel, a value from \ref Extern_OSC_ClockTypes_t.\r
+ * \param[in] Startup Statup time of the external oscillator, a value from \ref Extern_OSC_ClockStartup_t.\r
+ *\r
+ * \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline void AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup)\r
+ {\r
+ switch (Channel)\r
+ {\r
+ case 0:\r
+ AVR32_PM.OSCCTRL0.startup = Startup;\r
+ AVR32_PM.OSCCTRL0.mode = Type;\r
+ break;\r
+ case 1:\r
+ AVR32_PM.OSCCTRL1.startup = Startup;\r
+ AVR32_PM.OSCCTRL1.mode = Type;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ AVR32_PM.mcctrl |= (1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
+\r
+ while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_OSC0RDY_OFFSET + Channel))));\r
+ return true;\r
+ }\r
+\r
+ /** Stops the given external oscillator of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the external oscillator to stop.\r
+ */\r
+ static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel)\r
{\r
- case CLOCK_SRC_OSC0:\r
- AVR32_PM.PLL[Channel].pllosc = 0;\r
- break;\r
- case CLOCK_SRC_OSC1:\r
- AVR32_PM.PLL[Channel].pllosc = 1;\r
- break;\r
- default:\r
- return false;\r
+ AVR32_PM.mcctrl &= ~(1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
}\r
\r
- AVR32_PM.PLL[Channel].pllmul = (Frequency / SourceFreq) ? (((Frequency / SourceFreq) - 1) / 2) : 0;\r
- AVR32_PM.PLL[Channel].plldiv = 0;\r
- AVR32_PM.PLL[Channel].pllen = true;\r
-\r
- while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_LOCK0_OFFSET + Channel))));\r
- return true;\r
- }\r
-\r
- static inline void AVR32CLK_StopPLL(const uint8_t Channel)\r
- {\r
- AVR32_PM.PLL[Channel].pllen = false;\r
- }\r
- \r
- static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
- const uint8_t Source,\r
- const uint32_t SourceFreq,\r
- const uint32_t Frequency)\r
- {\r
- switch (Source)\r
+ /** Starts the given PLL of the UC3 microcontroller, with the given options. This routine blocks until the PLL is ready for use.\r
+ *\r
+ * \param[in] Channel Index of the PLL to start.\r
+ * \param[in] Source Clock source for the PLL, a value from \ref System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the PLL's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the PLL's output.\r
+ *\r
+ * \return Boolean \c true if the PLL was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
{\r
- case CLOCK_SRC_OSC0:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 0;\r
- AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
- break;\r
- case CLOCK_SRC_OSC1:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 0;\r
- AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
- break;\r
- case CLOCK_SRC_PLL0:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 1;\r
- AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
- break;\r
- case CLOCK_SRC_PLL1:\r
- AVR32_PM.GCCTRL[Channel].pllsel = 1;\r
- AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
- break;\r
- default:\r
- return false;\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_OSC0:\r
+ AVR32_PM.PLL[Channel].pllosc = 0;\r
+ break;\r
+ case CLOCK_SRC_OSC1:\r
+ AVR32_PM.PLL[Channel].pllosc = 1;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ AVR32_PM.PLL[Channel].pllmul = (Frequency / SourceFreq) ? (((Frequency / SourceFreq) - 1) / 2) : 0;\r
+ AVR32_PM.PLL[Channel].plldiv = 0;\r
+ AVR32_PM.PLL[Channel].pllen = true;\r
+\r
+ while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_LOCK0_OFFSET + Channel))));\r
+ return true;\r
}\r
\r
- AVR32_PM.GCCTRL[Channel].diven = (SourceFreq > Frequency) ? true : false;\r
- AVR32_PM.GCCTRL[Channel].div = (((SourceFreq / Frequency) - 1) / 2);\r
- AVR32_PM.GCCTRL[Channel].cen = true;\r
+ /** Stops the given PLL of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the PLL to stop.\r
+ */\r
+ static inline void AVR32CLK_StopPLL(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopPLL(const uint8_t Channel)\r
+ {\r
+ AVR32_PM.PLL[Channel].pllen = false;\r
+ }\r
+ \r
+ /** Starts the given Generic Clock of the UC3 microcontroller, with the given options.\r
+ *\r
+ * \param[in] Channel Index of the Generic Clock to start.\r
+ * \param[in] Source Clock source for the Generic Clock, a value from \ref System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the Generic Clock's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the Generic Clock's output.\r
+ *\r
+ * \return Boolean \c true if the Generic Clock was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
+ {\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_OSC0:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = 0;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
+ break;\r
+ case CLOCK_SRC_OSC1:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = 0;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
+ break;\r
+ case CLOCK_SRC_PLL0:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = 1;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
+ break;\r
+ case CLOCK_SRC_PLL1:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = 1;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ \r
+ if (SourceFreq < Frequency)\r
+ return false;\r
+\r
+ AVR32_PM.GCCTRL[Channel].diven = (SourceFreq > Frequency) ? true : false;\r
+ AVR32_PM.GCCTRL[Channel].div = (((SourceFreq / Frequency) - 1) / 2);\r
+ AVR32_PM.GCCTRL[Channel].cen = true;\r
+ \r
+ return true;\r
+ }\r
\r
- return true;\r
- }\r
- \r
- static inline void AVR32CLK_StopGenericClock(const uint8_t Channel)\r
- {\r
- AVR32_PM.GCCTRL[Channel].cen = false;\r
- }\r
-\r
- static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
- const uint32_t SourceFreq)\r
- {\r
- AVR32_FLASHC.FCR.fws = (SourceFreq > 30000000) ? true : false;\r
-\r
- switch (Source)\r
+ /** Stops the given generic clock of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the generic clock to stop.\r
+ */\r
+ static inline void AVR32CLK_StopGenericClock(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopGenericClock(const uint8_t Channel)\r
{\r
- case CLOCK_SRC_SLOW_CLK:\r
- AVR32_PM.MCCTRL.mcsel = 0;\r
- break;\r
- case CLOCK_SRC_OSC0:\r
- AVR32_PM.MCCTRL.mcsel = 1;\r
- break;\r
- case CLOCK_SRC_PLL0:\r
- AVR32_PM.MCCTRL.mcsel = 2;\r
- break;\r
- default:\r
- return false;\r
+ AVR32_PM.GCCTRL[Channel].cen = false;\r
}\r
\r
- return true;\r
- }\r
+ /** Sets the clock source for the main microcontroller core. The given clock source should be configured\r
+ * and ready for use before this function is called.\r
+ *\r
+ * This function will configure the FLASH controller's wait states automatically to suit the given clock source.\r
+ *\r
+ * \param[in] Source Clock source for the CPU core, a value from \ref System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the CPU core's clock source, in Hz.\r
+ *\r
+ * \return Boolean \c true if the CPU core clock was sucessfully altered, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
+ const uint32_t SourceFreq) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
+ const uint32_t SourceFreq)\r
+ {\r
+ AVR32_FLASHC.FCR.fws = (SourceFreq > 30000000) ? true : false;\r
+\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_SLOW_CLK:\r
+ AVR32_PM.MCCTRL.mcsel = 0;\r
+ break;\r
+ case CLOCK_SRC_OSC0:\r
+ AVR32_PM.MCCTRL.mcsel = 1;\r
+ break;\r
+ case CLOCK_SRC_PLL0:\r
+ AVR32_PM.MCCTRL.mcsel = 2;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+ \r
+ return true;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
\r
#endif\r
+\r
+/** @} */\r
this software.\r
*/\r
\r
-#ifndef _INTERRUPT_MANAGEMENT_H_\r
-#define _INTERRUPT_MANAGEMENT_H_\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 <avr32/io.h>\r
\r
#include <LUFA/Common/Common.h>\r
\r
- /* Macros: */\r
- #if !defined(ISR)\r
- #define ISR(Name) void Name (void) __attribute__((__interrupt__)); void Name (void)\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
+ /* 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
+ /* Type Defines: */\r
+ /** Type define for an interrupt handler ISR function. */\r
+ typedef void (*InterruptHandlerPtr_t)(void);\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
- #define INTC_EnableInterrupts() do { GCC_MEMORY_BARRIER(); __builtin_csrf(AVR32_SR_GM_OFFSET); } while (0)\r
- #define INTC_DisableInterrupts() do { __builtin_ssrf(AVR32_SR_GM_OFFSET); GCC_MEMORY_BARRIER(); } while (0)\r
-\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
-\r
- /* Function Prototypes: */\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, examine the module's interrupt\r
- * flag register bits.\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
- * \param[in] InterruptRequest Interrupt request index for the given interrupt, a AVR32_*_IRQ mask.\r
- * \param[in] InterruptLevel Priority level for the specified interrupt, a 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 InterruptRequest,\r
- const uint8_t InterruptLevel,\r
- const InterruptHandlerPtr_t Handler)\r
- {\r
- uint8_t InterruptGroup = (InterruptRequest >> 5);\r
-\r
- InterruptHandlers[InterruptGroup] = Handler;\r
- AVR32_INTC.ipr[InterruptGroup] = Autovector_Table[InterruptLevel];\r
- }\r
\r
#endif\r
+\r
+/** @} */\r