This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of internal software and hardware interrupts/exceptions.
The following peripheral is used by this module:
The following devices can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
The ARM® Cortex® M0+ core contains an interrupt and exception vector table, which can be used to configure the device's interrupt handlers; individual interrupts and exceptions can be enabled and disabled, as well as configured with a variable priority.
This driver provides a set of wrappers around the core interrupt functions, to expose a simple API for the management of global and individual interrupts within the device.
In some applications it is important to ensure that no interrupts may be executed by the system whilst a critical portion of code is being run; for example, a buffer may be copied from one context to another - during which interrupts must be disabled to avoid corruption of the source buffer contents until the copy has completed. This driver provides a basic API to enter and exit nested critical sections, so that global interrupts can be kept disabled for as long as necessary to complete a critical application code section.
For some applications, it may be desirable to raise a module or core interrupt via software. For this reason, a set of APIs to set an interrupt or exception as pending are provided to the user application.
Interrupts from peripherals in the SAM devices are on a per-module basis; an interrupt raised from any source within a module will cause a single, module-common handler to execute. It is the user application or driver's responsibility to de-multiplex the module-common interrupt to determine the exact interrupt cause.
For extra information, see Extra Information for SYSTEM INTERRUPT Driver. This includes:
For a list of examples related to this driver, see Examples for SYSTEM INTERRUPT Driver.
Critical Section Management | |
static void | system_interrupt_enter_critical_section (void) |
Enters a critical section. More... | |
static void | system_interrupt_leave_critical_section (void) |
Leaves a critical section. More... | |
Interrupt Enabling/Disabling | |
static bool | system_interrupt_is_global_enabled (void) |
Check if global interrupts are enabled. More... | |
static void | system_interrupt_enable_global (void) |
Enables global interrupts. More... | |
static void | system_interrupt_disable_global (void) |
Disables global interrupts. More... | |
static bool | system_interrupt_is_enabled (const enum system_interrupt_vector vector) |
Checks if an interrupt vector is enabled or not. More... | |
static void | system_interrupt_enable (const enum system_interrupt_vector vector) |
Enable interrupt vector. More... | |
static void | system_interrupt_disable (const enum system_interrupt_vector vector) |
Disable interrupt vector. More... | |
Interrupt State Management | |
static enum system_interrupt_vector | system_interrupt_get_active (void) |
Get active interrupt (if any). More... | |
bool | system_interrupt_is_pending (const enum system_interrupt_vector vector) |
Check if a interrupt line is pending. More... | |
enum status_code | system_interrupt_set_pending (const enum system_interrupt_vector vector) |
Set a interrupt vector as pending. More... | |
enum status_code | system_interrupt_clear_pending (const enum system_interrupt_vector vector) |
Clear pending interrupt vector. More... | |
Interrupt Priority Management | |
enum status_code | system_interrupt_set_priority (const enum system_interrupt_vector vector, const enum system_interrupt_priority_level priority_level) |
Set interrupt vector priority level. More... | |
enum system_interrupt_priority_level | system_interrupt_get_priority (const enum system_interrupt_vector vector) |
Get interrupt vector priority level. More... | |
Table of possible system interrupt/exception vector priorities.
Table of all possible interrupt and exception vector priorities within the device.
Table of possible system interrupt/exception vector numbers.
Table of all possible interrupt and exception vector indexes within the SAM D21 device. Check peripherals configuration in SAM D21 datasheet for available vector index for specific device.
enum status_code system_interrupt_clear_pending | ( | const enum system_interrupt_vector | vector | ) |
Clear pending interrupt vector.
Clear a pending interrupt vector, so the software handler is not executed.
[in] | vector | Interrupt vector number to clear |
STATUS_OK | If no error was detected |
STATUS_INVALID_ARG | If an unsupported interrupt vector number was given |
References Assert, STATUS_ERR_INVALID_ARG, STATUS_OK, SYSTEM_INTERRUPT_NON_MASKABLE, and SYSTEM_INTERRUPT_SYSTICK.
|
inlinestatic |
Disable interrupt vector.
Disables execution of the software handler for the requested interrupt vector.
[in] | vector | Interrupt vector to disable |
Referenced by spi_disable(), tcc_disable_callback(), and usart_disable().
|
inlinestatic |
Disables global interrupts.
Disabled global interrupts in the device, preventing any enabled interrupt handlers from executing.
References cpu_irq_disable.
|
inlinestatic |
Enable interrupt vector.
Enables execution of the software handler for the requested interrupt vector.
[in] | vector | Interrupt vector to enable |
Referenced by _system_extint_init(), spi_enable(), tcc_enable_callback(), and usart_enable().
|
inlinestatic |
Enables global interrupts.
Enables global interrupts in the device to fire any enabled interrupt handlers.
References cpu_irq_enable.
Referenced by nm_bsp_init().
|
inlinestatic |
Enters a critical section.
Disables global interrupts. To support nested critical sections, an internal count of the critical section nesting will be kept, so that global interrupts are only re-enabled upon leaving the outermost nested critical section.
References cpu_irq_enter_critical().
Referenced by _usart_read_buffer(), _usart_write_buffer(), spi_lock(), system_gclk_chan_disable(), system_gclk_chan_enable(), system_gclk_chan_get_hz(), system_gclk_chan_is_enabled(), system_gclk_chan_is_locked(), system_gclk_chan_lock(), system_gclk_gen_disable(), system_gclk_gen_enable(), system_gclk_gen_get_hz(), system_gclk_gen_is_enabled(), system_gclk_gen_set_config(), and usart_lock().
|
inlinestatic |
Get active interrupt (if any).
Return the vector number for the current executing software handler, if any.
enum system_interrupt_priority_level system_interrupt_get_priority | ( | const enum system_interrupt_vector | vector | ) |
Get interrupt vector priority level.
Retrieves the priority level of the requested external interrupt or exception.
[in] | vector | Interrupt vector of which the priority level will be read |
References SYSTEM_INTERRUPT_PRIORITY_LEVEL_0, and SYSTEM_INTERRUPT_SYSTICK.
|
inlinestatic |
Checks if an interrupt vector is enabled or not.
Checks if a specific interrupt vector is currently enabled.
[in] | vector | Interrupt vector number to check |
true | Specified interrupt vector is currently enabled |
false | Specified interrupt vector is currently disabled |
|
inlinestatic |
Check if global interrupts are enabled.
Checks if global interrupts are currently enabled.
true | Global interrupts are currently enabled |
false | Global interrupts are currently disabled |
References cpu_irq_is_enabled.
bool system_interrupt_is_pending | ( | const enum system_interrupt_vector | vector | ) |
Check if a interrupt line is pending.
Checks if the requested interrupt vector is pending.
[in] | vector | Interrupt vector number to check |
true | Specified interrupt vector is pending |
false | Specified interrupt vector is not pending |
References Assert, and SYSTEM_INTERRUPT_SYSTICK.
|
inlinestatic |
Leaves a critical section.
Enables global interrupts. To support nested critical sections, an internal count of the critical section nesting will be kept, so that global interrupts are only re-enabled upon leaving the outermost nested critical section.
References cpu_irq_leave_critical().
Referenced by _usart_read_buffer(), _usart_write_buffer(), spi_lock(), system_gclk_chan_disable(), system_gclk_chan_enable(), system_gclk_chan_get_hz(), system_gclk_chan_is_enabled(), system_gclk_chan_is_locked(), system_gclk_chan_lock(), system_gclk_gen_disable(), system_gclk_gen_enable(), system_gclk_gen_get_hz(), system_gclk_gen_is_enabled(), system_gclk_gen_set_config(), and usart_lock().
enum status_code system_interrupt_set_pending | ( | const enum system_interrupt_vector | vector | ) |
Set a interrupt vector as pending.
Set the requested interrupt vector as pending (i.e. issues a software interrupt request for the specified vector). The software handler will be handled (if enabled) in a priority order based on vector number and configured priority settings.
[in] | vector | Interrupt vector number which is set as pending |
STATUS_OK | If no error was detected |
STATUS_INVALID_ARG | If an unsupported interrupt vector number was given |
References Assert, STATUS_ERR_INVALID_ARG, STATUS_OK, SYSTEM_INTERRUPT_NON_MASKABLE, and SYSTEM_INTERRUPT_SYSTICK.
enum status_code system_interrupt_set_priority | ( | const enum system_interrupt_vector | vector, |
const enum system_interrupt_priority_level | priority_level | ||
) |
Set interrupt vector priority level.
Set the priority level of an external interrupt or exception.
[in] | vector | Interrupt vector to change |
[in] | priority_level | New vector priority level to set |
STATUS_OK | If no error was detected |
STATUS_INVALID_ARG | If an unsupported interrupt vector number was given |
References Assert, STATUS_ERR_INVALID_ARG, STATUS_OK, and SYSTEM_INTERRUPT_SYSTICK.