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:
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
§ HwiP_STRUCT_SIZE
#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
§ HwiP_Struct
HwiP structure.
Opaque structure that should be large enough to hold any of the RTOS specific HwiP objects.
§ HwiP_Handle
Opaque client reference to an instance of a HwiP.
A HwiP_Handle returned from the HwiP_create represents that instance.
§ HwiP_Fxn
typedef void(* HwiP_Fxn) (uintptr_t arg) |
Prototype for the entry function for a hardware interrupt.
§ HwiP_Status
Status codes for HwiP APIs.
Enumerator |
---|
HwiP_OK | |
HwiP_FAILURE | |
§ HwiP_construct()
Function to construct a hardware interrupt object.
- Parameters
-
hwiP | 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. |
- Returns
- A HwiP_Handle on success or a NULL on an error
§ HwiP_destruct()
Function to destruct a hardware interrupt object.
- Parameters
-
- Returns
§ HwiP_clearInterrupt()
void HwiP_clearInterrupt |
( |
int |
interruptNum | ) |
|
Function to clear a single interrupt.
- Parameters
-
interruptNum | interrupt number to clear |
§ HwiP_create()
Function to create an interrupt on CortexM devices.
- Note
- This function may not be available on all implementations
- Parameters
-
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. |
- Returns
- A HwiP_Handle on success or a NULL on an error
§ HwiP_delete()
Function to delete an interrupt on CortexM devices.
- Note
- This function may not be available on all implementations
- Parameters
-
handle | returned from the HwiP_create call |
- Returns
§ HwiP_disable()
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
- Returns
- A key that must be passed to HwiP_restore to re-enable interrupts.
§ HwiP_enable()
void HwiP_enable |
( |
void |
| ) |
|
Function to enable interrupts.
§ HwiP_disableInterrupt()
void HwiP_disableInterrupt |
( |
int |
interruptNum | ) |
|
Function to disable a single interrupt.
- Parameters
-
interruptNum | interrupt number to disable |
§ HwiP_enableInterrupt()
void HwiP_enableInterrupt |
( |
int |
interruptNum | ) |
|
Function to enable a single interrupt.
- Parameters
-
interruptNum | interrupt number to enable |
§ HwiP_inISR()
Function to return a status based on whether it is in an interrupt context.
- Returns
- A status: indicating whether the function was called in an ISR (true) or at thread level (false).
§ HwiP_interruptsEnabled()
bool HwiP_interruptsEnabled |
( |
void |
| ) |
|
Function to determine whether interrupts are currently enabled.
- Returns
- Current state of interrupts.
- true Interrupts are currently enabled.
- false Interrupts are currently disabled.
§ HwiP_Params_init()
Initialize params structure to default values.
The default parameters are:
- arg: 0
- priority: ~0
- enableInt: true
- Parameters
-
params | Pointer to the instance configuration parameters. |
§ HwiP_plug()
void HwiP_plug |
( |
int |
interruptNum, |
|
|
void * |
fxn |
|
) |
| |
Function to plug an interrupt vector.
- Parameters
-
interruptNum | ID of interrupt to plug |
fxn | ISR that services plugged interrupt |
§ HwiP_post()
void HwiP_post |
( |
int |
interruptNum | ) |
|
Function to generate an interrupt.
- Parameters
-
interruptNum | ID of interrupt to generate |
§ HwiP_restore()
void HwiP_restore |
( |
uintptr_t |
key | ) |
|
Function to restore interrupts to exit a critical region.
- Parameters
-
key | return from HwiP_disable |
§ HwiP_setFunc()
Function to overwrite HwiP function and arg.
- Parameters
-
hwiP | handle returned from the HwiP_create or construct call |
fxn | pointer to ISR function |
arg | argument to ISR function |
§ HwiP_setPriority()
void HwiP_setPriority |
( |
int |
interruptNum, |
|
|
uint32_t |
priority |
|
) |
| |
Function to set the priority of a hardware interrupt.
- Parameters
-
interruptNum | id of the interrupt to change |
priority | new priority |
§ HwiP_dispatchInterrupt()
void HwiP_dispatchInterrupt |
( |
int |
interruptNum | ) |
|
Function to call the HW ISR function registered by HwiP_construct.
- Note
- This function may not be available on all implementations
- Parameters
-
interruptNum | Interrupt Vector Id |
§ 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).