From b34f826ae1470aaa791bd8ed8dd66ccd4d96d82c Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 2 Dec 2010 17:15:43 -0500 Subject: added interrupts()/noInterrupts() --- wirish/ext_interrupts.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'wirish') diff --git a/wirish/ext_interrupts.h b/wirish/ext_interrupts.h index 80e2e9e..e68d973 100644 --- a/wirish/ext_interrupts.h +++ b/wirish/ext_interrupts.h @@ -23,6 +23,7 @@ *****************************************************************************/ #include "libmaple_types.h" +#include "nvic.h" /** * @file ext_interrupts.h @@ -73,6 +74,32 @@ void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode); */ void detachInterrupt(uint8 pin); +/** + * Re-enable interrupts. + * + * Call this after noInterrupts() to re-enable interrupt handling, + * after you have finished with a timing-critical section of code. + * + * @see noInterrupts() + */ +static inline __attribute__((always_inline)) void interrupts() { + nvic_globalirq_enable(); +} + +/** + * Disable interrupts. + * + * After calling this function, all user-programmable interrupts will + * be disabled. You can call this function before a timing-critical + * section of code, then call interrupts() to re-enable interrupt + * handling. + * + * @see interrupts() + */ +static inline __attribute__((always_inline)) void noInterrupts() { + nvic_globalirq_disable(); +} + #ifdef __cplusplus } #endif -- cgit v1.2.3