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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "Marlin.h"
  2. #ifdef USE_WATCHDOG
  3. #include "watchdog.h"
  4. #include "ultralcd.h"
  5. //===========================================================================
  6. //=============================private variables ============================
  7. //===========================================================================
  8. //===========================================================================
  9. //=============================functinos ============================
  10. //===========================================================================
  11. /// intialise watch dog with a 1 sec interrupt time
  12. void watchdog_init()
  13. {
  14. #ifdef RESET_MANUAL
  15. //We enable the watchdog timer, but only for the interrupt.
  16. //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
  17. wdt_reset();
  18. _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
  19. _WD_CONTROL_REG = _BV(WDIE) | WDTO_1S;
  20. #else
  21. wdt_enable(WDTO_1S);
  22. #endif
  23. }
  24. /// reset watchdog. MUST be called every 1s after init or avr will reset.
  25. void watchdog_reset()
  26. {
  27. wdt_reset();
  28. }
  29. //===========================================================================
  30. //=============================ISR ============================
  31. //===========================================================================
  32. //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
  33. #ifdef RESET_MANUAL
  34. ISR(WDT_vect)
  35. {
  36. LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
  37. LCD_STATUS;
  38. SERIAL_ERROR_START;
  39. SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
  40. kill(); //kill blocks
  41. while(1); //wait for user or serial reset
  42. }
  43. #endif//RESET_MANUAL
  44. #endif//USE_WATCHDOG