CPU Architecture Interrupts API

Module: CPU Architecture API

More…

Types

Name

enum

Arch_Interrupt_Type { ARCH_INTERRUPT_TYPE_IRQ, ARCH_INTERRUPT_TYPE_FIQ}
Interrupt type.

typedef void(*)(void)

Arch_Interrupt_HandlerType
Interrupt handler to invoke on interrupt number specfied by Arch_Interrupt_RegisterHandler.

Functions

Name

void

Arch_Interrupt_Init(void )
Initialize Interrupts.

int32_t

Arch_Interrupt_RegisterHandler(int32_t intrNum, Arch_Interrupt_HandlerType handler)
Register interrupt handler.

int32_t

Arch_Interrupt_UnRegisterHandler(int32_t intrNum)
UnRegister interrupt handler.

int32_t

Arch_Interrupt_Enable(int32_t intrNum)
Enable interrupt.

int32_t

Arch_Interrupt_Disable(int32_t intrNum)
Disable interrupt.

int32_t

Arch_Interrupt_Clear(int32_t intrNum)
Clear interrupt.

int32_t

Arch_Interrupt_SetPriority(int32_t intrNum, uint32_t priority)
Set interrupt priority.

int32_t

Arch_Interrupt_SetTriggerType(int32_t intrNum, bool isEdgeTriggered)
Set interrupt trigger type.

int32_t

Arch_Interrupt_SetType(int32_t intrNum, Arch_Interrupt_Type type)
Set interrupt type.

int32_t

Arch_Interrupt_Trigger(int32_t intrNum)
Trigger interrupt.

int32_t

Arch_Interrupt_SetPriorityMask(uint32_t priority, uint32_t * oldIntrPriorityMask)
Set interrupt priority mask.

int32_t

Arch_Interrupt_RestorePriorityMask(uint32_t oldIntrPriorityMask)
Restore interrupt priority mask.

void

Arch_Interrupt_EnableAll(void )
Enable all interrupts.

uint32_t

Arch_Interrupt_DisableAll(void )
Disable all interrupts.

void

Arch_Interrupt_RestoreAll(uint32_t key)
Restore all interrupts.

uint32_t

Arch_Interrupt_GetIrqNestingCnt(void )
Get IRQ nesting count.

int32_t

Arch_Interrupt_GetActiveIrqNum(void )
Get active IRQ number.

Defines

Name

ARCH_INTERRUPT_ERROR_NONE
No error.

ARCH_INTERRUPT_ERROR_NOT_INIT
Not initalized.

ARCH_INTERRUPT_ERROR_INVALID_INTR_NUM
Invalid interrupt number.

ARCH_INTERRUPT_ERROR_INVALID_PRIORITY
Invalid interrupt priority.

ARCH_INTERRUPT_ERROR_INVALID_HANDLER
Invalid interrupt handler, eg. NULL handler.

ARCH_INTERRUPT_ERROR_UNSUPPORTED_FEATURE
This value is returned when a API is not supported by underlying architecture.

ARCH_INTERRUPT_ERROR_REGISTER_FAILED
Register handler failed, eg. Due to interrupt vectors in FLASH and not relocated to RAM.

ARCH_INTERRUPT_INVALID_INTR_NUM
Invalid Interrupt number.

Detailed Description

CPU architecture specific notes,

C29,

R52,

M33,

  • In Arch_Interrupt_Init

    • 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 priority higher is the actual interrupt priority.

    • Valid priority values are device specific based on number of priority bits implemented. Refer __NVIC_PRIO_BITS in 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>, where

    • negative 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 true for edge-triggered, false for 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:

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.