Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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...
 

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

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

#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_level (   level)
Value:
do { \
__builtin_ssrf(TPASTE3(AVR32_SR_I, level, M_OFFSET)); \
} while (0)
#define barrier()
Memory barrier.
Definition: compiler.h:106
#define TPASTE3(a, b, c)
Definition: tpaste.h:69

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_level (   level)
Value:
do { \
__builtin_csrf(TPASTE3(AVR32_SR_I, level, M_OFFSET)); \
} while (0)
#define barrier()
Memory barrier.
Definition: compiler.h:106
#define TPASTE3(a, b, c)
Definition: tpaste.h:69

Enable interrupt level.

Parameters
levelInterrupt level to enable (0 to 3).
Note
The interrupt level must be known at compile time.
#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:244
#define sysreg_read(reg)
Get value of system register.
Definition: compiler.h:164
#define TPASTE3(a, b, c)
Definition: tpaste.h:69

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.

Referenced by _init_startup(), init_interrupts(), init_timer_isr(), main(), and sensor_board_init().

#define irq_register_handler (   func,
  int_num,
  int_lvl 
)
Value:
INTC_register_interrupt(func, int_num, \
TPASTE2(AVR32_INTC_INT, int_lvl))
void INTC_register_interrupt(__int_handler handler, uint32_t irq, uint32_t int_level)
Registers an interrupt handler.
Definition: intc.c:257
#define TPASTE2(a, b)
Definition: tpaste.h:68

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:

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

Referenced by at42qt1060_register_int(), init_timer_isr(), main(), otg_dual_enable(), tpa6130_dac_start(), twi_master_init(), twi_slave_init(), uart_open(), and udd_enable().

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

ISR(foo_irq_handler, AVR32_xxx_IRQ_GROUP, n)
{
// Function definition
...
}
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 at42qt1060_register_int(), eic_clear_interrupt_line(), eic_clear_interrupt_lines(), eic_disable_interrupt_line(), eic_disable_interrupt_lines(), ili9341_send_byte(), osc_disable(), osc_enable(), pdca_disable_interrupt_reload_counter_zero(), pdca_disable_interrupt_transfer_complete(), pdca_disable_interrupt_transfer_error(), pdca_init_channel(), pdca_load_channel(), pdca_reload_channel(), sleepmgr_lock_mode(), sleepmgr_unlock_mode(), sysclk_disable_pbb_module(), sysclk_enable_pbb_module(), sysclk_priv_disable_module(), sysclk_priv_enable_module(), sysclk_set_source(), twi_disable_interrupt(), twi_master_init(), twi_slave_init(), udd_attach(), udd_ctrl_in_sent(), udd_ctrl_init(), udd_ctrl_out_received(), udd_ctrl_send_zlp_in(), udd_ctrl_send_zlp_out(), udd_ctrl_setup_received(), udd_disable(), udd_enable(), udd_reset_ep_ctrl(), udi_cdc_ctrl_state_change(), udi_cdc_multi_get_free_tx_buffer(), udi_cdc_multi_get_nb_received_data(), udi_cdc_multi_getc(), udi_cdc_multi_putc(), udi_cdc_multi_read_buf(), udi_cdc_multi_write_buf(), udi_cdc_rx_start(), udi_cdc_tx_send(), udi_hid_generic_send_report_in(), udi_hid_kbd_down(), udi_hid_kbd_modifier_down(), udi_hid_kbd_modifier_up(), udi_hid_kbd_up(), udi_hid_mouse_move(), udi_phdc_senddata(), udi_phdc_waitdata(), uhd_ctrl_request_end(), uhd_disable(), uhd_enable(), uhd_ep_run(), uhd_pipe_trans_complet(), uhd_setup_request(), uhi_cdc_putc(), uhi_cdc_rx_update(), uhi_cdc_tx_send(), uhi_cdc_tx_update(), uhi_cdc_write_buf(), win_are_events_pending(), win_pop_front_event(), and win_queue_event().

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 at42qt1060_register_int(), eic_clear_interrupt_line(), eic_clear_interrupt_lines(), eic_disable_interrupt_line(), eic_disable_interrupt_lines(), ili9341_send_byte(), osc_disable(), osc_enable(), pdca_disable_interrupt_reload_counter_zero(), pdca_disable_interrupt_transfer_complete(), pdca_disable_interrupt_transfer_error(), pdca_init_channel(), pdca_load_channel(), pdca_reload_channel(), sleepmgr_lock_mode(), sleepmgr_unlock_mode(), sysclk_disable_pbb_module(), sysclk_enable_pbb_module(), sysclk_priv_disable_module(), sysclk_priv_enable_module(), sysclk_set_source(), twi_disable_interrupt(), twi_master_init(), twi_slave_init(), udd_attach(), udd_ctrl_in_sent(), udd_ctrl_init(), udd_ctrl_out_received(), udd_ctrl_send_zlp_in(), udd_ctrl_send_zlp_out(), udd_ctrl_setup_received(), udd_disable(), udd_enable(), udd_reset_ep_ctrl(), udi_cdc_ctrl_state_change(), udi_cdc_multi_get_free_tx_buffer(), udi_cdc_multi_get_nb_received_data(), udi_cdc_multi_getc(), udi_cdc_multi_putc(), udi_cdc_multi_read_buf(), udi_cdc_multi_write_buf(), udi_cdc_rx_start(), udi_cdc_tx_send(), udi_hid_generic_send_report_in(), udi_hid_kbd_down(), udi_hid_kbd_modifier_down(), udi_hid_kbd_modifier_up(), udi_hid_kbd_up(), udi_hid_mouse_move(), udi_phdc_senddata(), udi_phdc_waitdata(), uhd_ctrl_request_end(), uhd_disable(), uhd_enable(), uhd_ep_run(), uhd_pipe_trans_complet(), uhd_setup_request(), uhi_cdc_putc(), uhi_cdc_rx_update(), uhi_cdc_tx_send(), uhi_cdc_tx_update(), uhi_cdc_write_buf(), win_are_events_pending(), win_pop_front_event(), and win_queue_event().