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
 

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

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

#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(), and cpu_irq_save().

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

Enable interrupts globally.

Referenced by cpu_irq_leave_critical(), and cpu_irq_restore().

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

#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).
#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 efc_perform_command().

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

Referenced by efc_perform_command().

volatile uint32_t cpu_irq_critical_section_counter
static
volatile bool cpu_irq_prev_interrupt_state
static