Atmel Software Framework

Global interrupt management

This is a driver for global enabling and disabling of interrupts.

Modules

 Deprecated interrupt definitions
 

Macros

#define CONFIG_INTERRUPT_FORCE_INTC
 Force usage of the ASF INTC driver. More...
 

Typedefs

typedef void(* __int_handler) (void)
 Pointer to interrupt handler. More...
 

Global interrupt flags

typedef uint32_t irqflags_t
 Type used for holding state of interrupt flag. More...
 
static irqflags_t cpu_irq_save (void)
 Get and clear the global interrupt flags. More...
 
static bool cpu_irq_is_enabled_flags (irqflags_t flags)
 Check if interrupts are globally enabled in supplied flags. More...
 
static void cpu_irq_restore (irqflags_t flags)
 Restore global interrupt flags. More...
 
#define cpu_irq_enable()
 Enable interrupts globally. More...
 
#define cpu_irq_disable()
 Disable interrupts globally. More...
 
#define cpu_irq_is_enabled()   cpu_irq_is_enabled_flags(sysreg_read(AVR32_SR))
 Check if interrupts are globally enabled. More...
 

Interrupt Service Routine definition and registration

#define ISR(func, int_grp, int_lvl)   __attribute__((__interrupt__)) static void func (void)
 Macro to declare an interrupt service routine. More...
 
#define irq_initialize_vectors()   INTC_init_interrupts()
 Initialize interrupt vectors. More...
 
#define irq_register_handler(func, int_num, int_lvl)
 Register handler for interrupt. More...
 

Global interrupt levels

static bool cpu_irq_level_is_enabled_flags (irqflags_t flags, uint32_t level)
 Check if interrupt level is enabled in supplied flags. More...
 
#define cpu_irq_level_is_enabled(level)
 Check if interrupt level is enabled. More...
 
#define cpu_irq_enable_level(level)
 Enable interrupt level. More...
 
#define cpu_irq_disable_level(level)
 Disable interrupt level. More...
 

#define CONFIG_INTERRUPT_FORCE_INTC

Force usage of the ASF INTC driver.

Predefine this symbol when preprocessing to force the use of the ASF INTC driver. This is useful to ensure compatibility across compilers and shall be used only when required by the application needs.

#define cpu_irq_disable ( )
Value:
do { \
__builtin_ssrf(AVR32_SR_GM_OFFSET); \
} while (0)
#define barrier()
Memory barrier.
Definition: compiler.h:109

Disable interrupts globally.

Referenced by cpu_irq_save(), and pm_bod_disable_irq().

#define cpu_irq_disable_level (   level)
Value:
do { \
__builtin_ssrf(TPASTE3(AVR32_SR_I, level, M_OFFSET)); \
} while (0)
#define barrier()
Memory barrier.
Definition: compiler.h:109
#define TPASTE3(a, b, c)
Definition: tpaste.h:72

Disable interrupt level.

Parameters
levelInterrupt level to disable (0 to 3).
Note
The interrupt level must be known at compile time.
#define cpu_irq_enable ( )
Value:
do { \
__builtin_csrf(AVR32_SR_GM_OFFSET); \
} while (0)
#define barrier()
Memory barrier.
Definition: compiler.h:109

Enable interrupts globally.

Referenced by cpu_irq_restore(), and pm_bod_disable_irq().

#define cpu_irq_enable_level (   level)
Value:
do { \
__builtin_csrf(TPASTE3(AVR32_SR_I, level, M_OFFSET)); \
} while (0)
#define barrier()
Memory barrier.
Definition: compiler.h:109
#define TPASTE3(a, b, c)
Definition: tpaste.h:72

Enable interrupt level.

Parameters
levelInterrupt level to enable (0 to 3).
Note
The interrupt level must be known at compile time.
#define cpu_irq_is_enabled ( )    cpu_irq_is_enabled_flags(sysreg_read(AVR32_SR))

Check if interrupts are globally enabled.

Returns
True if interrupts are enabled.

Referenced by pm_bod_disable_irq().

#define cpu_irq_level_is_enabled (   level)
Value:
TPASTE3(AVR32_SR_I, level, M_OFFSET))
static bool cpu_irq_level_is_enabled_flags(irqflags_t flags, uint32_t level)
Check if interrupt level is enabled in supplied flags.
Definition: interrupt_avr32.h:247
#define sysreg_read(reg)
Get value of system register.
Definition: compiler.h:167
#define TPASTE3(a, b, c)
Definition: tpaste.h:72

Check if interrupt level is enabled.

