From: R. Steve McKown Date: Thu, 8 Dec 2011 21:50:01 +0000 (-0700) Subject: Uses tmr, runs if already on, stops, will not wake X-Git-Tag: 1.0~36 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=rgblamp.git;a=commitdiff_plain;h=65079ad3f1ecdbcfc6c8d35040a818994f8af94f Uses tmr, runs if already on, stops, will not wake --- diff --git a/adc_random.c b/adc_random.c index d516d7f..e5e7694 100644 --- a/adc_random.c +++ b/adc_random.c @@ -6,7 +6,7 @@ */ #include -#include "timer.h" +#include "tmr.h" unsigned char adc_random() { @@ -28,7 +28,7 @@ unsigned char adc_random() /* Sample the ADC several times, accumulating the LSB of the result */ for (unsigned i = 0; i < 128; i++) { - timer_uwait(10); /* Sampling time */ + tmr_uwait(10); /* Sampling time */ ADGO = 1; /* Start the conversion */ while (ADGO); /* wait for completion */ accumulate += ADRESL; diff --git a/buttons.c b/buttons.c index 8ddd7ee..486fd58 100644 --- a/buttons.c +++ b/buttons.c @@ -7,10 +7,13 @@ #include #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; } diff --git a/tmr_defs.h b/tmr_defs.h index 34ffda5..cc69711 100644 --- a/tmr_defs.h +++ b/tmr_defs.h @@ -14,7 +14,7 @@ * accordingly. */ enum { - TMR_AUTO_ONOFF = 0, + TMR_AUTO_OFFON = 0, TMR_FADE, TMR_DIM, TMR_BTN,