*/
#include <htc.h>
-#include "timer.h"
+#include "tmr.h"
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;
#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;
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 */
SLEEP();
IOCIE = 0;
}
+
+ /* Turn global interrupts back on to activate the ISR. */
+ GIE = 0;
}