1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "Marlin.h"
- #if ENABLED(USE_WATCHDOG)
- #include "watchdog.h"
- 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)
-
-
-
- wdt_reset();
- cli();
- _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
- _WD_CONTROL_REG = _BV(WDIE) | (WDTO_NS & 0x07) | ((WDTO_NS & 0x08) << 2);
-
- sei();
- wdt_reset();
- #else
- wdt_enable(WDTO_NS);
- #endif
-
- }
- #if ENABLED(WATCHDOG_RESET_MANUAL)
- ISR(WDT_vect) {
- sei();
- SERIAL_ERROR_START();
- SERIAL_ERRORLNPGM("Watchdog barked, please turn off the printer.");
- kill(PSTR("ERR:Watchdog"));
- while (1);
- }
- #endif
- #endif
|