From 6771dc14966175ee9ce516bd02741637ebab43d5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Sep 2020 21:11:22 -0500 Subject: [PATCH] Move TMC standby init to a custom method --- Marlin/src/MarlinCore.cpp | 69 ++++++++++++++++++++++-------- Marlin/src/inc/Conditionals_post.h | 48 --------------------- 2 files changed, 52 insertions(+), 65 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 8f6358667d20..c6c6ef9b0db5 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -867,6 +867,57 @@ void stop() { } } +inline void tmc_standby_setup() { + #if PIN_EXISTS(X_STDBY) + SET_INPUT_PULLDOWN(X_STDBY_PIN); + #endif + #if PIN_EXISTS(X2_STDBY) + SET_INPUT_PULLDOWN(X2_STDBY_PIN); + #endif + #if PIN_EXISTS(Y_STDBY) + SET_INPUT_PULLDOWN(Y_STDBY_PIN); + #endif + #if PIN_EXISTS(Y2_STDBY) + SET_INPUT_PULLDOWN(Y2_STDBY_PIN); + #endif + #if PIN_EXISTS(Z_STDBY) + SET_INPUT_PULLDOWN(Z_STDBY_PIN); + #endif + #if PIN_EXISTS(Z2_STDBY) + SET_INPUT_PULLDOWN(Z2_STDBY_PIN); + #endif + #if PIN_EXISTS(Z3_STDBY) + SET_INPUT_PULLDOWN(Z3_STDBY_PIN); + #endif + #if PIN_EXISTS(Z4_STDBY) + SET_INPUT_PULLDOWN(Z4_STDBY_PIN); + #endif + #if PIN_EXISTS(E0_STDBY) + SET_INPUT_PULLDOWN(E0_STDBY_PIN); + #endif + #if PIN_EXISTS(E1_STDBY) + SET_INPUT_PULLDOWN(E1_STDBY_PIN); + #endif + #if PIN_EXISTS(E2_STDBY) + SET_INPUT_PULLDOWN(E2_STDBY_PIN); + #endif + #if PIN_EXISTS(E3_STDBY) + SET_INPUT_PULLDOWN(E3_STDBY_PIN); + #endif + #if PIN_EXISTS(E4_STDBY) + SET_INPUT_PULLDOWN(E4_STDBY_PIN); + #endif + #if PIN_EXISTS(E5_STDBY) + SET_INPUT_PULLDOWN(E5_STDBY_PIN); + #endif + #if PIN_EXISTS(E6_STDBY) + SET_INPUT_PULLDOWN(E6_STDBY_PIN); + #endif + #if PIN_EXISTS(E7_STDBY) + SET_INPUT_PULLDOWN(E7_STDBY_PIN); + #endif +} + /** * Marlin entry-point: Set up before the program loop * - Set up the kill pin, filament runout, power hold @@ -888,23 +939,7 @@ void stop() { */ void setup() { - // TMC Low Power Standby pins need to be set as early as possible or they won't be usable - TERN_(HAS_X_TMC_STDBY,SET_INPUT_PULLDOWN(X_STDBY_PIN)); - TERN_(HAS_X2_TMC_STDBY,SET_INPUT_PULLDOWN(X2_STDBY_PIN)); - TERN_(HAS_Y_TMC_STDBY,SET_INPUT_PULLDOWN(Y_STDBY_PIN)); - TERN_(HAS_Y2_TMC_STDBY,SET_INPUT_PULLDOWN(Y2_STDBY_PIN)); - TERN_(HAS_Z_TMC_STDBY,SET_INPUT_PULLDOWN(Z_STDBY_PIN)); - TERN_(HAS_Z2_TMC_STDBY,SET_INPUT_PULLDOWN(Z2_STDBY_PIN)); - TERN_(HAS_Z3_TMC_STDBY,SET_INPUT_PULLDOWN(Z3_STDBY_PIN)); - TERN_(HAS_Z4_TMC_STDBY,SET_INPUT_PULLDOWN(Z4_STDBY_PIN)); - TERN_(HAS_E0_TMC_STDBY,SET_INPUT_PULLDOWN(E0_STDBY_PIN)); - TERN_(HAS_E1_TMC_STDBY,SET_INPUT_PULLDOWN(E1_STDBY_PIN)); - TERN_(HAS_E2_TMC_STDBY,SET_INPUT_PULLDOWN(E2_STDBY_PIN)); - TERN_(HAS_E3_TMC_STDBY,SET_INPUT_PULLDOWN(E3_STDBY_PIN)); - TERN_(HAS_E4_TMC_STDBY,SET_INPUT_PULLDOWN(E4_STDBY_PIN)); - TERN_(HAS_E5_TMC_STDBY,SET_INPUT_PULLDOWN(E5_STDBY_PIN)); - TERN_(HAS_E6_TMC_STDBY,SET_INPUT_PULLDOWN(E6_STDBY_PIN)); - TERN_(HAS_E7_TMC_STDBY,SET_INPUT_PULLDOWN(E7_STDBY_PIN)); + tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 4942a5d9048f..c9a29b351cbb 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1336,9 +1336,6 @@ #if PIN_EXISTS(X_MS1) #define HAS_X_MS_PINS 1 #endif -#if PIN_EXISTS(X_STDBY) - #define HAS_X_TMC_STDBY 1 -#endif #if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) #define HAS_X2_ENABLE 1 @@ -1352,9 +1349,6 @@ #if PIN_EXISTS(X2_MS1) #define HAS_X2_MS_PINS 1 #endif -#if PIN_EXISTS(X2_STDBY) - #define HAS_X2_TMC_STDBY 1 -#endif #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) #define HAS_Y_ENABLE 1 @@ -1368,9 +1362,6 @@ #if PIN_EXISTS(Y_MS1) #define HAS_Y_MS_PINS 1 #endif -#if PIN_EXISTS(Y_STDBY) - #define HAS_Y_TMC_STDBY 1 -#endif #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) #define HAS_Y2_ENABLE 1 @@ -1384,9 +1375,6 @@ #if PIN_EXISTS(Y2_MS1) #define HAS_Y2_MS_PINS 1 #endif -#if PIN_EXISTS(Y2_STDBY) - #define HAS_Y2_TMC_STDBY 1 -#endif #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) #define HAS_Z_ENABLE 1 @@ -1400,9 +1388,6 @@ #if PIN_EXISTS(Z_MS1) #define HAS_Z_MS_PINS 1 #endif -#if PIN_EXISTS(Z_STDBY) - #define HAS_Z_TMC_STDBY 1 -#endif #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) #define HAS_Z2_ENABLE 1 @@ -1416,9 +1401,6 @@ #if PIN_EXISTS(Z2_MS1) #define HAS_Z2_MS_PINS 1 #endif -#if PIN_EXISTS(Z2_STDBY) - #define HAS_Z2_TMC_STDBY 1 -#endif #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) #define HAS_Z3_ENABLE 1 @@ -1432,9 +1414,6 @@ #if PIN_EXISTS(Z3_MS1) #define HAS_Z3_MS_PINS 1 #endif -#if PIN_EXISTS(Z3_STDBY) - #define HAS_Z3_TMC_STDBY 1 -#endif #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) #define HAS_Z4_ENABLE 1 @@ -1448,9 +1427,6 @@ #if PIN_EXISTS(Z4_MS1) #define HAS_Z4_MS_PINS 1 #endif -#if PIN_EXISTS(Z4_STDBY) - #define HAS_Z4_TMC_STDBY 1 -#endif // Extruder steppers and solenoids #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) @@ -1468,9 +1444,6 @@ #if PIN_EXISTS(SOL0) #define HAS_SOLENOID_0 1 #endif -#if PIN_EXISTS(E0_STDBY) - #define HAS_E0_TMC_STDBY 1 -#endif #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) #define HAS_E1_ENABLE 1 @@ -1487,9 +1460,6 @@ #if PIN_EXISTS(SOL1) #define HAS_SOLENOID_1 1 #endif -#if PIN_EXISTS(E1_STDBY) - #define HAS_E1_TMC_STDBY 1 -#endif #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) #define HAS_E2_ENABLE 1 @@ -1506,9 +1476,6 @@ #if PIN_EXISTS(SOL2) #define HAS_SOLENOID_2 1 #endif -#if PIN_EXISTS(E2_STDBY) - #define HAS_E2_TMC_STDBY 1 -#endif #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) #define HAS_E3_ENABLE 1 @@ -1525,9 +1492,6 @@ #if PIN_EXISTS(SOL3) #define HAS_SOLENOID_3 1 #endif -#if PIN_EXISTS(E3_STDBY) - #define HAS_E3_TMC_STDBY 1 -#endif #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) #define HAS_E4_ENABLE 1 @@ -1544,9 +1508,6 @@ #if PIN_EXISTS(SOL4) #define HAS_SOLENOID_4 1 #endif -#if PIN_EXISTS(E4_STDBY) - #define HAS_E4_TMC_STDBY 1 -#endif #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) #define HAS_E5_ENABLE 1 @@ -1563,9 +1524,6 @@ #if PIN_EXISTS(SOL5) #define HAS_SOLENOID_5 1 #endif -#if PIN_EXISTS(E5_STDBY) - #define HAS_E5_TMC_STDBY 1 -#endif #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) #define HAS_E6_ENABLE 1 @@ -1582,9 +1540,6 @@ #if PIN_EXISTS(SOL6) #define HAS_SOLENOID_6 1 #endif -#if PIN_EXISTS(E6_STDBY) - #define HAS_E6_TMC_STDBY 1 -#endif #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) #define HAS_E7_ENABLE 1 @@ -1601,9 +1556,6 @@ #if PIN_EXISTS(SOL7) #define HAS_SOLENOID_7 1 #endif -#if PIN_EXISTS(E7_STDBY) - #define HAS_E7_TMC_STDBY 1 -#endif // // Trinamic Stepper Drivers