Parameters
levelInterrupt level (0 to 3).
Returns
True if interrupt level level is enabled.
Note
The interrupt level must be known at compile time.
#define irq_initialize_vectors ( )    INTC_init_interrupts()

Initialize interrupt vectors.

With GCC, this macro adds code for initialization of the interrupt vectors with the driver for the interrupt controller (INTC).

With IAR and unless CONFIG_INTERRUPT_FORCE_INTC is defined this macro adds no code, since initialization of the INTC is handled by the compiler.

Note
Defining CONFIG_INTERRUPT_FORCE_INTC will force the use of the INTC driver, replacing the compiler built-in interrupt handler.

This must be called prior to irq_register_handler.

#define irq_register_handler (   func,
  int_num,
  int_lvl 
)
Value:
INTC_register_interrupt(func, int_num, \
TPASTE2(AVR32_INTC_INT, int_lvl))
#define TPASTE2(a, b)
Definition: tpaste.h:71

Register handler for interrupt.

With GCC, this macro adds code for registering an interrupt handler with the driver for the interrupt controller (INTC).

With IAR and unless CONFIG_INTERRUPT_FORCE_INTC is defined this macro adds no code, since initialization of the INTC is handled by the compiler.

Note
Defining CONFIG_INTERRUPT_FORCE_INTC will force the use of the INTC driver, replacing the compiler built-in interrupt handler.
Parameters
funcName of handler function to register for interrupt.
int_numNumber of the interrupt line to register function for.
int_lvlPriority level to set for the interrupt's group, in the range 0 to 3.

Usage:

1 irq_initialize_vectors();
2 irq_register_handler(foo_irq_handler, AVR32_xxx_IRQ, n);
Note
The function func must be defined with the ISR macro.
The interrupt line number can be found in the device header files for the GCC toolchain (avr32/<part>.h).
#define ISR (   func,
  int_grp,
  int_lvl 
)    __attribute__((__interrupt__)) static void func (void)

Macro to declare an interrupt service routine.

With GCC, this macro only causes the function to be defined as an interrupt service routine, i.e., it does not add any initialization code. A valid function name is required for use with irq_register_handler.

With IAR, this macro defines the function as an interrupt service routine and causes the compiler to add initialization code for the interrupt controller (INTC). The interrupt group and level, as well as a valid function name are therefore required.

Note
If CONFIG_INTERRUPT_FORCE_INTC is defined, only a valid function name is required for use with irq_register_handler. The initialization code will be handled by the interrupt controller itself.

Usage:

1 ISR(foo_irq_handler, AVR32_xxx_IRQ_GROUP, n)
2 {
3  // Function definition
4  ...
5 }
Parameters
funcName for the function, needed by irq_register_handler.
int_grpInterrupt group to define service routine for.
int_lvlPriority level to set for the interrupt group, in the range 0 to 3.
Note
The interrupt groups can be found in the device header files for the IAR toolchain (avr32/io<part>.h).
Todo:
Update to use IRQ numbers when these are made available in the device header files of both IAR and GCC.

typedef void(* __int_handler) (void)

Pointer to interrupt handler.

Type used for holding state of interrupt flag.

bool cpu_irq_is_enabled_flags ( irqflags_t  flags)
inlinestatic

Check if interrupts are globally enabled in supplied flags.

Parameters
flagsCurrents state of interrupt flags.
Returns
True if interrupts are enabled.

Referenced by cpu_irq_restore().

static bool cpu_irq_level_is_enabled_flags ( irqflags_t  flags,
uint32_t  level 
)
inlinestatic

Check if interrupt level is enabled in supplied flags.

Parameters
flagsState of interrupt flags.
levelBit position for interrupt level.
Returns
True if interrupt level is enabled.
void cpu_irq_restore ( irqflags_t  flags)
inlinestatic

Restore global interrupt flags.

Use in conjunction with cpu_irq_save.

Parameters
flagsState to set interrupt flag to.

References barrier, cpu_irq_enable, and cpu_irq_is_enabled_flags().

Referenced by osc_disable(), osc_enable(), sysclk_disable_pbb_module(), sysclk_enable_pbb_module(), sysclk_priv_disable_module(), sysclk_priv_enable_module(), and sysclk_set_source().

irqflags_t cpu_irq_save ( void  )
inlinestatic

Get and clear the global interrupt flags.

Use in conjunction with cpu_irq_restore.

Returns
Current state of interrupt flags.
Note
This function leaves interrupts disabled.

References cpu_irq_disable, and sysreg_read.

Referenced by osc_disable(), osc_enable(), sysclk_disable_pbb_module(), sysclk_enable_pbb_module(), sysclk_priv_disable_module(), sysclk_priv_enable_module(), and sysclk_set_source().