My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

watchdog.cpp 1.8KB

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