![]() |
![]() |
Hardware Interrupt module for the RTOS Porting Interface.
============================================================================
The HwiP_disable()/HwiP_restore() APIs can be called recursively. The order of the HwiP_restore() calls, must be in reversed order. For example:
The following sections highlight some important items to consider when using the HwiP DPL. Due to the nature and intention of different operating systems, the HwiP DPL implementation may differ depending on the underlying platform and operating system.
On Arm Cortex-M platforms, the highest logical interrupt priority has the lowest numerical value. That is, 0 is the highest interrupt priority (interrupt level 0 has the highest urgency). The number of interrupt priorities is given by the number of interrupt priority bits implemented, which is vendor-specific.
For example:
| Device Family | Architecture | Priority Bits | Priority Levels |
|---|---|---|---|
| CC23X0 | Armv6-m | 2 | 4 (0-3) |
| CC13X2_CC26X2 | Armv7-m | 3 | 8 (0-7) |
| CC13X4_CC26X4 | Armv8-m | 3 | 8 (0-7) |
| CC27XX | Armv8-m | 4 | 16 (0-15) |
On Arm Cortex-M platforms, interrupt priority values are stored in the most significant bits of the 8-bit interrupt priority registers. For example, with 3 interrupt priority bits implemented, interrupt priority level 2 (0b010) is represented in the interrupt priority registers as 0b010 << (8-3) = 0x40. This is automatically handled by SysConfig, but may cause some confusion, for example, when inspecting the raw value of the HwiP_Params.priority field or the Cortex-M interrupt priority registers.
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html for more details.
Arm Cortex-M devices may support 2 methods for masking interrupts
PRIMASK disables all interrupt levels indiscriminately (with the exception of non-maskable interrupts).BASEPRI disables interrupts with priority equal to or lower than a certain level. Software can set BASEPRI to a priority level between 1 (second highest priority) and the maximum supported priority level (lowest priority). This means that interrupt priority level 0 cannot be masked using BASEPRI.The table gives an overview of what interrupt masking controls the different Arm platforms support:
| Architecture | PRIMASK | BASEPRI |
|---|---|---|
| Armv6-m | Yes | No |
| Armv7-m | Yes | Yes |
| Armv8-m | Yes | Yes |
On Cortex-M platforms that support BASEPRI, the FreeRTOS kernel does not completely disable interrupts even inside critical sections. This is achieved by these FreeRTOS configurations:
configMAX_SYSCALL_INTERRUPT_PRIORITY defines the highest logical priority at which FreeRTOS kernel API calls can be made.configKERNEL_INTERRUPT_PRIORITY sets the priority of the FreeRTOS kernel itself, usually the lowest logical priority possible.This permits a fully nested model where higher-priority interrupts can preempt lower-priority ones. However, interrupts that require FreeRTOS API calls must adhere to the configMAX_SYSCALL_INTERRUPT_PRIORITY limit to avoid corrupting kernel data.
See https://www.freertos.org/a00110.html#kernel_priority for more details.
BASEPRI to configMAX_SYSCALL_INTERRUPT_PRIORITY. Returns original BASEPRI.BASEPRI to 0 (no interrupts are masked).TI-RTOS behaves similar to FreeRTOS, meaning that on Cortex-M platforms that support BASEPRI, the TI-RTOS kernel does not completely disable interrupts even inside critical sections.
BASEPRI to Hwi_disablePriority. Returns original BASEPRI.BASEPRI to the provided argument value.See TI-RTOS Hwi documentation for more details.
#include <stdint.h>#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Data Structures | |
| union | HwiP_Struct |
| HwiP structure. More... | |
| struct | HwiP_Params |
| Basic HwiP Parameters. More... | |
Macros | |
| #define | HwiP_STRUCT_SIZE (28) |
| Number of bytes greater than or equal to the size of any RTOS HwiP object. More... | |
Typedefs | |
| typedef union HwiP_Struct | HwiP_Struct |
| HwiP structure. More... | |
| typedef void * | HwiP_Handle |
| Opaque client reference to an instance of a HwiP. More... | |
| typedef void(* | HwiP_Fxn) (uintptr_t arg) |
| Prototype for the entry function for a hardware interrupt. More... | |
Enumerations | |
| enum | HwiP_Status { HwiP_OK = 0, HwiP_FAILURE = -1 } |
| Status codes for HwiP APIs. More... | |
Functions | |
| HwiP_Handle | HwiP_construct (HwiP_Struct *handle, int interruptNum, HwiP_Fxn hwiFxn, HwiP_Params *params) |
| Function to construct a hardware interrupt object. More... | |
| void | HwiP_destruct (HwiP_Struct *handle) |
| Function to destruct a hardware interrupt object. More... | |
| void | HwiP_clearInterrupt (int interruptNum) |
| Function to clear a single interrupt. More... | |
| HwiP_Handle | HwiP_create (int interruptNum, HwiP_Fxn hwiFxn, HwiP_Params *params) |
| Function to create an interrupt on CortexM devices. More... | |
| void | HwiP_delete (HwiP_Handle handle) |
| Function to delete an interrupt on CortexM devices. More... | |
| uintptr_t | HwiP_disable (void) |
| Function to disable interrupts to enter a critical region. More... | |
| void | HwiP_enable (void) |
| Function to enable interrupts. More... | |
| void | HwiP_disableInterrupt (int interruptNum) |
| Function to disable a single interrupt. More... | |
| void | HwiP_enableInterrupt (int interruptNum) |
| Function to enable a single interrupt. More... | |
| bool | HwiP_inISR (void) |
| Function to return a status based on whether it is in an interrupt context. More... | |
| bool | HwiP_interruptsEnabled (void) |
| Function to determine whether interrupts are currently enabled. More... | |
| void | HwiP_Params_init (HwiP_Params *params) |
| Initialize params structure to default values. More... | |
| void | HwiP_plug (int interruptNum, void *fxn) |
| Function to plug an interrupt vector. More... | |
| void | HwiP_post (int interruptNum) |
| Function to generate an interrupt. More... | |
| void | HwiP_restore (uintptr_t key) |
| Function to restore interrupts to exit a critical region. More... | |
| void | HwiP_setFunc (HwiP_Handle handle, HwiP_Fxn fxn, uintptr_t arg) |
| Function to overwrite HwiP function and arg. More... | |
| void | HwiP_setPriority (int interruptNum, uint32_t priority) |
| Function to set the priority of a hardware interrupt. More... | |
| void | HwiP_dispatchInterrupt (int interruptNum) |
| Function to call the HW ISR function registered by HwiP_construct() More... | |
Variables | |
| int | HwiP_swiPIntNum |
| Interrupt number posted by SwiP. More... | |
| #define HwiP_STRUCT_SIZE (28) |
Number of bytes greater than or equal to the size of any RTOS HwiP object.
NoRTOS: 12 FreeRTOS: 12 BIOS 6.x: 28 BIOS 7.x: 20
| typedef union HwiP_Struct HwiP_Struct |
HwiP structure.
Opaque structure that should be large enough to hold any of the RTOS specific HwiP objects.
| typedef void* HwiP_Handle |
Opaque client reference to an instance of a HwiP.
A HwiP_Handle returned from the HwiP_create() represents that instance.
| typedef void(* HwiP_Fxn) (uintptr_t arg) |
Prototype for the entry function for a hardware interrupt.
| enum HwiP_Status |
| HwiP_Handle HwiP_construct | ( | HwiP_Struct * | handle, |
| int | interruptNum, | ||
| HwiP_Fxn | hwiFxn, | ||
| HwiP_Params * | params | ||
| ) |
Function to construct a hardware interrupt object.
| handle | Pointer to HwiP_Struct object. |
| interruptNum | Interrupt Vector Id |
| hwiFxn | entry function of the hardware interrupt |
| params | Pointer to the instance configuration parameters. NULL denotes to use the default parameters. The HwiP default parameters are noted in HwiP_Params_init(). |
| void HwiP_destruct | ( | HwiP_Struct * | handle | ) |
Function to destruct a hardware interrupt object.
| handle | Pointer to a HwiP_Struct object that was passed to HwiP_construct(). |
| void HwiP_clearInterrupt | ( | int | interruptNum | ) |
Function to clear a single interrupt.
| interruptNum | interrupt number to clear |
| HwiP_Handle HwiP_create | ( | int | interruptNum, |
| HwiP_Fxn | hwiFxn, | ||
| HwiP_Params * | params | ||
| ) |
Function to create an interrupt on CortexM devices.
| interruptNum | Interrupt Vector Id |
| hwiFxn | entry function of the hardware interrupt |
| params | Pointer to the instance configuration parameters. NULL denotes to use the default parameters. The HwiP default parameters are noted in HwiP_Params_init(). |
| void HwiP_delete | ( | HwiP_Handle | handle | ) |
Function to delete an interrupt on CortexM devices.
| handle | returned from the HwiP_create call |
| uintptr_t HwiP_disable | ( | void | ) |
Function to disable interrupts to enter a critical region.
This function can be called multiple times, but must unwound in the reverse order. For example
| void HwiP_enable | ( | void | ) |
Function to enable interrupts.
| void HwiP_disableInterrupt | ( | int | interruptNum | ) |
Function to disable a single interrupt.
| interruptNum | interrupt number to disable |
| void HwiP_enableInterrupt | ( | int | interruptNum | ) |
Function to enable a single interrupt.
| interruptNum | interrupt number to enable |
| bool HwiP_inISR | ( | void | ) |
Function to return a status based on whether it is in an interrupt context.
| bool HwiP_interruptsEnabled | ( | void | ) |
Function to determine whether interrupts are currently enabled.
| void HwiP_Params_init | ( | HwiP_Params * | params | ) |
Initialize params structure to default values.
The default parameters are:
| params | Pointer to the instance configuration parameters. |
| void HwiP_plug | ( | int | interruptNum, |
| void * | fxn | ||
| ) |
Function to plug an interrupt vector.
| interruptNum | ID of interrupt to plug |
| fxn | ISR that services plugged interrupt |
| void HwiP_post | ( | int | interruptNum | ) |
Function to generate an interrupt.
| interruptNum | ID of interrupt to generate |
| void HwiP_restore | ( | uintptr_t | key | ) |
Function to restore interrupts to exit a critical region.
| key | return from HwiP_disable |
| void HwiP_setFunc | ( | HwiP_Handle | handle, |
| HwiP_Fxn | fxn, | ||
| uintptr_t | arg | ||
| ) |
Function to overwrite HwiP function and arg.
| handle | Handle returned from the HwiP_create() or HwiP_construct() call |
| fxn | pointer to ISR function |
| arg | argument to ISR function |
| void HwiP_setPriority | ( | int | interruptNum, |
| uint32_t | priority | ||
| ) |
Function to set the priority of a hardware interrupt.
| interruptNum | id of the interrupt to change |
| priority | new priority |
| void HwiP_dispatchInterrupt | ( | int | interruptNum | ) |
Function to call the HW ISR function registered by HwiP_construct()
| interruptNum | Interrupt Vector Id |
| int HwiP_swiPIntNum |
Interrupt number posted by SwiP.
The SwiP module needs its scheduler to run at key points in SwiP processing. This is accomplished via an interrupt that is configured at the lowest possible interrupt priority level and is plugged with the SwiP scheduler. This interrupt must be the only interrupt at that lowest priority. SwiP will post this interrupt whenever its scheduler needs to run.
The default value for your device should suffice, but if a different interrupt is needed to be used for SwiP scheduling then HwiP_swiPIntNum can be assigned with this interrupt (early on, before HwiPs are created and before any SwiP gets posted).