Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator 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...
 

Functions

void cpu_irq_enter_critical (void)
 
void cpu_irq_leave_critical (void)
 

Variables

static volatile uint32_t cpu_irq_critical_section_counter
 
static volatile bool cpu_irq_prev_interrupt_state
 

Interrupt Service Routine definition

#define ISR(func)   void func (void)
 Define service routine. More...
 
#define irq_initialize_vectors()
 Initialize interrupt vectors. More...
 
#define irq_register_handler(int_num, int_prio)
 Register handler for interrupt. 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()   (__get_PRIMASK() == 0)
 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 ( )
Value:
do { \
__disable_irq(); \
__DMB(); \
g_interrupt_enabled = false; \
} while (0)

Disable interrupts globally.

Referenced by cpu_irq_enter_critical(), cpu_irq_save(), main(), program_memory(), sleepmgr_enter_sleep(), sleepmgr_sleep(), start_application_with_wdt(), and usb_rx_notify().

#define cpu_irq_enable ( )
Value:
do { \
g_interrupt_enabled = true; \
__DMB(); \
__enable_irq(); \
} while (0)

Enable interrupts globally.

Referenced by bootloader_system_init(), bpm_sleep(), cpu_irq_leave_critical(), cpu_irq_restore(), firmware_gen_system_init(), main(), program_memory(), sleepmgr_enter_sleep(), sleepmgr_sleep(), and usb_rx_notify().

#define cpu_irq_is_enabled ( )    (__get_PRIMASK() == 0)

Check if interrupts are globally enabled.

Returns
True if interrupts are enabled.

Referenced by cpu_irq_enter_critical(), and cpu_irq_save().

#define irq_initialize_vectors ( )
Value:
do { \
} while(0)

Initialize interrupt vectors.

For NVIC the interrupt vectors are put in vector table. So nothing to do to initialize them, except defined the vector function with right name.

This must be called prior to irq_register_handler.

Referenced by main().

#define irq_register_handler (   int_num,
  int_prio 
)
Value:
NVIC_ClearPendingIRQ( (IRQn_Type)int_num); \
NVIC_SetPriority( (IRQn_Type)int_num, int_prio); \
NVIC_EnableIRQ( (IRQn_Type)int_num); \

Register handler for interrupt.

For NVIC the interrupt vectors are put in vector table. So nothing to do to register them, except defined the vector function with right name.

Usage:

Note
The function func must be defined with the ISR macro.
The functions prototypes can be found in the device exception header files (exceptions.h).

Referenced by abdac_set_callback(), ac_set_callback(), adc_set_callback(), aes_set_callback(), eic_line_set_callback(), freqm_set_callback(), pdca_channel_set_callback(), and twis_set_callback().

#define ISR (   func)    void func (void)

Define service routine.

Note
For NVIC devices the interrupt service routines are predefined to add to vector table in binary generation, so there is no service register at run time. The routine collections are in exceptions.h.

Usage:

ISR(foo_irq_handler)
{
// Function definition
...
}
Parameters
funcName for the function.

Type used for holding state of interrupt flag.

void cpu_irq_enter_critical ( void  )
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().

void cpu_irq_leave_critical ( void  )
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 cpu_irq_enable, and cpu_irq_is_enabled_flags().

Referenced by bpm_power_scaling_cpu_failsafe(), dfll_enable_closed_loop(), dfll_enable_open_loop(), osc_priv_disable_rc1m(), osc_priv_disable_rc32k(), osc_priv_disable_rc80m(), osc_priv_disable_rcfast(), osc_priv_enable_rc1m(), osc_priv_enable_rc32k(), osc_priv_enable_rc80m(), osc_priv_enable_rcfast(), pll_config_write(), pll_disable(), pll_enable(), restore_cpu_interrupt(), sleepmgr_lock_mode(), sleepmgr_unlock_mode(), sw_timer_service(), SYS_TimerTaskHandler(), sysclk_disable_pba_module(), sysclk_disable_pbb_module(), sysclk_enable_pba_module(), sysclk_enable_pbb_module(), sysclk_init(), sysclk_priv_disable_module(), sysclk_priv_enable_module(), sysclk_set_prescalers(), sysclk_set_source(), udd_attach(), udd_ctrl_in_sent(), 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_read_no_polling(), 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(), and uhi_cdc_write_buf().

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, cpu_irq_is_enabled, and pbuf::flags.

Referenced by bpm_power_scaling_cpu_failsafe(), dfll_enable_closed_loop(), dfll_enable_open_loop(), osc_priv_disable_rc1m(), osc_priv_disable_rc32k(), osc_priv_disable_rc80m(), osc_priv_disable_rcfast(), osc_priv_enable_rc1m(), osc_priv_enable_rc32k(), osc_priv_enable_rc80m(), osc_priv_enable_rcfast(), pll_config_write(), pll_disable(), pll_enable(), save_cpu_interrupt(), sleepmgr_lock_mode(), sleepmgr_unlock_mode(), sw_timer_service(), SYS_TimerTaskHandler(), sysclk_disable_pba_module(), sysclk_disable_pbb_module(), sysclk_enable_pba_module(), sysclk_enable_pbb_module(), sysclk_init(), sysclk_priv_disable_module(), sysclk_priv_enable_module(), sysclk_set_prescalers(), sysclk_set_source(), udd_attach(), udd_ctrl_in_sent(), 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_read_no_polling(), 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(), and uhi_cdc_write_buf().

volatile uint32_t cpu_irq_critical_section_counter
static
volatile bool cpu_irq_prev_interrupt_state
static