30 static const uint32_t reserved_mask[4] = {
38 if (((int32_t)irqn < 0) || ((int32_t)irqn > (int32_t)FMPI2C1_Error_IRQn))
44 uint32_t word = (uint32_t)irqn >> 5U;
46 if ((reserved_mask[word] & (1U << ((uint32_t)irqn & 0x1FU))) != 0U)
61 __asm__
volatile(
"" :::
"memory");
71 __asm__
volatile(
"dsb 0xF\n\tisb 0xF" :::
"memory");
84 return (uint32_t)irqn >> 5U;
94 return 1U << ((uint32_t)irqn & 0x1FU);
185 volatile uint32_t *shpr = &scb->
SHPR1;
192 case MemoryManagement_IRQn:
202 case UsageFault_IRQn:
234 *shpr = (*shpr & ~msk) | ((priority <<
NVIC_PRIO_Pos) << pos);
DriverStatus_e
Outcome of a driver call: a category for control flow, not a diagnosis.
@ DRIVER_STATUS_OK
Succeeded.
@ DRIVER_STATUS_ERR_INVALID_PARAM
A parameter is outside its valid domain.
DRIVER_MUST_CHECK DriverStatus_e nvicDisableIrq(NvicRegisters_t *nvic, IRQn_e irqn)
Disable a device interrupt.
DRIVER_MUST_CHECK DriverStatus_e nvicClearPending(NvicRegisters_t *nvic, IRQn_e irqn)
Clear a device interrupt's pending state (ICPR).
DRIVER_MUST_CHECK DriverStatus_e nvicEnableIrq(NvicRegisters_t *nvic, IRQn_e irqn)
Enable a device interrupt.
static uint32_t nvicIrqBit(IRQn_e irqn)
Bit mask within that word for a validated IRQn.
static uint32_t nvicIrqWord(IRQn_e irqn)
Word index into ISER/ICER/ISPR/ICPR for a validated IRQn.
DRIVER_MUST_CHECK DriverStatus_e nvicGetPriority(const NvicRegisters_t *nvic, IRQn_e irqn, uint32_t *priority)
Read a device interrupt's priority, as nvicSetPriority() takes it.
DRIVER_MUST_CHECK DriverStatus_e nvicSetPending(NvicRegisters_t *nvic, IRQn_e irqn)
Make a device interrupt pending (ISPR).
#define NVIC_PRIORITY_MAX
Lowest-urgency priority value: 15, from NVIC_PRIO_BITS implemented bits.
static void nvicCompilerBarrier(void)
Compiler barrier: stops stores being reordered across the ISER write (as CMSIS __NVIC_EnableIRQ() doe...
static void nvicSyncBarrier(void)
DSB then ISB on the target (a compiler barrier on the host), so a disabled interrupt cannot be taken ...
static DriverStatus_e nvicValidateIrq(IRQn_e irqn)
Accept only a real device interrupt.
DRIVER_MUST_CHECK DriverStatus_e nvicSetPriority(NvicRegisters_t *nvic, IRQn_e irqn, uint32_t priority)
Set a device interrupt's priority.
DRIVER_MUST_CHECK DriverStatus_e nvicSetSystemHandlerPriority(ScbRegisters_t *scb, IRQn_e irqn, uint32_t priority)
Set a configurable system handler's priority (SCB SHPR1-3).
#define NVIC_PRIO_Pos
Shift that moves a 0-15 priority into IP[].
IRQn_e
Interrupt and exception numbers, in RM0390 vector-table order.
#define SCB_SHPR2_PRI_11_Msk
SVCall priority.
#define SCB_SHPR3_PRI_14_Msk
PendSV priority.
#define SCB_SHPR1_PRI_6_Msk
UsageFault priority.
#define SCB_SHPR3_PRI_15_Msk
SysTick priority.
#define SCB_SHPR1_PRI_5_Pos
Bits 15:8.
#define SCB_SHPR3_PRI_15_Pos
Bits 31:24.
#define SCB_SHPR1_PRI_5_Msk
BusFault priority.
#define SCB_SHPR3_PRI_14_Pos
Bits 23:16.
#define SCB_SHPR2_PRI_11_Pos
Bits 31:24.
#define SCB_SHPR1_PRI_4_Msk
MemManage priority.
#define SCB_SHPR1_PRI_4_Pos
Bits 7:0.
#define SCB_SHPR1_PRI_6_Pos
Bits 23:16.
NVIC driver: device interrupt enable, pending and priority, and system-handler priority.
volatile uint8_t IP[240]
0x300: priority, one byte per interrupt
volatile uint32_t ISPR[8]
0x100: set-pending, write 1 to pend
volatile uint32_t ICER[8]
0x080: clear-enable, write 1 to disable
volatile uint32_t ISER[8]
0x000: set-enable, write 1 to enable
volatile uint32_t ICPR[8]
0x180: clear-pending, write 1 to un-pend
volatile uint32_t SHPR1
0x18: priority of MemManage, BusFault, UsageFault
volatile uint32_t SHPR3
0x20: priority of PendSV, SysTick
volatile uint32_t SHPR2
0x1C: priority of SVCall