AVR: Hidden option to use 8s watchdog

This commit is contained in:
Scott Lahteine 2017-10-29 18:30:03 -05:00
parent 9d4cfd2013
commit b232f39341

View file

@ -30,16 +30,22 @@
#include "../../Marlin.h" #include "../../Marlin.h"
// Initialize watchdog with a 4 sec interrupt time // Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s.
void watchdog_init() { void watchdog_init() {
#if ENABLED(WATCHDOG_DURATION_8S) && defined(WDTO_8S)
#define WDTO_NS WDTO_8S
#else
#define WDTO_NS WDTO_4S
#endif
#if ENABLED(WATCHDOG_RESET_MANUAL) #if ENABLED(WATCHDOG_RESET_MANUAL)
// We enable the watchdog timer, but only for the interrupt. // We enable the watchdog timer, but only for the interrupt.
// Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details. // Take care, as this requires the correct order of operation, with interrupts disabled.
// See the datasheet of any AVR chip for details.
wdt_reset(); wdt_reset();
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE); _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
_WD_CONTROL_REG = _BV(WDIE) | WDTO_4S; _WD_CONTROL_REG = _BV(WDIE) | WDTO_NS;
#else #else
wdt_enable(WDTO_4S); wdt_enable(WDTO_NS);
#endif #endif
} }