X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Firq.h;h=3a84dcb33b225c8ea5fc80d3b417d446647bbebb;hb=274910d36c7db1d556864384534f43c69d1bae19;hp=290b73d722d920380593d94dd4233da287abe39f;hpb=3e2d80120922e13d77e2497290f96a3f0ed08488;p=bertos.git diff --git a/bertos/cpu/irq.h b/bertos/cpu/irq.h index 290b73d7..3a84dcb3 100644 --- a/bertos/cpu/irq.h +++ b/bertos/cpu/irq.h @@ -232,6 +232,31 @@ #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 + +// OBSOLETE names +#define ASSERT_IRQ_ENABLED() IRQ_ASSERT_ENABLED() +#define ASSERT_IRQ_DISABLED() IRQ_ASSERT_DISABLED() /** * Execute \a CODE atomically with respect to interrupts.