improve sleep based on lamp switch and add parameterized enableWdt
This commit is contained in:
parent
a01644927d
commit
0ea8e72026
@ -22,18 +22,26 @@ public:
|
|||||||
adc_disable();
|
adc_disable();
|
||||||
|
|
||||||
sleep_enable(); // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
|
sleep_enable(); // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
|
||||||
|
sleep_bod_disable();
|
||||||
sei(); // Enable interrupts
|
sei(); // Enable interrupts
|
||||||
|
|
||||||
sleep_cpu(); // sleep
|
sleep_cpu(); // sleep
|
||||||
|
|
||||||
|
sleep_disable(); // Clear SE bit
|
||||||
cli(); // Disable interrupts
|
cli(); // Disable interrupts
|
||||||
PCMSK &= ~_BV(PCINT0); // Turn off PB0 as interrupt pin
|
PCMSK &= ~_BV(PCINT0); // Turn off PB0 as interrupt pin
|
||||||
sleep_disable(); // Clear SE bit
|
|
||||||
adc_enable();
|
adc_enable();
|
||||||
|
|
||||||
sei(); // Enable interrupts
|
sei(); // Enable interrupts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void enableWdt(byte time)
|
||||||
|
{
|
||||||
|
MCUSR = 0x00;
|
||||||
|
WDTCR |= _BV(WDCE) | _BV(WDE);
|
||||||
|
WDTCR = _BV(WDIE) | time;
|
||||||
|
}
|
||||||
|
|
||||||
//enable the wdt for 8sec interrupt
|
//enable the wdt for 8sec interrupt
|
||||||
static void enableWdt()
|
static void enableWdt()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user