AVR32 Interrupt Controller driver module.
Definition in file intc.h.
#include "compiler.h"
Go to the source code of this file.
Defines | |
#define | AVR32_INTC_MAX_NUM_IRQS_PER_GRP 32 |
Maximal number of interrupt request lines per group. | |
#define | AVR32_INTC_NUM_INT_LEVELS (1 << AVR32_INTC_IPR_INTLEVEL_SIZE) |
Number of interrupt priority levels. | |
Typedefs | |
typedef void(* | __int_handler )(void) |
Pointer to interrupt handler. | |
Functions | |
void | INTC_init_interrupts (void) |
Initializes the hardware interrupt controller driver. | |
void | INTC_register_interrupt (__int_handler handler, unsigned int irq, unsigned int int_level) |
Registers an interrupt handler. |
#define AVR32_INTC_MAX_NUM_IRQS_PER_GRP 32 |
Maximal number of interrupt request lines per group.
Definition at line 55 of file intc.h.
Referenced by INTC_register_interrupt().
#define AVR32_INTC_NUM_INT_LEVELS (1 << AVR32_INTC_IPR_INTLEVEL_SIZE) |
typedef void(* __int_handler)(void) |
void INTC_init_interrupts | ( | void | ) |
Initializes the hardware interrupt controller driver.
Definition at line 173 of file intc.c.
References _int_handler_table, _unhandled_interrupt(), INTC_init_evba(), and ipr_val.
Referenced by main().
00174 { 00175 unsigned int int_grp, int_req; 00176 00177 INTC_init_evba(); 00178 00179 // For all interrupt groups, 00180 for (int_grp = 0; int_grp < AVR32_INTC_NUM_INT_GRPS; int_grp++) 00181 { 00182 // For all interrupt request lines of each group, 00183 for (int_req = 0; int_req < _int_handler_table[int_grp].num_irqs; int_req++) 00184 { 00185 // Assign _unhandled_interrupt as default interrupt handler. 00186 _int_handler_table[int_grp]._int_line_handler_table[int_req] = &_unhandled_interrupt; 00187 } 00188 00189 // Set the interrupt group priority register to its default value. 00190 // By default, all interrupt groups are linked to the interrupt priority 00191 // level 0 and to the interrupt vector _int0. 00192 AVR32_INTC.ipr[int_grp] = ipr_val[AVR32_INTC_INT0]; 00193 } 00194 }
void INTC_register_interrupt | ( | __int_handler | handler, | |
unsigned int | irq, | |||
unsigned int | int_level | |||
) |
Registers an interrupt handler.
handler | Interrupt handler to register. | |
irq | IRQ of the interrupt handler to register. | |
int_level | Interrupt priority level to assign to the group of this IRQ. |
If several interrupt handlers of a same group are registered with different priority levels, only the latest priority level set will be effective.
Definition at line 197 of file intc.c.
References _int_handler_table, AVR32_INTC_MAX_NUM_IRQS_PER_GRP, and ipr_val.
Referenced by main().
00198 { 00199 // Determine the group of the IRQ. 00200 unsigned int int_grp = irq / AVR32_INTC_MAX_NUM_IRQS_PER_GRP; 00201 00202 // Store in _int_line_handler_table_x the pointer to the interrupt handler, so 00203 // that _get_interrupt_handler can retrieve it when the interrupt is vectored. 00204 _int_handler_table[int_grp]._int_line_handler_table[irq % AVR32_INTC_MAX_NUM_IRQS_PER_GRP] = handler; 00205 00206 // Program the corresponding IPRX register to set the interrupt priority level 00207 // and the interrupt vector offset that will be fetched by the core interrupt 00208 // system. 00209 // NOTE: The _intx functions are intermediate assembly functions between the 00210 // core interrupt system and the user interrupt handler. 00211 AVR32_INTC.ipr[int_grp] = ipr_val[int_level & (AVR32_INTC_IPR_INTLEVEL_MASK >> AVR32_INTC_IPR_INTLEVEL_OFFSET)]; 00212 }