intermediate 20151208fix
This commit is contained in:
@@ -37,13 +37,15 @@ void wakeUp2() //place to send the second interrupts
|
|||||||
ISR (WDT_vect)
|
ISR (WDT_vect)
|
||||||
{
|
{
|
||||||
// WDIE & WDIF is cleared in hardware upon entering this ISR
|
// WDIE & WDIF is cleared in hardware upon entering this ISR
|
||||||
wdt_disable();
|
//wdt_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hwPowerDown(period_t period) {
|
void hwPowerDown(period_t period) {
|
||||||
|
|
||||||
// disable ADC for power saving
|
// disable ADC for power saving
|
||||||
ADCSRA &= ~(1 << ADEN);
|
ADCSRA &= ~(1 << ADEN);
|
||||||
|
// save WDT settings
|
||||||
|
uint8_t WDTsave = WDTCSR;
|
||||||
|
|
||||||
if (period != SLEEP_FOREVER)
|
if (period != SLEEP_FOREVER)
|
||||||
{
|
{
|
||||||
@@ -51,6 +53,9 @@ void hwPowerDown(period_t period) {
|
|||||||
wdt_enable(period);
|
wdt_enable(period);
|
||||||
// enable WDT interrupt before system reset
|
// enable WDT interrupt before system reset
|
||||||
WDTCSR |= (1 << WDIE) ;
|
WDTCSR |= (1 << WDIE) ;
|
||||||
|
} else {
|
||||||
|
// if sleeping forever, wdt should be disabled
|
||||||
|
wdt_disable();
|
||||||
}
|
}
|
||||||
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
|
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
|
||||||
cli();
|
cli();
|
||||||
@@ -62,6 +67,9 @@ void hwPowerDown(period_t period) {
|
|||||||
// sleep until WDT or ext. interrupt
|
// sleep until WDT or ext. interrupt
|
||||||
sleep_cpu();
|
sleep_cpu();
|
||||||
sleep_disable();
|
sleep_disable();
|
||||||
|
// restore previous WDT settings
|
||||||
|
WDTCSR = (1 << WDCE) | (1 << WDE);
|
||||||
|
WDTCSR = WDTsave;
|
||||||
// enable ADC
|
// enable ADC
|
||||||
ADCSRA |= (1 << ADEN);
|
ADCSRA |= (1 << ADEN);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user