aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-12-02 17:15:43 -0500
committerMarti Bolivar <mbolivar@mit.edu>2010-12-02 17:15:43 -0500
commitb34f826ae1470aaa791bd8ed8dd66ccd4d96d82c (patch)
tree95ee476ae62dd4833c9bc1f164938ca546f414b0 /wirish
parent4d424d98b63df873ff373a66aeee27a75ae63f1d (diff)
downloadlibrambutan-b34f826ae1470aaa791bd8ed8dd66ccd4d96d82c.tar.gz
librambutan-b34f826ae1470aaa791bd8ed8dd66ccd4d96d82c.zip
added interrupts()/noInterrupts()
Diffstat (limited to 'wirish')
-rw-r--r--wirish/ext_interrupts.h27
1 files changed, 27 insertions, 0 deletions
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