My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

watchdog.pde 1.1KB

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