diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-12-14 15:41:17 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-12-14 15:41:17 -0500 |
commit | 74c8937446e1be4e0d21f69a8c098e2caf7814d5 (patch) | |
tree | 1c7b8e4d93a9512ee54cdd6c5bb7ede064f96b3e /wirish/ext_interrupts.h | |
parent | 5ceac644e90c929e77f05d357d1d35d45e673fac (diff) | |
parent | b67d281d85bd59a9738a9a43c4db1027f81d9208 (diff) | |
download | librambutan-74c8937446e1be4e0d21f69a8c098e2caf7814d5.tar.gz librambutan-74c8937446e1be4e0d21f69a8c098e2caf7814d5.zip |
Merge branch 'master' into newdoc
Diffstat (limited to 'wirish/ext_interrupts.h')
-rw-r--r-- | wirish/ext_interrupts.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/wirish/ext_interrupts.h b/wirish/ext_interrupts.h index d44978a..057c0d3 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 @@ -77,6 +78,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 |