Interrupt Module¶
The Interrupt API provides a set of functions for configuring the NVIC module in the Cortex M core. Functions are provided to configure various interrupts and exceptions in the system
-
group
interrupt_api This module configures the NVIC interrupt controller.
Enums
-
enum
Interrupt_PriorityGrouping¶ Values that can be passed to Interrupt_setPriorityGrouping() as priGroup parameter.
Values:
-
enumerator
Interrupt_PriorityGrouping_7_1= 0x00000000U¶ Priority group 7.1 split.
-
enumerator
Interrupt_PriorityGrouping_6_2= 0x00000100U¶ Priority group 6.2 split.
-
enumerator
Interrupt_PriorityGrouping_5_3= 0x00000200U¶ Priority group 5.3 split.
-
enumerator
Interrupt_PriorityGrouping_4_4= 0x00000300U¶ Priority group 4.4 split.
-
enumerator
Interrupt_PriorityGrouping_3_5= 0x00000400U¶ Priority group 3.5 split.
-
enumerator
Interrupt_PriorityGrouping_2_6= 0x00000500U¶ Priority group 2.6 split.
-
enumerator
Interrupt_PriorityGrouping_1_7= 0x00000600U¶ Priority group 1.7 split.
-
enumerator
Interrupt_PriorityGrouping_0_8= 0x00000700U¶ Priority group 0.8 split.
-
enumerator
Functions
-
void
Interrupt_defaultHandler(void)¶
-
bool
Interrupt_enableInProcessor(void)¶ Enables the processor interrupt.
This function allows the processor to respond to interrupts. This function does not affect the set of interrupts enabled in the interrupt controller, it just gates the single interrupt from the controller to the processor.
- Return
Returns true if interrupts were disabled when the function was called or false if they were initially enabled.
-
bool
Interrupt_disableInProcessor(void)¶ Disables the processor interrupt.
This function prevents the processor from receiving interrupts. This function does not affect the set of interrupts enabled in the interrupt controller; it just gates the single interrupt from the controller to the processor.
- Return
Returns true if interrupts were already disabled when the function was called or false if they were initially enabled.
-
void
Interrupt_setSoftwareTrigger(uint32_t interruptNum)¶ Triggers an interrupt.
This function performs a software trigger of an interrupt.The interrupt controller behaves as if the corresponding interrupt line was asserted, and the interrupt is handled in the same manner (meaning that it must be enabled in order to be processed, and the processing is based on its priority with respect to other unhandled interrupts).
- Parameters
interruptNum: specifies the interrupt to be triggered.
- Return
None.
-
void
Interrupt_setVectorTableOffset(uint32_t addr)¶ Sets the offset address of the vector table.
Sets the address of the vector table. This function is for advanced users who might want to switch between multiple instances of vector tables (perhaps between flash/ram). The param addr can take following values: (uint32_t)vectorTableFlash - Offset address for Flash Vector Table (uint32_t)vectorTableRAM - Offset address for RAM Vector Table
- Parameters
addr: is the new address of the vector table.
- Return
None.
-
uint32_t
Interrupt_getVectorTableOffset(void)¶ Returns the offset address of the interrupt vector table.
This function returns the offset address of the interrupt vector table.
- Return
Offset address of the vector table.
-
void
Interrupt_setPriorityGrouping(Interrupt_PriorityGrouping priGrouping)¶ Sets the priority grouping of the interrupt controller.
This function specifies the split between preemptable priority levels and sub-priority levels in the interrupt priority specification. The range of the grouping values are dependent upon the hardware implementation; on the MSP432 family, three bits are available for hardware interrupt prioritization and therefore priority grouping values of three through seven have the same effect.
- Parameters
priGrouping: specifies the required priority grouping
- Return
None.
-
uint32_t
Interrupt_getPriorityGrouping(void)¶ Gets the priority grouping of the interrupt controller.
This function returns the split between preemptable priority levels and sub-priority levels in the interrupt priority specification.
- Return
The number of bits of preemptable priority.
-
void
Interrupt_requestSystemReset(void)¶ Resets the core and all on-chip peripherals except Debug interface.
This function will perform a software reset of the entire device. The processor and all peripherals will be reset and all device registers will return to their default values (with the exception of the reset cause register, which will maintain its current value but have the software reset bit set as well).
- Return
None
-
void
Interrupt_setPriorityMask(uint32_t priorityMask)¶ Sets the priority masking level.
This function sets the interrupt priority masking level so that all interrupts at the specified or lesser priority level are masked. Masking interrupts can be used to globally disable a set of interrupts with priority below a predetermined threshold. A value of 0 disables priority masking.
- Parameters
priorityMask: is the priority level that is masked.
Smaller numbers correspond to higher interrupt priorities. So for example a priority level mask of 4 allows interrupts of priority level 0-3, and interrupts with a numerical priority of 4 and greater are blocked.
- Return
None.
-
uint32_t
Interrupt_getPriorityMask(void)¶ Gets the priority masking level.
This function gets the current setting of the interrupt priority masking level. The value returned is the priority level such that all interrupts of that and lesser priority are masked. A value of 0 means that priority masking is disabled.
Smaller numbers correspond to higher interrupt priorities. So for example a priority level mask of 4 allows interrupts of priority level 0-3, and interrupts with a numerical priority of 4 and greater are blocked.
- Return
Returns the value of the interrupt priority level mask.
-
void
Interrupt_enableSleepOnISRExit(void)¶ Enables the processor to sleep when exiting an ISR.
This function enables the processor to sleep when exiting an ISR. For low power operation, this is ideal as power cycles are not wasted with the processing required for waking up from an ISR and going back to sleep.
- Return
None
-
void
Interrupt_disableSleepOnISRExit(void)¶ Disables the processor to sleep when exiting an ISR.
This function disables the processor to sleep when exiting an ISR.
- Return
None
-
void
Interrupt_unregisterHandler(uint32_t interruptNum)¶ Unregisters the function to be called when an interrupt occurs.
This function is used to indicate that no handler should be called when the given interrupt is asserted to the processor. The interrupt source is automatically disabled (via Interrupt_disableInterrupt()) if necessary.
See
Interrupt_enable() for details about the interrupt parameter- See
Interrupt_registerInterrupt() for important information about registering interrupt handlers.
- Return
None.
-
void
Interrupt_registerHandler(uint32_t interruptNum, void (*intHandler)(void))¶ Registers a function to be called when an interrupt occurs.
See
Interrupt_enable() for details about the interrupt parameter- Note
The use of this function (directly or indirectly via a peripheral driver interrupt register function) moves the interrupt vector table from flash to SRAM. Therefore, care must be taken when linking the application to ensure that the SRAM vector table is located at the beginning of SRAM, otherwise the NVIC does not look in the correct portion of memory for the vector table (it requires the vector table be on a 1 kB memory alignment). Normally, the SRAM vector table is so placed via the use of linker scripts. See the discussion of compile-time versus run-time interrupt handler registration in the introduction to this chapter.
- Note
This function is only used if the customer wants to specify the interrupt handler at run time. In most cases, this is done through means of the user setting the ISR function pointer in the startup file. Refer Refer to the Module Operation section for more details.
- Parameters
interruptNum: specifies the interrupt in question.intHandler: is a pointer to the function to be called.
- Return
None.
-
void
Interrupt_enable(uint32_t interruptNum)¶ Enables an interrupt in interrupt controller.
This function enables the specified interrupt in the interrupt controller. The parameter interruptNum can take any of the valid interrupts from
hw_ints.h file. Other enables for the interrupt (such as at the peripheral level) are unaffected by this function.- Parameters
interruptNum: is the interrupt to be enabled.
- Return
None.
-
void
Interrupt_disable(uint32_t interruptNum)¶ Disables an interrupt in interrupt controller.
This function disables the specified interrupt in the interrupt controller. The parameter interruptNum can take any of the valid interrupts from
hw_ints.h file. Other enables for the interrupt (such as at the peripheral level) are unaffected by this function.- Parameters
interruptNum: is the interrupt to be disabled.
- Return
None.
-
bool
Interrupt_isEnabled(uint32_t interruptNum)¶ Returns if a peripheral interrupt is enabled.
This function checks if the specified interrupt is enabled in the interrupt controller. The
interruptNum parameter must be one of the valid interrupts defined in the inc/hw_ints.h header file.- Parameters
interruptNum: is the interrupt to be checked.
- Return
None.
-
void
Interrupt_pend(uint32_t interruptNum)¶ Pends an interrupt.
The specified interrupt is pended in the interrupt controller. Pending an interrupt causes the interrupt controller to execute the corresponding interrupt handler at the next available time, based on the current interrupt state priorities. For example, if called by a higher priority interrupt handler, the specified interrupt handler is not called until after the current interrupt handler has completed execution. The interrupt must have been enabled for it to be called.
- Parameters
interruptNum: specifies the interrupt to be pended.
See Interrupt_enable() for details about the interrupt parameter
- Return
None.
-
void
Interrupt_unpend(uint32_t interruptNum)¶ Un-pends an interrupt.
The specified interrupt is un-pended in the interrupt controller. This will cause any previously generated interrupts that have not been handled yet (due to higher priority interrupts or the interrupt no having been enabled yet) to be discarded.
- Parameters
interruptNum: specifies the interrupt to be un-pended.
See Interrupt_enable() for details about the interrupt parameter
- Return
None.
-
void
Interrupt_setPriority(uint32_t interruptNum, uint32_t priority)¶ Sets the priority of an interrupt.
This function is used to set the priority of an interrupt. When multiple interrupts are asserted simultaneously, the ones with the highest priority are processed before the lower priority interrupts. Smaller numbers correspond to higher interrupt priorities; priority 0 is the highest interrupt priority.
- Parameters
interruptNum: specifies the interrupt in question.priority: specifies the priority of the interrupt.
The hardware priority mechanism only looks at the upper N bits of the priority level, so any prioritization must be performed in those bits. The remaining bits can be used to sub-prioritize the interrupt sources, and may be used by the hardware priority mechanism on a future part. This arrangement allows priorities to migrate to different NVIC implementations without changing the gross prioritization of the interrupts.
See Interrupt_enable() for details about the interrupt parameter
- Return
None.
-
uint32_t
Interrupt_getPriority(uint32_t interruptNum)¶ Gets the priority of an interrupt.
This function gets the priority of an interrupt. See
Interrupt_setPriority() for a definition of the priority value.- Parameters
interruptNum: specifies the interrupt in question.
See Interrupt_enable() for details about the interrupt parameter
- Return
Returns the interrupt priority, or -1 if an invalid interrupt was specified.
-
void
Interrupt_initRAMVectorTable(void (*srcVectorTable[])(void), void (*dstVectorTable[])(void))¶ Initializes all the ISRs in the RAM vector table.
This function initializes all the ISRs in the RAM vector table. It copies the ISR addresses from temporary source table to destination RAM vector table. The
srcVectorTable can be preinitialised table which can be used to initialize vector table in one go. dstVectorTable can be the RAM vector table to be populated.- Parameters
srcVectorTable: is source vector table arraydstVectorTable: is destination vector table array
- Return
None
-
enum
The code for this module is contained in driverlib_cm/interrupt.c, with driverlib_cm/interrupt.h containing the API declarations for use by applications.