# intc.h File Reference

## Detailed Description

INTC driver for AVR32 UC3.

AVR32 Interrupt Controller driver module.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All AVR32 devices with an INTC module can be used.
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

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_lev)
| Registers an interrupt handler.

## Define Documentation

#define AVR32_INTC_MAX_NUM_IRQS_PER_GRP 32

Maximal number of interrupt request lines per group.

Definition at line 52 of file intc.h.

Referenced by INTC_register_interrupt().

#define AVR32_INTC_NUM_INT_LEVELS (1 << AVR32_INTC_IPR_INTLEVEL_SIZE)

Number of interrupt priority levels.

Definition at line 55 of file intc.h.

## Typedef Documentation

typedef void(* __int_handler)(void)

Pointer to interrupt handler.

Definition at line 62 of file intc.h.

## Function Documentation

void INTC_init_interrupts | ( | void |  | ) |

Initializes the hardware interrupt controller driver.

Note:
  Taken and adapted from Newlib.

Definition at line 163 of file intc.c.

References _int_handler_table, _unhandled_interrupt(), and ipr_val.

Referenced by main().

    00164 {
    00165   unsigned int int_grp, int_req;
    00166
    00167   // For all interrupt groups,
    00168   for (int_grp = 0; int_grp < AVR32_INTC_NUM_INT_GRPS; int_grp++)
    00169   {
    00170     // For all interrupt request lines of each group,
    00171     for (int_req = 0; int_req < _int_handler_table[int_grp].num_irqs; int_req++)
    00172     {
    00173       // Assign _unhandled_interrupt as default interrupt handler.
    00174       _int_handler_table[int_grp]._int_line_handler_table[int_req] = &_unhandled_interrupt;
    00175     }
    00176
    00177     // Set the interrupt group priority register to its default value.
    00178     // By default, all interrupt groups are linked to the interrupt priority
    00179     // level 0 and to the interrupt vector _int0.
    00180     AVR32_INTC.ipr[int_grp] = ipr_val[AVR32_INTC_INT0];
    00181   }
    00182 }

void INTC_register_interrupt | ( | __int_handler | handler,
|  | unsigned int | irq,
|  | unsigned int | int_lev |
| ) |  |  |

Registers an interrupt handler.

Parameters:

  | handler | Interrupt handler to register.
  | irq | IRQ of the interrupt handler to register.
  | int_lev | Interrupt priority level to assign to the group of this IRQ.

Warning:
  The interrupt handler must manage the `rete' instruction, what can be done thanks to pure assembly, inline assembly or the `__attribute__((__interrupt__))' C function attribute.

  If several interrupt handlers of a same group are registered with different priority levels, only the latest priority level set will be effective.

Note:
  Taken and adapted from Newlib.

Definition at line 185 of file intc.c.

References _int_handler_table, AVR32_INTC_MAX_NUM_IRQS_PER_GRP, and ipr_val.

Referenced by main().

    00186 {
    00187   // Determine the group of the IRQ.
    00188   unsigned int int_grp = irq / AVR32_INTC_MAX_NUM_IRQS_PER_GRP;
    00189
    00190   // Store in _int_line_handler_table_x the pointer to the interrupt handler, so
    00191   // that _get_interrupt_handler can retrieve it when the interrupt is vectored.
    00192   _int_handler_table[int_grp]._int_line_handler_table[irq % AVR32_INTC_MAX_NUM_IRQS_PER_GRP] = handler;
    00193
    00194   // Program the corresponding IPRX register to set the interrupt priority level
    00195   // and the interrupt vector offset that will be fetched by the core interrupt
    00196   // system.
    00197   // NOTE: The _intx functions are intermediate assembly functions between the
    00198   // core interrupt system and the user interrupt handler.
    00199   AVR32_INTC.ipr[int_grp] = ipr_val[int_lev & (AVR32_INTC_IPR_INTLEVEL_MASK >> AVR32_INTC_IPR_INTLEVEL_OFFSET)];
    00200 }