3      Copyright (C) Dean Camera, 2011. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  31 #ifndef _INTERRUPT_MANAGEMENT_H_ 
  32 #define _INTERRUPT_MANAGEMENT_H_ 
  39                 #include <LUFA/Common/Common.h> 
  43                         #define ISR(Name)                 void Name (void) __attribute__((__interrupt__)); void Name (void) 
  46                 #define INTC_EnableInterrupts()   do { GCC_MEMORY_BARRIER(); __builtin_csrf(AVR32_SR_GM_OFFSET); } while (0) 
  47                 #define INTC_DisableInterrupts()  do { __builtin_ssrf(AVR32_SR_GM_OFFSET); GCC_MEMORY_BARRIER(); } while (0) 
  50                 typedef void (*InterruptHandlerPtr_t
)(void); 
  52         /* External Variables: */ 
  53                 extern const void            EVBA_Table
; 
  54                 extern const uint32_t        Autovector_Table
[]; 
  55                 extern InterruptHandlerPtr_t InterruptHandlers
[AVR32_INTC_NUM_INT_GRPS
]; 
  57         /* Function Prototypes: */ 
  60         /* Inline Functions: */ 
  61                 /** Registers a handler for a given interrupt group. On the AVR32 UC3 devices, interrupts are grouped by 
  62                  *  peripheral. To save on SRAM used, a single ISR handles all interrupt lines within a single group - to 
  63                  *  determine the exact line that has interrupted within the group ISR handler, examine the module's interrupt 
  66                  *  If multiple interrupts with the same group are registered, the last registered handler will become the 
  67                  *  handler called for interrupts raised within that group. 
  69                  *  \param[in] InterruptRequest  Interrupt request index for the given interrupt, a AVR32_*_IRQ mask. 
  70                  *  \param[in] InterruptLevel    Priority level for the specified interrupt, a AVR32_INTC_INT* mask. 
  71                  *  \param[in] Handler           Address of the ISR handler for the interrupt group. 
  73                 static inline void INTC_RegisterGroupHandler(const uint16_t InterruptRequest
, 
  74                                                                                                      const uint8_t  InterruptLevel
, 
  75                                                                                                      const InterruptHandlerPtr_t Handler
) 
  77                         uint8_t InterruptGroup 
= (InterruptRequest 
>> 5); 
  79                         InterruptHandlers
[InterruptGroup
] = Handler
; 
  80                         AVR32_INTC
.ipr
[InterruptGroup
]    = Autovector_Table
[InterruptLevel
];