My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

watchdog.cpp 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "Marlin.h"
  2. #if ENABLED(USE_WATCHDOG)
  3. #include "watchdog.h"
  4. // Initialize watchdog with a 4 sec interrupt time
  5. void watchdog_init() {
  6. #if ENABLED(WATCHDOG_RESET_MANUAL)
  7. // We enable the watchdog timer, but only for the interrupt.
  8. // Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
  9. wdt_reset();
  10. _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
  11. _WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
  12. #else
  13. wdt_enable(WDTO_4S);
  14. #endif
  15. }
  16. //===========================================================================
  17. //=================================== ISR ===================================
  18. //===========================================================================
  19. // Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
  20. #if ENABLED(WATCHDOG_RESET_MANUAL)
  21. ISR(WDT_vect) {
  22. SERIAL_ERROR_START;
  23. SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
  24. kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display
  25. while (1); //wait for user or serial reset
  26. }
  27. #endif //WATCHDOG_RESET_MANUAL
  28. #endif //USE_WATCHDOG