]> oss.titaniummirror.com Git - rgblamp.git/blobdiff - isr.h
Incorporate new tmr and isr code
[rgblamp.git] / isr.h
diff --git a/isr.h b/isr.h
new file mode 100644 (file)
index 0000000..7b1ede0
--- /dev/null
+++ b/isr.h
@@ -0,0 +1,36 @@
+/*
+ * File:   isr.h
+ *
+ * Interrupt handling routines
+ */
+
+#ifndef _ISR_H
+#define _ISR_H
+
+#include <htc.h>
+
+extern bit isr_gie;
+extern unsigned char isr_di;
+
+/* Nested disable interrupts inline function, for use outside ISR */
+#define ndi() \
+  do { \
+    if (isr_di++ == 0) \
+      isr_gie = GIE; \
+      if (isr_gie) \
+        di(); \
+  } while (0)
+
+/* Nested enable interrupts inline function, for use outside ISR */
+#define nei() \
+  do { \
+    if (--isr_di == 0) \
+      if (isr_gie) { \
+       isr_gie = 0; \
+        ei(); \
+      } \
+  } while (0)
+
+void interrupt isr();
+
+#endif