|
STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
|
Interrupt enable, pending and priority control. More...
Macros | |
| #define | NVIC_PRIORITY_MAX ((1U << NVIC_PRIO_BITS) - 1U) |
| Lowest-urgency priority value: 15, from NVIC_PRIO_BITS implemented bits. | |
Functions | |
| DRIVER_MUST_CHECK DriverStatus_e | nvicEnableIrq (NvicRegisters_t *nvic, IRQn_e irqn) |
| Enable a device interrupt. | |
| DRIVER_MUST_CHECK DriverStatus_e | nvicDisableIrq (NvicRegisters_t *nvic, IRQn_e irqn) |
| Disable a device interrupt. | |
| DRIVER_MUST_CHECK DriverStatus_e | nvicSetPending (NvicRegisters_t *nvic, IRQn_e irqn) |
| Make a device interrupt pending (ISPR). | |
| 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 | nvicSetPriority (NvicRegisters_t *nvic, IRQn_e irqn, uint32_t priority) |
| Set a device interrupt's priority. | |
| 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 | nvicSetSystemHandlerPriority (ScbRegisters_t *scb, IRQn_e irqn, uint32_t priority) |
| Set a configurable system handler's priority (SCB SHPR1-3). | |
| static DriverStatus_e | nvicValidateIrq (IRQn_e irqn) |
| Accept only a real device interrupt. | |
| static void | nvicCompilerBarrier (void) |
| Compiler barrier: stops stores being reordered across the ISER write (as CMSIS __NVIC_EnableIRQ() does). | |
| static void | nvicSyncBarrier (void) |
| DSB then ISB on the target (a compiler barrier on the host), so a disabled interrupt cannot be taken after nvicDisableIrq() returns. | |
| static uint32_t | nvicIrqWord (IRQn_e irqn) |
| Word index into ISER/ICER/ISPR/ICPR for a validated IRQn. | |
| static uint32_t | nvicIrqBit (IRQn_e irqn) |
| Bit mask within that word for a validated IRQn. | |
Interrupt enable, pending and priority control.
| #define NVIC_PRIORITY_MAX ((1U << NVIC_PRIO_BITS) - 1U) |
Lowest-urgency priority value: 15, from NVIC_PRIO_BITS implemented bits.
Definition at line 36 of file nvic.h.
Referenced by nvicSetPriority(), and nvicSetSystemHandlerPriority().
| DriverStatus_e nvicEnableIrq | ( | NvicRegisters_t * | nvic, |
| IRQn_e | irqn ) |
Enable a device interrupt.
Writes only its ISER bit, between compiler barriers, so state set up before the call is not reordered after the enable.
| nvic | NVIC block (e.g. NVIC). |
| irqn | Device interrupt. |
| DRIVER_STATUS_OK | Enabled. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is negative, above ::FMPI2C1_Error_IRQn or reserved. |
Definition at line 97 of file nvic.c.
References DRIVER_STATUS_OK, NvicRegisters_t::ISER, nvicCompilerBarrier(), nvicEnableIrq(), nvicIrqBit(), nvicIrqWord(), and nvicValidateIrq().
Referenced by nvicEnableIrq().
| DriverStatus_e nvicDisableIrq | ( | NvicRegisters_t * | nvic, |
| IRQn_e | irqn ) |
Disable a device interrupt.
Writes its ICER bit, then DSB and ISB. Once this returns the interrupt is not taken, even if it was already pending.
| nvic | NVIC block (e.g. NVIC). |
| irqn | Device interrupt. |
| DRIVER_STATUS_OK | Disabled. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is not a valid device interrupt. |
Definition at line 111 of file nvic.c.
References DRIVER_STATUS_OK, NvicRegisters_t::ICER, nvicDisableIrq(), nvicIrqBit(), nvicIrqWord(), nvicSyncBarrier(), and nvicValidateIrq().
Referenced by nvicDisableIrq().
| DriverStatus_e nvicSetPending | ( | NvicRegisters_t * | nvic, |
| IRQn_e | irqn ) |
Make a device interrupt pending (ISPR).
| nvic | NVIC block (e.g. NVIC). |
| irqn | Device interrupt. |
| DRIVER_STATUS_OK | Pending. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is not a valid device interrupt. |
Definition at line 124 of file nvic.c.
References DRIVER_STATUS_OK, NvicRegisters_t::ISPR, nvicIrqBit(), nvicIrqWord(), nvicSetPending(), and nvicValidateIrq().
Referenced by nvicSetPending().
| DriverStatus_e nvicClearPending | ( | NvicRegisters_t * | nvic, |
| IRQn_e | irqn ) |
Clear a device interrupt's pending state (ICPR).
| nvic | NVIC block (e.g. NVIC). |
| irqn | Device interrupt. |
| DRIVER_STATUS_OK | Cleared. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is not a valid device interrupt. |
Definition at line 136 of file nvic.c.
References DRIVER_STATUS_OK, NvicRegisters_t::ICPR, nvicClearPending(), nvicIrqBit(), nvicIrqWord(), and nvicValidateIrq().
Referenced by nvicClearPending().
| DriverStatus_e nvicSetPriority | ( | NvicRegisters_t * | nvic, |
| IRQn_e | irqn, | ||
| uint32_t | priority ) |
Set a device interrupt's priority.
| nvic | NVIC block (e.g. NVIC). |
| irqn | Device interrupt. |
| priority | 0 (most urgent) to NVIC_PRIORITY_MAX. |
| DRIVER_STATUS_OK | Set. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is not valid, or priority is too large. |
Definition at line 148 of file nvic.c.
References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, NvicRegisters_t::IP, NVIC_PRIO_Pos, NVIC_PRIORITY_MAX, nvicSetPriority(), and nvicValidateIrq().
Referenced by nvicSetPriority().
| DriverStatus_e nvicGetPriority | ( | const NvicRegisters_t * | nvic, |
| IRQn_e | irqn, | ||
| uint32_t * | priority ) |
Read a device interrupt's priority, as nvicSetPriority() takes it.
| nvic | NVIC block (e.g. NVIC). |
| irqn | Device interrupt. |
| priority | Receives 0 to NVIC_PRIORITY_MAX; written only on success. |
| DRIVER_STATUS_OK | Read. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is not valid, or priority is NULL. |
Definition at line 165 of file nvic.c.
References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, NvicRegisters_t::IP, NVIC_PRIO_Pos, nvicGetPriority(), and nvicValidateIrq().
Referenced by nvicGetPriority().
| DriverStatus_e nvicSetSystemHandlerPriority | ( | ScbRegisters_t * | scb, |
| IRQn_e | irqn, | ||
| uint32_t | priority ) |
Set a configurable system handler's priority (SCB SHPR1-3).
Changes only that handler's byte; SHPR3 is shared by PendSV and SysTick.
| scb | SCB block (e.g. SCB). |
| irqn | ::MemoryManagement_IRQn, ::BusFault_IRQn, ::UsageFault_IRQn, ::SVCall_IRQn, ::PendSV_IRQn or ::SysTick_IRQn. |
| priority | 0 (most urgent) to NVIC_PRIORITY_MAX. |
| DRIVER_STATUS_OK | Set. |
| DRIVER_STATUS_ERR_INVALID_PARAM | irqn is not one of the six handlers, or priority is too large. |
Definition at line 182 of file nvic.c.
References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, NVIC_PRIO_Pos, NVIC_PRIORITY_MAX, nvicSetSystemHandlerPriority(), SCB_SHPR1_PRI_4_Msk, SCB_SHPR1_PRI_4_Pos, SCB_SHPR1_PRI_5_Msk, SCB_SHPR1_PRI_5_Pos, SCB_SHPR1_PRI_6_Msk, SCB_SHPR1_PRI_6_Pos, SCB_SHPR2_PRI_11_Msk, SCB_SHPR2_PRI_11_Pos, SCB_SHPR3_PRI_14_Msk, SCB_SHPR3_PRI_14_Pos, SCB_SHPR3_PRI_15_Msk, SCB_SHPR3_PRI_15_Pos, ScbRegisters_t::SHPR1, ScbRegisters_t::SHPR2, and ScbRegisters_t::SHPR3.
Referenced by nvicSetSystemHandlerPriority().
|
static |
Accept only a real device interrupt.
Negative values (system exceptions) and values past ::FMPI2C1_Error_IRQn would index outside the implemented banks. Reserved positions have no vector, so pending one would jump through address 0.
| irqn | Candidate interrupt. |
| DRIVER_STATUS_OK | 0 to ::FMPI2C1_Error_IRQn and not reserved. |
| DRIVER_STATUS_ERR_INVALID_PARAM | Otherwise. |
Definition at line 25 of file nvic.c.
References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, and nvicValidateIrq().
Referenced by nvicClearPending(), nvicDisableIrq(), nvicEnableIrq(), nvicGetPriority(), nvicSetPending(), nvicSetPriority(), and nvicValidateIrq().
|
inlinestatic |
Compiler barrier: stops stores being reordered across the ISER write (as CMSIS __NVIC_EnableIRQ() does).
Emits no instruction.
Definition at line 59 of file nvic.c.
References nvicCompilerBarrier().
Referenced by nvicCompilerBarrier(), nvicEnableIrq(), and nvicSyncBarrier().
|
inlinestatic |
DSB then ISB on the target (a compiler barrier on the host), so a disabled interrupt cannot be taken after nvicDisableIrq() returns.
Definition at line 68 of file nvic.c.
References nvicCompilerBarrier(), and nvicSyncBarrier().
Referenced by nvicDisableIrq(), and nvicSyncBarrier().
|
static |
Word index into ISER/ICER/ISPR/ICPR for a validated IRQn.
| irqn | Device interrupt number, already validated. |
Definition at line 82 of file nvic.c.
References nvicIrqWord().
Referenced by nvicClearPending(), nvicDisableIrq(), nvicEnableIrq(), nvicIrqWord(), and nvicSetPending().
|
static |
Bit mask within that word for a validated IRQn.
| irqn | Device interrupt number, already validated. |
Definition at line 92 of file nvic.c.
References nvicIrqBit().
Referenced by nvicClearPending(), nvicDisableIrq(), nvicEnableIrq(), nvicIrqBit(), and nvicSetPending().