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.pde 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifdef USE_WATCHDOG
  2. #include "Marlin.h"
  3. #include "watchdog.h"
  4. //===========================================================================
  5. //=============================private variables ============================
  6. //===========================================================================
  7. static volatile uint8_t timeout_seconds=0;
  8. void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
  9. //===========================================================================
  10. //=============================functinos ============================
  11. //===========================================================================
  12. /// intialise watch dog with a 1 sec interrupt time
  13. void wd_init()
  14. {
  15. WDTCSR |= (1<<WDCE )|(1<<WDE ); //allow changes
  16. WDTCSR = (1<<WDCE )|(1<<WDE )|(1<<WDP3 )|(1<<WDP0); // Reset after 8 sec.
  17. // WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP3) | (1<<WDP0);
  18. }
  19. /// reset watchdog. MUST be called every 1s after init or avr will reset.
  20. void wd_reset()
  21. {
  22. wdt_reset();
  23. }
  24. //===========================================================================
  25. //=============================ISR ============================
  26. //===========================================================================
  27. //Watchdog timer interrupt, called if main program blocks >1sec
  28. ISR(WDT_vect)
  29. {
  30. if(timeout_seconds++ >= WATCHDOG_TIMEOUT)
  31. {
  32. #ifdef RESET_MANUAL
  33. LCD_MESSAGEPGM("Please Reset!");
  34. LCD_STATUS;
  35. SERIAL_ERROR_START;
  36. SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
  37. #else
  38. LCD_MESSAGEPGM("Timeout, resetting!");
  39. LCD_STATUS;
  40. #endif
  41. //disable watchdog, it will survife reboot.
  42. WDTCSR |= (1<<WDCE) | (1<<WDE);
  43. WDTCSR = 0;
  44. #ifdef RESET_MANUAL
  45. kill(); //kill blocks
  46. while(1); //wait for user or serial reset
  47. #else
  48. ctrlaltdelete();
  49. #endif
  50. }
  51. }
  52. #endif /* USE_WATCHDOG */