From e8092898b1c4db328a2f5d247fe06603f586f924 Mon Sep 17 00:00:00 2001 From: Bernhard Kubicek Date: Sun, 6 Nov 2011 14:22:15 +0100 Subject: [PATCH] watchdog into dedicated file --- Marlin/Marlin.h | 16 +++++++++++++- Marlin/Marlin.pde | 54 ----------------------------------------------- watchdog.cpp | 48 +++++++++++++++++++++++++++++++++++++++++ watchdog.h | 10 +++++++++ 4 files changed, 73 insertions(+), 55 deletions(-) create mode 100644 watchdog.cpp create mode 100644 watchdog.h diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 15e6570c93..07dd0d8bf1 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -78,5 +78,19 @@ void enquecommand(const char *cmd); extern float homing_feedrate[]; extern bool axis_relative_modes[]; -void wd_reset() ; + +inline void kill() +{ + disable_heater(); + + disable_x(); + disable_y(); + disable_z(); + disable_e(); + + if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT); + Serial.println("!! Printer halted. kill() called !!"); + while(1); // Wait for reset +} + #endif diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 698b137803..6a6fb80f43 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -1263,63 +1263,9 @@ void prepare_arc_move(char isclockwise) { } } -#ifdef USE_WATCHDOG -#include -#include -volatile uint8_t timeout_seconds=0; -void(* ctrlaltdelete) (void) = 0; - -ISR(WDT_vect) { //Watchdog timer interrupt, called if main program blocks >1sec - if(timeout_seconds++ >= WATCHDOG_TIMEOUT) - { - kill(); -#ifdef RESET_MANUAL - LCD_MESSAGE("Please Reset!"); - ECHOLN("echo_: Something is wrong, please turn off the printer."); -#else - LCD_MESSAGE("Timeout, resetting!"); -#endif - //disable watchdog, it will survife reboot. - WDTCSR |= (1< -1) pinMode(PS_ON_PIN,INPUT); - Serial.println("!! Printer halted. kill() called !!"); - while(1); // Wait for reset -} void manage_inactivity(byte debug) { if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(); diff --git a/watchdog.cpp b/watchdog.cpp new file mode 100644 index 0000000000..0adf9cc7d7 --- /dev/null +++ b/watchdog.cpp @@ -0,0 +1,48 @@ +#ifdef USE_WATCHDOG + +#include +#include + +volatile uint8_t timeout_seconds=0; + +void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560 + +//Watchdog timer interrupt, called if main program blocks >1sec +ISR(WDT_vect) +{ + if(timeout_seconds++ >= WATCHDOG_TIMEOUT) + { + + #ifdef RESET_MANUAL + LCD_MESSAGE("Please Reset!"); + ECHOLN("echo_: Something is wrong, please turn off the printer."); + #else + LCD_MESSAGE("Timeout, resetting!"); + #endif + //disable watchdog, it will survife reboot. + WDTCSR |= (1<