From e4d080e63cef6d3c001541a364442cd307743ae4 Mon Sep 17 00:00:00 2001 From: Bruce j Beare Date: Sun, 10 Mar 2019 07:57:38 -0700 Subject: [PATCH] Reset after kill with a button on the KILL_PIN (#13091) --- Marlin/src/Marlin.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 2f022ec15..1d825fe81 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -764,11 +764,34 @@ void minkill() { suicide(); #endif - while (1) { - #if ENABLED(USE_WATCHDOG) - watchdog_reset(); - #endif - } // Wait for reset + #if HAS_KILL + + // Wait for kill to be released + while (!READ(KILL_PIN)) { + #if ENABLED(USE_WATCHDOG) + watchdog_reset(); + #endif + } + + // Wait for kill to be pressed + while (READ(KILL_PIN)) { + #if ENABLED(USE_WATCHDOG) + watchdog_reset(); + #endif + } + + void(*resetFunc)(void) = 0; // Declare resetFunc() at address 0 + resetFunc(); // Jump to address 0 + + #else // !HAS_KILL + + for (;;) { + #if ENABLED(USE_WATCHDOG) + watchdog_reset(); + #endif + } // Wait for reset + + #endif // !HAS_KILL } /**