From fd7fd55662f380c9015789e4af939d4a23894553 Mon Sep 17 00:00:00 2001
From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com>
Date: Fri, 9 Nov 2018 21:58:04 +0100
Subject: [PATCH] Solve endstops issues (#12382)

- Partially reverts #11900 and tries to solve #12336
---
 Marlin/src/module/endstops.cpp | 22 +++-------------------
 Marlin/src/module/motion.cpp   | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp
index e3324d0c19b..28e0d92f69f 100644
--- a/Marlin/src/module/endstops.cpp
+++ b/Marlin/src/module/endstops.cpp
@@ -260,33 +260,19 @@ void Endstops::poll() {
 void Endstops::enable_globally(const bool onoff) {
   enabled_globally = enabled = onoff;
 
-  #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
-    update();
-  #endif
+  update();
 }
 
 // Enable / disable endstop checking
 void Endstops::enable(const bool onoff) {
   enabled = onoff;
 
-  #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
-    update();
-  #endif
+  update();
 }
 
 // Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
 void Endstops::not_homing() {
   enabled = enabled_globally;
-
-  // Still 'enabled'? Then endstops are always on and kept in sync.
-  // Otherwise reset 'live's variables to let axes move in both directions.
-  if (!enabled) {
-    #if ENDSTOP_NOISE_THRESHOLD
-      endstop_poll_count = 0;   // Stop filtering (MUST be done first to prevent race condition)
-      validated_live_state = 0;
-    #endif
-    live_state = 0;
-  }
 }
 
 #if ENABLED(VALIDATE_HOMING_ENDSTOPS)
@@ -302,9 +288,7 @@ void Endstops::not_homing() {
   void Endstops::enable_z_probe(const bool onoff) {
     z_probe_enabled = onoff;
 
-    #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
-      update();
-    #endif
+    update();
   }
 #endif
 
diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp
index d549dc3cca8..9cd83907c1b 100644
--- a/Marlin/src/module/motion.cpp
+++ b/Marlin/src/module/motion.cpp
@@ -1522,6 +1522,20 @@ void homeaxis(const AxisEnum axis) {
       }
     #endif
 
+    // Reset flags for X, Y, Z motor locking
+    switch (axis) {
+      #if ENABLED(X_DUAL_ENDSTOPS)
+        case X_AXIS:
+      #endif
+      #if ENABLED(Y_DUAL_ENDSTOPS)
+        case Y_AXIS:
+      #endif
+      #if Z_MULTI_ENDSTOPS
+        case Z_AXIS:
+      #endif
+      stepper.set_separate_multi_axis(false);
+      default: break;
+    }
   #endif
 
   #if IS_SCARA