My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

dac_mcp4728.cpp 4.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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<<WDCE )|(1<<WDE )|(1<<WDP3 )|(1<<WDP0); // Reset after 8 sec.
  18. // WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP3) | (1<<WDP0);
  19. }
  20. /// reset watchdog. MUST be called every 1s after init or avr will reset.
  21. void wd_reset()
  22. {
  23. wdt_reset();
  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. LCD_STATUS;
  36. SERIAL_ERROR_START;
  37. SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
  38. #else
  39. LCD_MESSAGEPGM("Timeout, resetting!");
  40. LCD_STATUS;
  41. #endif
  42. //disable watchdog, it will survife reboot.
  43. WDTCSR |= (1<<WDCE) | (1<<WDE);
  44. WDTCSR = 0;
  45. #ifdef RESET_MANUAL
  46. kill(); //kill blocks
  47. while(1); //wait for user or serial reset
  48. #else
  49. ctrlaltdelete();
  50. #endif
  51. }
  52. }
  53. #endif /* USE_WATCHDOG */