I am using CMSIS API in my C program for ARM Cortex-M CPU.
CMSIS defines NVIC_DisableIRQ
function as
__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn);
IRQn_Type is a typedef enum
, like
typedef enum IRQn
{
NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */
HardFault_IRQn = -13, /* 3 HardFault Interrupt */
.....
Interrupt0_IRQn = 0,
Interrupt1_IRQn = 1,
Interrupt2_IRQn = 2,
} IRQn_Type;
So, given that I would like to call NVIC_DisableIRQ
, as
NVIC_DisableIRQ( (IRQn_Type )(SCB->ICSR -16);
and this fails MISRA check
note 9034: cannot assign 'unsigned32' to different essential type 'enum (IRQn)' [MISRA 2012 Rule 10.3, required]
I understand why MISRA complains, but that is a practical solution for this? That I found is to create huge switch/case , are any other solutions/hacks available ?