My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

watchdog.pde 1.9KB

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