X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Firq.h;h=0d0d46861646dda34877b8971b16f0fc103b5573;hb=0eeba5822b3ff0e76ae0fd0272536d371d272d7d;hp=290b73d722d920380593d94dd4233da287abe39f;hpb=3e2d80120922e13d77e2497290f96a3f0ed08488;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 290b73d7..0d0d4686 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -60,6 +60,7 @@ #define IRQ_RESTORE(x) FIXME #endif /* OS_EMBEDDED */ + #elif CPU_ARM #ifdef __IAR_SYSTEMS_ICC__ @@ -92,8 +93,6 @@ #define IRQ_ENABLED() \ ((bool)(get_CPSR() & 0xb0)) - #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */ - #else /* !__IAR_SYSTEMS_ICC__ */ #define IRQ_DISABLE \ @@ -166,7 +165,6 @@ #elif CPU_DSP56K - #define BREAKPOINT asm(debug) #define IRQ_DISABLE do { asm(bfset #0x0200,SR); asm(nop); } while (0) #define IRQ_ENABLE do { asm(bfclr #0x0200,SR); asm(nop); } while (0) @@ -232,6 +230,27 @@ #define IRQ_EXIT() /* NOP */ #endif +#ifdef IRQ_RUNNING + /// Ensure callee is running within an interrupt + #define ASSERT_IRQ_CONTEXT() ASSERT(IRQ_RUNNING()) + + /// Ensure callee is not running within an interrupt + #define ASSERT_USER_CONTEXT() ASSERT(!IRQ_RUNNING()) +#else + #define ASSERT_USER_CONTEXT() do {} while(0) + #define ASSERT_IRQ_CONTEXT() do {} while(0) +#endif + +#ifdef IRQ_ENABLED + /// Ensure interrupts are enabled + #define IRQ_ASSERT_ENABLED() ASSERT(IRQ_ENABLED()) + + /// Ensure interrupts are not enabled + #define IRQ_ASSERT_DISABLED() ASSERT(!IRQ_ENABLED()) +#else + #define IRQ_ASSERT_ENABLED() do {} while(0) + #define IRQ_ASSERT_DISABLED() do {} while(0) +#endif /** * Execute \a CODE atomically with respect to interrupts. @@ -246,10 +265,4 @@ IRQ_RESTORE(__flags); \ } while (0) - -#ifndef BREAKPOINT -#define BREAKPOINT /* nop */ -#endif - - #endif /* CPU_IRQ_H */