# intc.h File Reference

INTC driver for AVR32 UC3. More...

`#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.

## 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.

## Define Documentation

#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)

Number of interrupt priority levels.

Definition at line 58 of file intc.h.

## Typedef Documentation

typedef void(* __int_handler)(void)

Pointer to interrupt handler.

Definition at line 65 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 173 of file intc.c.

References _int_handler_table, _unhandled_interrupt(), INTC_init_evba(), and ipr_val.

    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.

Parameters:

  | 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.

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 197 of file intc.c.

References _int_handler_table, AVR32_INTC_MAX_NUM_IRQS_PER_GRP, and ipr_val.

    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 }