diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 15e6570c9..07dd0d8bf 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 698b13780..6a6fb80f4 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 000000000..0adf9cc7d --- /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<