]> oss.titaniummirror.com Git - rgblamp.git/blobdiff - buttons.c
Uses tmr, runs if already on, stops, will not wake
[rgblamp.git] / buttons.c
index 8ddd7ee2c94ff06fe10bc8e0bb51cc9ca51bee84..486fd5884a3d4f881e5b29e5d03fd5924081f99b 100644 (file)
--- a/buttons.c
+++ b/buttons.c
@@ -7,10 +7,13 @@
 
 #include <htc.h>
 #include "buttons.h"
-#include "timer.h"
+#include "tmr.h"
 
 void buttons_sleep()
 {
+    /* Turn off global interrupts.  Don't need to call the ISR */
+    GIE = 0;
+
     /* If the rocker is on, sleep until it is placed in the off position */
     IOCBN4 = 0; IOCBP4 = 1;
     IOCBN5 = 0; IOCBP5 = 1;
@@ -18,7 +21,7 @@ void buttons_sleep()
         IOCIE = 1;
         SLEEP();
         IOCIE = 0;
-        timer_mwait(50); /* debounce */
+        tmr_mwait(50); /* debounce */
     }
 
     /* Now that the rocker is off, sleep until it is turned on */
@@ -29,4 +32,7 @@ void buttons_sleep()
         SLEEP();
         IOCIE = 0;
     }
+
+    /* Turn global interrupts back on to activate the ISR. */
+    GIE = 0;
 }