From 99af971f727ad7e34dbdf2a41f1384a50223a476 Mon Sep 17 00:00:00 2001 From: Frederik Kemner Date: Wed, 15 Feb 2023 05:25:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20SPI=20endstops=20for=20X/Y=20Dua?= =?UTF-8?q?l=20and=20Core=20(#25371)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/endstops.cpp | 69 +++++++++++++--------------------- Marlin/src/module/endstops.h | 6 +++ 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index cabb0fbf190f..ef5f5d06e120 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -1330,75 +1330,54 @@ void Endstops::update() { bool hit = false; #if X_SPI_SENSORLESS if (tmc_spi_homing.x && (stepperX.test_stall_status() - #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SPI_SENSORLESS + #if Y_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) || stepperY.test_stall_status() - #elif CORE_IS_XZ && Z_SPI_SENSORLESS + #elif Z_SPI_SENSORLESS && CORE_IS_XZ || stepperZ.test_stall_status() #endif - )) { - SBI(live_state, X_ENDSTOP); - hit = true; - } + )) { SBI(live_state, X_ENDSTOP); hit = true; } + #if ENABLED(X_DUAL_ENDSTOPS) + if (tmc_spi_homing.x && stepperX2.test_stall_status()) { SBI(live_state, X2_ENDSTOP); hit = true; } + #endif #endif #if Y_SPI_SENSORLESS if (tmc_spi_homing.y && (stepperY.test_stall_status() - #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SPI_SENSORLESS + #if X_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) || stepperX.test_stall_status() - #elif CORE_IS_YZ && Z_SPI_SENSORLESS + #elif Z_SPI_SENSORLESS && CORE_IS_YZ || stepperZ.test_stall_status() #endif - )) { - SBI(live_state, Y_ENDSTOP); - hit = true; - } + )) { SBI(live_state, Y_ENDSTOP); hit = true; } + #if ENABLED(Y_DUAL_ENDSTOPS) + if (tmc_spi_homing.y && stepperY2.test_stall_status()) { SBI(live_state, Y2_ENDSTOP); hit = true; } + #endif #endif #if Z_SPI_SENSORLESS if (tmc_spi_homing.z && (stepperZ.test_stall_status() - #if CORE_IS_XZ && X_SPI_SENSORLESS + #if X_SPI_SENSORLESS && CORE_IS_XZ || stepperX.test_stall_status() - #elif CORE_IS_YZ && Y_SPI_SENSORLESS + #elif Y_SPI_SENSORLESS && CORE_IS_YZ || stepperY.test_stall_status() #endif - )) { - SBI(live_state, Z_ENDSTOP); - hit = true; - } + )) { SBI(live_state, Z_ENDSTOP); hit = true; } #endif #if I_SPI_SENSORLESS - if (tmc_spi_homing.i && stepperI.test_stall_status()) { - SBI(live_state, I_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.i && stepperI.test_stall_status()) { SBI(live_state, I_ENDSTOP); hit = true; } #endif #if J_SPI_SENSORLESS - if (tmc_spi_homing.j && stepperJ.test_stall_status()) { - SBI(live_state, J_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.j && stepperJ.test_stall_status()) { SBI(live_state, J_ENDSTOP); hit = true; } #endif #if K_SPI_SENSORLESS - if (tmc_spi_homing.k && stepperK.test_stall_status()) { - SBI(live_state, K_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.k && stepperK.test_stall_status()) { SBI(live_state, K_ENDSTOP); hit = true; } #endif #if U_SPI_SENSORLESS - if (tmc_spi_homing.u && stepperU.test_stall_status()) { - SBI(live_state, U_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.u && stepperU.test_stall_status()) { SBI(live_state, U_ENDSTOP); hit = true; } #endif #if V_SPI_SENSORLESS - if (tmc_spi_homing.v && stepperV.test_stall_status()) { - SBI(live_state, V_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.v && stepperV.test_stall_status()) { SBI(live_state, V_ENDSTOP); hit = true; } #endif #if W_SPI_SENSORLESS - if (tmc_spi_homing.w && stepperW.test_stall_status()) { - SBI(live_state, W_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.w && stepperW.test_stall_status()) { SBI(live_state, W_ENDSTOP); hit = true; } #endif if (TERN0(ENDSTOP_INTERRUPTS_FEATURE, hit)) update(); @@ -1408,7 +1387,13 @@ void Endstops::update() { void Endstops::clear_endstop_state() { TERN_(X_SPI_SENSORLESS, CBI(live_state, X_ENDSTOP)); + #if BOTH(X_SPI_SENSORLESS, X_DUAL_ENDSTOPS) + CBI(live_state, X2_ENDSTOP); + #endif TERN_(Y_SPI_SENSORLESS, CBI(live_state, Y_ENDSTOP)); + #if BOTH(Y_SPI_SENSORLESS, Y_DUAL_ENDSTOPS) + CBI(live_state, Y2_ENDSTOP); + #endif TERN_(Z_SPI_SENSORLESS, CBI(live_state, Z_ENDSTOP)); TERN_(I_SPI_SENSORLESS, CBI(live_state, I_ENDSTOP)); TERN_(J_SPI_SENSORLESS, CBI(live_state, J_ENDSTOP)); diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index bffa7fdc39cd..4d64455b21e1 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -85,9 +85,15 @@ enum EndstopEnum : char { // Endstops can be either MIN or MAX but not both #if HAS_X_MIN || HAS_X_MAX , X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN) + #if ENABLED(X_DUAL_ENDSTOPS) + , X2_ENDSTOP = TERN(X_HOME_TO_MAX, X2_MAX, X2_MIN) + #endif #endif #if HAS_Y_MIN || HAS_Y_MAX , Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) + #if ENABLED(Y_DUAL_ENDSTOPS) + , Y2_ENDSTOP = TERN(Y_HOME_TO_MAX, Y2_MAX, Y2_MIN) + #endif #endif #if HAS_Z_MIN || HAS_Z_MAX || HOMING_Z_WITH_PROBE , Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN))