From 76563958fe92175878258f80f1fe43404f1b6e83 Mon Sep 17 00:00:00 2001 From: Jim Paris Date: Tue, 28 Sep 2010 17:32:47 -0400 Subject: [PATCH] Add the disable_int({}) macro This is similar to safe_irq_enable and disable --- lib/include/isr.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/include/isr.h b/lib/include/isr.h index 1647e3b8a..a63215ce8 100644 --- a/lib/include/isr.h +++ b/lib/include/isr.h @@ -130,6 +130,23 @@ enum interrupt_nums { #endif /* REG_NO_COMPAT */ +/* Macro to safely disable all interrupts for a block of code. + Use it like this: + disable_int({ + asdf = 1234; + printf("hi\r\n"); + }); +*/ +#define __int_top() volatile uint32_t saved_intenable +#define __int_disable() saved_intenable = ITC->INTENABLE; ITC->INTENABLE = 0 +#define __int_enable() ITC->INTENABLE = saved_intenable +#define disable_int(x) do { \ + __int_top(); \ + __int_disable(); \ + x; \ + __int_enable(); } while(0) + + extern void tmr0_isr(void) __attribute__((weak)); extern void tmr1_isr(void) __attribute__((weak)); extern void tmr2_isr(void) __attribute__((weak));