方法一: 通过IPSR寄存器 代码参考: __STATIC_INLINE uint32_t __get_IPSR(void)
{
register uint32_t __regIPSR __ASM("ipsr");
return(__regIPSR);
} #define IS_IRQ_MODE() (__get_IPSR_s() != 0U)
方法二:通过ACTIVE寄存器族 0xE000_E300_0xE000_E31C 参考代码: #define INTERRUPT_ACTIVE_BIT_REGISTER1_MASK 0xBFFFFFFFU (根据芯片芯片中断实际情况设置)
#define INTERRUPT_ACTIVE_BIT_REGISTER2_MASK 0x0000011FU
#define INTERRUPT_ACTIVE_BIT_REGISTER1_ADDR ((volatile uint32_t *)0xE000E300U)
#define INTERRUPT_ACTIVE_BIT_REGISTER2_ADDR ((volatile uint32_t *)0xE000E304U) #define phPlatform_Is_Irq_Context() ((*(INTERRUPT_ACTIVE_BIT_REGISTER1_ADDR) & INTERRUPT_ACTIVE_BIT_REGISTER1_MASK) || \
(*(INTERRUPT_ACTIVE_BIT_REGISTER2_ADDR) & INTERRUPT_ACTIVE_BIT_REGISTER2_MASK))
|