CPU Architecture Interrupts API
Module: CPU Architecture API
Types
Name |
|
|---|---|
enum |
Arch_Interrupt_Type { ARCH_INTERRUPT_TYPE_IRQ, ARCH_INTERRUPT_TYPE_FIQ} |
typedef void(*)(void) |
Arch_Interrupt_HandlerType |
Functions
Name |
|
|---|---|
void |
Arch_Interrupt_Init(void ) |
int32_t |
Arch_Interrupt_RegisterHandler(int32_t intrNum, Arch_Interrupt_HandlerType handler) |
int32_t |
Arch_Interrupt_UnRegisterHandler(int32_t intrNum) |
int32_t |
Arch_Interrupt_Enable(int32_t intrNum) |
int32_t |
Arch_Interrupt_Disable(int32_t intrNum) |
int32_t |
Arch_Interrupt_Clear(int32_t intrNum) |
int32_t |
Arch_Interrupt_SetPriority(int32_t intrNum, uint32_t priority) |
int32_t |
Arch_Interrupt_SetTriggerType(int32_t intrNum, bool isEdgeTriggered) |
int32_t |
Arch_Interrupt_SetType(int32_t intrNum, Arch_Interrupt_Type type) |
int32_t |
Arch_Interrupt_Trigger(int32_t intrNum) |
int32_t |
Arch_Interrupt_SetPriorityMask(uint32_t priority, uint32_t * oldIntrPriorityMask) |
int32_t |
Arch_Interrupt_RestorePriorityMask(uint32_t oldIntrPriorityMask) |
void |
Arch_Interrupt_EnableAll(void ) |
uint32_t |
Arch_Interrupt_DisableAll(void ) |
void |
Arch_Interrupt_RestoreAll(uint32_t key) |
uint32_t |
Arch_Interrupt_GetIrqNestingCnt(void ) |
int32_t |
Arch_Interrupt_GetActiveIrqNum(void ) |
Defines
Name |
|
|---|---|
ARCH_INTERRUPT_ERROR_NONE |
|
ARCH_INTERRUPT_ERROR_NOT_INIT |
|
ARCH_INTERRUPT_ERROR_INVALID_INTR_NUM |
|
ARCH_INTERRUPT_ERROR_INVALID_PRIORITY |
|
ARCH_INTERRUPT_ERROR_INVALID_HANDLER |
|
ARCH_INTERRUPT_ERROR_UNSUPPORTED_FEATURE |
|
ARCH_INTERRUPT_ERROR_REGISTER_FAILED |
|
ARCH_INTERRUPT_INVALID_INTR_NUM |
Detailed Description
CPU architecture specific notes,
C29,
-
All individual PIPE interrupts are disabled and cleared
A default handler is setup for each PIPE interrupt
RTINT threshold is set to value defined in
source/device/{device}/{config}/Arch_Cfg/Arch_Interrupt_C29_Cfg.hGlobal interrupts, i.e RTINTs as well as INTs are enabled
Priority mask is set to max value to allow all interrupts
Use Arch_Interrupt_SetPriorityMask to set the appropriate priority mask value
Interrupts use LINK2 by default, use Arch_Pipe_SetLinkOwner() to change link ownership.
In Arch_Interrupt_DisableAll, Arch_Interrupt_EnableAll all INTs are disabled or enabled.
Note: RTINTs status remains unchanged. To enable or disable RTINTs use Arch_Pipe_EnableGlobal() and Arch_Pipe_DisableGlobal() respectively.
In Arch_Interrupt_SetPriority, lower the value of
priorityhigher is the actual interrupt priority.Valid priority values are from ARCH_PIPE_HIGHEST_PRIORITY (0) to ARCH_PIPE_LOWEST_PRIORITY (255)
All interrupts are always edge triggered and Arch_Interrupt_SetTriggerType is not supported to change this.
Arch_Interrupt_SetType is not supported.
Arch_Interrupt_GetIrqNestingCnt is not supported.
The following APIs should be used only from LINK2 (SROOT_LINK) due to PIPE register access privileges:
The following APIs should be used only from LINK2 or the configured owner link of the interrupt line:
R52,
-
All individual interrupts are disabled and cleared
All individual interrupts are set as IRQ type
All SPIs are set as rising edge-triggered and routed to core 0
All PPIs are set as active-LOW level-sensitive
Priority mask is set to max value to allow all interrupts
IRQs and FIQs are enabled in the CPU Current Program Status Register (CPSR)
Use Arch_Interrupt_SetPriorityMask to set the appropriate priority mask value
In Arch_Interrupt_DisableAll, Arch_Interrupt_EnableAll all IRQs are disabled or enabled.
Note, FIQs status remains unchanged. To enable or disable FIQs use CPU specific API.
In Arch_Interrupt_SetPriority, lower the value of
priorityhigher is the actual interrupt priority.Valid priority values are from 0 to 31
For Arch_Interrupt_SetTriggerType
All SPIs support both rising edge-triggered and level-sensitive(active-HIGH) types
All PPIs except PPIs 6-11 (Interrupt Number 22-27) and 14 (Interrupt Number 30) support both rising edge-triggered and level-sensitive(active-LOW) types
PPIs 6-11 and 14 are assigned to core peripherals that have a fixed level-sensitive configuration
SGIs are always edge-triggered
In Arch_Interrupt_RegisterHandler, this also routes the SPI to the current core.
Following APIs should be used only from a privileged mode. This is due to access restrictions in User mode to read/modify various system registers.
M33,
-
All external interrupts are disabled and cleared
Base priority mask is set to 0 to disable masking and allow all interrupts
Interrupts are enabled
Use Arch_Interrupt_SetPriorityMask to set the appropriate priority mask value
In Arch_Interrupt_DisableAll, Arch_Interrupt_EnableAll all interrupts are disabled or enabled.
In Arch_Interrupt_SetPriority, lower the value of
priorityhigher is the actual interrupt priority.Valid priority values are device specific based on number of priority bits implemented. Refer
__NVIC_PRIO_BITSin device specific header file.
Arch_Interrupt_SetTriggerType is not supported.
Arch_Interrupt_SetType is not supported.
Arch_Interrupt_GetIrqNestingCnt is not supported.
All APIs should be used only from privileged mode.
This is due to NVIC and other system registers usage constraints - Privileged access only.
The interrupt number parameter of APIs is compliant to CMSIS NVIC APIs
<IRQn_Type>, wherenegative numbers are the exceptions and system handlers
non-negative numbers are the external device peripheral interrupts
Arch_Interrupt_GetActiveIrqNum returns active IRQ number:
= 0 for external device peripheral interrupts
< 0 for exceptions and system handlers using CMSIS IRQn_Type convention
ARCH_INTERRUPT_INVALID_INTR_NUM if called from thread mode (no active exception)
Types Documentation
enum Arch_Interrupt_Type
Enumerator |
Value |
Description |
|---|---|---|
ARCH_INTERRUPT_TYPE_IRQ |
IRQ type - Standard interrupts |
|
ARCH_INTERRUPT_TYPE_FIQ |
FIQ type - Fast interrupts |
Interrupt type.
typedef Arch_Interrupt_HandlerType
typedef void(* Arch_Interrupt_HandlerType) (void);
Interrupt handler to invoke on interrupt number specfied by Arch_Interrupt_RegisterHandler.
Functions Documentation
function Arch_Interrupt_Init
void Arch_Interrupt_Init(
void
)
Initialize Interrupts.
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_RegisterHandler
int32_t Arch_Interrupt_RegisterHandler(
int32_t intrNum,
Arch_Interrupt_HandlerType handler
)
Register interrupt handler.
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_UnRegisterHandler
int32_t Arch_Interrupt_UnRegisterHandler(
int32_t intrNum
)
UnRegister interrupt handler.
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_Enable
int32_t Arch_Interrupt_Enable(
int32_t intrNum
)
Enable interrupt.
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_Disable
int32_t Arch_Interrupt_Disable(
int32_t intrNum
)
Disable interrupt.
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_Clear
int32_t Arch_Interrupt_Clear(
int32_t intrNum
)
Clear interrupt.
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_SetPriority
int32_t Arch_Interrupt_SetPriority(
int32_t intrNum,
uint32_t priority
)
Set interrupt priority.
Return: see [Arch_Interrupt_ErrorType]
function Arch_Interrupt_SetTriggerType
int32_t Arch_Interrupt_SetTriggerType(
int32_t intrNum,
bool isEdgeTriggered
)
Set interrupt trigger type.
Parameters:
intrNum Interrupt Number
isEdgeTriggered
truefor edge-triggered,falsefor level-sensitive
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs and some specific interrupts may not support this. Refer CPU specific notes for details.
function Arch_Interrupt_SetType
int32_t Arch_Interrupt_SetType(
int32_t intrNum,
Arch_Interrupt_Type type
)
Set interrupt type.
Parameters:
intrNum Interrupt Number
type Arch_Interrupt_Type
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs may not support this. Refer CPU specific notes for details.
function Arch_Interrupt_Trigger
int32_t Arch_Interrupt_Trigger(
int32_t intrNum
)
Trigger interrupt.
Return: see [Arch_Interrupt_ErrorType]
function Arch_Interrupt_SetPriorityMask
int32_t Arch_Interrupt_SetPriorityMask(
uint32_t priority,
uint32_t * oldIntrPriorityMask
)
Set interrupt priority mask.
Parameters:
priority Only interrupts with higher priority will be signaled. Interrupts with priority less than or equal to this value will be masked.
oldIntrPriorityMask Old interrupt priority mask value, can be NULL if not needed. This value MUST be passed to Arch_Interrupt_RestorePriorityMask
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs may not support this / will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_RestorePriorityMask
int32_t Arch_Interrupt_RestorePriorityMask(
uint32_t oldIntrPriorityMask
)
Restore interrupt priority mask.
Return: see [Arch_Interrupt_ErrorType]
Note: Some CPUs may not support this / will have access restrictions with the execution mode. Refer CPU specific notes for details.
Restore the interrupt priority mask to oldIntrPriorityMask value returned by Arch_Interrupt_SetPriorityMask
function Arch_Interrupt_EnableAll
void Arch_Interrupt_EnableAll(
void
)
Enable all interrupts.
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_DisableAll
uint32_t Arch_Interrupt_DisableAll(
void
)
Disable all interrupts.
Return: Old interrupt state, this value MUST be passed to Arch_Interrupt_RestoreAll
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
function Arch_Interrupt_RestoreAll
void Arch_Interrupt_RestoreAll(
uint32_t key
)
Restore all interrupts.
Note: Some CPUs will have access restrictions with the execution mode. Refer CPU specific notes for details.
Restore interrupts to state that is returned via Arch_Interrupt_DisableAll
function Arch_Interrupt_GetIrqNestingCnt
uint32_t Arch_Interrupt_GetIrqNestingCnt(
void
)
Get IRQ nesting count.
Return: IRQ nesting count
Note: Some CPUs may not support this. Refer CPU specific notes for details.
function Arch_Interrupt_GetActiveIrqNum
int32_t Arch_Interrupt_GetActiveIrqNum(
void
)
Get active IRQ number.
Return: Active IRQ number or ARCH_INTERRUPT_INVALID_INTR_NUM if no IRQ is active
Note:
Some CPUs may not support this / will have access restrictions with the execution mode. Refer CPU specific notes for details.
Some CPUs return negative number for CPU exceptions, while non-negative numbers are for peripheral interrupts. Refer CPU specific notes for details.
Macros Documentation
define ARCH_INTERRUPT_ERROR_NONE
#define ARCH_INTERRUPT_ERROR_NONE (0)
No error.
define ARCH_INTERRUPT_ERROR_NOT_INIT
#define ARCH_INTERRUPT_ERROR_NOT_INIT (1)
Not initalized.
define ARCH_INTERRUPT_ERROR_INVALID_INTR_NUM
#define ARCH_INTERRUPT_ERROR_INVALID_INTR_NUM (2)
Invalid interrupt number.
define ARCH_INTERRUPT_ERROR_INVALID_PRIORITY
#define ARCH_INTERRUPT_ERROR_INVALID_PRIORITY (3)
Invalid interrupt priority.
define ARCH_INTERRUPT_ERROR_INVALID_HANDLER
#define ARCH_INTERRUPT_ERROR_INVALID_HANDLER (4)
Invalid interrupt handler, eg. NULL handler.
define ARCH_INTERRUPT_ERROR_UNSUPPORTED_FEATURE
#define ARCH_INTERRUPT_ERROR_UNSUPPORTED_FEATURE (5)
This value is returned when a API is not supported by underlying architecture.
define ARCH_INTERRUPT_ERROR_REGISTER_FAILED
#define ARCH_INTERRUPT_ERROR_REGISTER_FAILED (6)
Register handler failed, eg. Due to interrupt vectors in FLASH and not relocated to RAM.
define ARCH_INTERRUPT_INVALID_INTR_NUM
#define ARCH_INTERRUPT_INVALID_INTR_NUM (0x5A5A5A5A)
Invalid Interrupt number.