From 0b889df69c42806131e28780ea48172d6377f4df Mon Sep 17 00:00:00 2001 From: Manuel McLure Date: Sun, 19 Jun 2022 12:16:35 -0700 Subject: [PATCH 1/4] Remove tmc configuration section Use values in tmc_smart section for TMC26x drivers --- Marlin/Configuration_adv.h | 210 +++++---------------------- Marlin/src/core/drivers.h | 2 + Marlin/src/inc/SanityCheck.h | 8 + Marlin/src/module/stepper/TMC26X.cpp | 2 +- 4 files changed, 45 insertions(+), 177 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 96a3e04d0b77..3283023c9727 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2581,150 +2581,6 @@ //#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302) #endif -// @section tmc - -/** - * TMC26X Stepper Driver options - * - * The TMC26XStepper library is required for this stepper driver. - * https://github.com/trinamic/TMC26XStepper - */ -#if HAS_DRIVER(TMC26X) - - #if AXIS_DRIVER_TYPE_X(TMC26X) - #define X_MAX_CURRENT 1000 // (mA) - #define X_SENSE_RESISTOR 91 // (mOhms) - #define X_MICROSTEPS 16 // Number of microsteps - #endif - - #if AXIS_DRIVER_TYPE_X2(TMC26X) - #define X2_MAX_CURRENT 1000 - #define X2_SENSE_RESISTOR 91 - #define X2_MICROSTEPS X_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Y(TMC26X) - #define Y_MAX_CURRENT 1000 - #define Y_SENSE_RESISTOR 91 - #define Y_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_Y2(TMC26X) - #define Y2_MAX_CURRENT 1000 - #define Y2_SENSE_RESISTOR 91 - #define Y2_MICROSTEPS Y_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z(TMC26X) - #define Z_MAX_CURRENT 1000 - #define Z_SENSE_RESISTOR 91 - #define Z_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_Z2(TMC26X) - #define Z2_MAX_CURRENT 1000 - #define Z2_SENSE_RESISTOR 91 - #define Z2_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z3(TMC26X) - #define Z3_MAX_CURRENT 1000 - #define Z3_SENSE_RESISTOR 91 - #define Z3_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z4(TMC26X) - #define Z4_MAX_CURRENT 1000 - #define Z4_SENSE_RESISTOR 91 - #define Z4_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_I(TMC26X) - #define I_MAX_CURRENT 1000 - #define I_SENSE_RESISTOR 91 - #define I_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_J(TMC26X) - #define J_MAX_CURRENT 1000 - #define J_SENSE_RESISTOR 91 - #define J_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_K(TMC26X) - #define K_MAX_CURRENT 1000 - #define K_SENSE_RESISTOR 91 - #define K_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_U(TMC26X) - #define U_MAX_CURRENT 1000 - #define U_SENSE_RESISTOR 91 - #define U_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_V(TMC26X) - #define V_MAX_CURRENT 1000 - #define V_SENSE_RESISTOR 91 - #define V_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_W(TMC26X) - #define W_MAX_CURRENT 1000 - #define W_SENSE_RESISTOR 91 - #define W_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_E0(TMC26X) - #define E0_MAX_CURRENT 1000 - #define E0_SENSE_RESISTOR 91 - #define E0_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_E1(TMC26X) - #define E1_MAX_CURRENT 1000 - #define E1_SENSE_RESISTOR 91 - #define E1_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E2(TMC26X) - #define E2_MAX_CURRENT 1000 - #define E2_SENSE_RESISTOR 91 - #define E2_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E3(TMC26X) - #define E3_MAX_CURRENT 1000 - #define E3_SENSE_RESISTOR 91 - #define E3_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E4(TMC26X) - #define E4_MAX_CURRENT 1000 - #define E4_SENSE_RESISTOR 91 - #define E4_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E5(TMC26X) - #define E5_MAX_CURRENT 1000 - #define E5_SENSE_RESISTOR 91 - #define E5_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E6(TMC26X) - #define E6_MAX_CURRENT 1000 - #define E6_SENSE_RESISTOR 91 - #define E6_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E7(TMC26X) - #define E7_MAX_CURRENT 1000 - #define E7_SENSE_RESISTOR 91 - #define E7_MICROSTEPS E0_MICROSTEPS - #endif - -#endif // TMC26X - // @section tmc_smart /** @@ -2743,7 +2599,7 @@ * TMCStepper library is required to use TMC stepper drivers. * https://github.com/teemuatlut/TMCStepper */ -#if HAS_TRINAMIC_CONFIG +#if HAS_TRINAMIC_CONFIG || HAS_DRIVER(TMC26X) #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current @@ -2753,7 +2609,7 @@ */ #define INTERPOLATE true - #if AXIS_IS_TMC(X) + #if AXIS_IS_TMC_CONFIG(X) #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 @@ -2763,7 +2619,7 @@ //#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis #endif - #if AXIS_IS_TMC(X2) + #if AXIS_IS_TMC_CONFIG(X2) #define X2_CURRENT 800 #define X2_CURRENT_HOME X2_CURRENT #define X2_MICROSTEPS X_MICROSTEPS @@ -2773,7 +2629,7 @@ //#define X2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y) + #if AXIS_IS_TMC_CONFIG(Y) #define Y_CURRENT 800 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 @@ -2783,7 +2639,7 @@ //#define Y_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y2) + #if AXIS_IS_TMC_CONFIG(Y2) #define Y2_CURRENT 800 #define Y2_CURRENT_HOME Y2_CURRENT #define Y2_MICROSTEPS Y_MICROSTEPS @@ -2793,7 +2649,7 @@ //#define Y2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z) + #if AXIS_IS_TMC_CONFIG(Z) #define Z_CURRENT 800 #define Z_CURRENT_HOME Z_CURRENT #define Z_MICROSTEPS 16 @@ -2803,7 +2659,7 @@ //#define Z_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z2) + #if AXIS_IS_TMC_CONFIG(Z2) #define Z2_CURRENT 800 #define Z2_CURRENT_HOME Z2_CURRENT #define Z2_MICROSTEPS Z_MICROSTEPS @@ -2813,7 +2669,7 @@ //#define Z2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z3) + #if AXIS_IS_TMC_CONFIG(Z3) #define Z3_CURRENT 800 #define Z3_CURRENT_HOME Z3_CURRENT #define Z3_MICROSTEPS Z_MICROSTEPS @@ -2823,7 +2679,7 @@ //#define Z3_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z4) + #if AXIS_IS_TMC_CONFIG(Z4) #define Z4_CURRENT 800 #define Z4_CURRENT_HOME Z4_CURRENT #define Z4_MICROSTEPS Z_MICROSTEPS @@ -2833,7 +2689,7 @@ //#define Z4_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(I) + #if AXIS_IS_TMC_CONFIG(I) #define I_CURRENT 800 #define I_CURRENT_HOME I_CURRENT #define I_MICROSTEPS 16 @@ -2843,7 +2699,7 @@ //#define I_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(J) + #if AXIS_IS_TMC_CONFIG(J) #define J_CURRENT 800 #define J_CURRENT_HOME J_CURRENT #define J_MICROSTEPS 16 @@ -2853,7 +2709,7 @@ //#define J_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(K) + #if AXIS_IS_TMC_CONFIG(K) #define K_CURRENT 800 #define K_CURRENT_HOME K_CURRENT #define K_MICROSTEPS 16 @@ -2863,7 +2719,7 @@ //#define K_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(U) + #if AXIS_IS_TMC_CONFIG(U) #define U_CURRENT 800 #define U_CURRENT_HOME U_CURRENT #define U_MICROSTEPS 8 @@ -2873,7 +2729,7 @@ //#define U_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(V) + #if AXIS_IS_TMC_CONFIG(V) #define V_CURRENT 800 #define V_CURRENT_HOME V_CURRENT #define V_MICROSTEPS 8 @@ -2883,7 +2739,7 @@ //#define V_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(W) + #if AXIS_IS_TMC_CONFIG(W) #define W_CURRENT 800 #define W_CURRENT_HOME W_CURRENT #define W_MICROSTEPS 8 @@ -2893,7 +2749,7 @@ //#define W_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E0) + #if AXIS_IS_TMC_CONFIG(E0) #define E0_CURRENT 800 #define E0_MICROSTEPS 16 #define E0_RSENSE 0.11 @@ -2902,7 +2758,7 @@ //#define E0_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E1) + #if AXIS_IS_TMC_CONFIG(E1) #define E1_CURRENT 800 #define E1_MICROSTEPS E0_MICROSTEPS #define E1_RSENSE 0.11 @@ -2911,7 +2767,7 @@ //#define E1_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E2) + #if AXIS_IS_TMC_CONFIG(E2) #define E2_CURRENT 800 #define E2_MICROSTEPS E0_MICROSTEPS #define E2_RSENSE 0.11 @@ -2920,7 +2776,7 @@ //#define E2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E3) + #if AXIS_IS_TMC_CONFIG(E3) #define E3_CURRENT 800 #define E3_MICROSTEPS E0_MICROSTEPS #define E3_RSENSE 0.11 @@ -2929,7 +2785,7 @@ //#define E3_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E4) + #if AXIS_IS_TMC_CONFIG(E4) #define E4_CURRENT 800 #define E4_MICROSTEPS E0_MICROSTEPS #define E4_RSENSE 0.11 @@ -2938,7 +2794,7 @@ //#define E4_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E5) + #if AXIS_IS_TMC_CONFIG(E5) #define E5_CURRENT 800 #define E5_MICROSTEPS E0_MICROSTEPS #define E5_RSENSE 0.11 @@ -2947,7 +2803,7 @@ //#define E5_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E6) + #if AXIS_IS_TMC_CONFIG(E6) #define E6_CURRENT 800 #define E6_MICROSTEPS E0_MICROSTEPS #define E6_RSENSE 0.11 @@ -2956,7 +2812,7 @@ //#define E6_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E7) + #if AXIS_IS_TMC_CONFIG(E7) #define E7_CURRENT 800 #define E7_MICROSTEPS E0_MICROSTEPS #define E7_RSENSE 0.11 @@ -3050,15 +2906,17 @@ * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. */ - #define STEALTHCHOP_XY - #define STEALTHCHOP_Z - #define STEALTHCHOP_I - #define STEALTHCHOP_J - #define STEALTHCHOP_K - #define STEALTHCHOP_U - #define STEALTHCHOP_V - #define STEALTHCHOP_W - #define STEALTHCHOP_E + #if HAS_STEALTHCHOP + #define STEALTHCHOP_XY + #define STEALTHCHOP_Z + #define STEALTHCHOP_I + #define STEALTHCHOP_J + #define STEALTHCHOP_K + #define STEALTHCHOP_U + #define STEALTHCHOP_V + #define STEALTHCHOP_W + #define STEALTHCHOP_E + #endif /** * Optimize spreadCycle chopper parameters by using predefined parameter sets diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 7f9da909b248..681784a11d44 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -129,6 +129,8 @@ || AXIS_DRIVER_TYPE(A,TMC2660) \ || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) ) +#define AXIS_IS_TMC_CONFIG(A) ( AXIS_IS_TMC(A) || AXIS_DRIVER_TYPE(A,TMC26X) ) + // Test for a driver that uses SPI - this allows checking whether a _CS_ pin // is considered sensitive #define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \ diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 90516c932d9d..273af8393060 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -633,6 +633,14 @@ #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*." #elif defined(LEVEL_CENTER_TOO) #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." +#elif defined(X_MAX_CURRENT) || defined(X2_MAX_CURRENT) || defined(Y_MAX_CURRENT) || defined(Y2_MAX_CURRENT) || defined(Z_MAX_CURRENT) || defined(Z2_MAX_CURRENT) || defined(Z3_MAX_CURRENT) || defined(Z4_MAX_CURRENT) \ + || defined(I_MAX_CURRENT)|| defined(J_MAX_CURRENT)|| defined(K_MAX_CURRENT) || defined(U_MAX_CURRENT) || defined(V_MAX_CURRENT) || defined(W_MAX_CURRENT) \ + || defined(E0_MAX_CURRENT) || defined(E1_MAX_CURRENT) || defined(E2_MAX_CURRENT) || defined(E3_MAX_CURRENT) || defined(E4_MAX_CURRENT) || defined(E5_MAX_CURRENT) || defined(E6_MAX_CURRENT) || defined(E7_MAX_CURRENT) + #error "[AXIS]_MAX_CURRENT in section \"tmc\" is now [AXIS]_CURRENT in section \"tmc_smart\"." +#elif defined(X_SENSE_RESISTOR) || defined(X2_SENSE_RESISTOR) || defined(Y_SENSE_RESISTOR) || defined(Y2_SENSE_RESISTOR) || defined(Z_SENSE_RESISTOR) || defined(Z2_SENSE_RESISTOR) || defined(Z3_SENSE_RESISTOR) || defined(Z4_SENSE_RESISTOR) \ + || defined(I_SENSE_RESISTOR)|| defined(J_SENSE_RESISTOR)|| defined(K_SENSE_RESISTOR) || defined(U_SENSE_RESISTOR) || defined(V_SENSE_RESISTOR) || defined(W_SENSE_RESISTOR) \ + || defined(E0_SENSE_RESISTOR) || defined(E1_SENSE_RESISTOR) || defined(E2_SENSE_RESISTOR) || defined(E3_SENSE_RESISTOR) || defined(E4_SENSE_RESISTOR) || defined(E5_SENSE_RESISTOR) || defined(E6_SENSE_RESISTOR) || defined(E7_SENSE_RESISTOR) + #error "[AXIS]_SENSE_RESISTOR in section \"tmc\" is now [AXIS]_RSENSE in section \"tmc_smart\"" #endif constexpr float arm[] = AXIS_RELATIVE_MODES; diff --git a/Marlin/src/module/stepper/TMC26X.cpp b/Marlin/src/module/stepper/TMC26X.cpp index 52d84f84101c..f46163ea2de2 100644 --- a/Marlin/src/module/stepper/TMC26X.cpp +++ b/Marlin/src/module/stepper/TMC26X.cpp @@ -34,7 +34,7 @@ #include "TMC26X.h" -#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR) +#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_CURRENT, int(ST##_RSENSE * 1000)) #if AXIS_DRIVER_TYPE_X(TMC26X) _TMC26X_DEFINE(X); From e360f6b20463a73a02069db534e5e07c55da2a24 Mon Sep 17 00:00:00 2001 From: Manuel McLure Date: Sun, 19 Jun 2022 13:14:32 -0700 Subject: [PATCH 2/4] Modify URL to TMC26XStepper --- Marlin/Configuration_adv.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 3283023c9727..f32b99284c55 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2596,8 +2596,11 @@ * a resistor. * The drivers can also be used with hardware serial. * - * TMCStepper library is required to use TMC stepper drivers. + * TMCStepper library is required to use TMC stepper drivers except for the TMC26x. * https://github.com/teemuatlut/TMCStepper + * + * The TMC26XStepper library is required for TMC26X stepper drivers. + * https://github.com/MarlinFirmware/TMC26XStepper */ #if HAS_TRINAMIC_CONFIG || HAS_DRIVER(TMC26X) From 9d4aff12193ed1500f4d05297af9e3e3a001cb36 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 21 Jun 2022 22:25:26 -0500 Subject: [PATCH 3/4] extend description --- Marlin/Configuration_adv.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index f32b99284c55..641059ba0975 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2584,25 +2584,28 @@ // @section tmc_smart /** - * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode - * connect your SPI pins to the hardware SPI interface on your board and define - * the required CS pins in your `pins_MYBOARD.h` file. (e.g., RAMPS 1.4 uses AUX3 - * pins `X_CS_PIN 53`, `Y_CS_PIN 49`, etc.). - * You may also use software SPI if you wish to use general purpose IO pins. + * Trinamic Smart Drivers * - * To use TMC2208 stepper UART-configurable stepper drivers connect #_SERIAL_TX_PIN - * to the driver side PDN_UART pin with a 1K resistor. - * To use the reading capabilities, also connect #_SERIAL_RX_PIN to PDN_UART without - * a resistor. - * The drivers can also be used with hardware serial. + * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode: + * - Connect your SPI pins to the Hardware SPI interface on the board. + * Some boards have simple jumper connections! See your board's documentation. + * - Define the required Stepper CS pins in your `pins_MYBOARD.h` file. + * (See the RAMPS pins, for example.) + * - You can also use Software SPI with GPIO pins instead of Hardware SPI. * - * TMCStepper library is required to use TMC stepper drivers except for the TMC26x. - * https://github.com/teemuatlut/TMCStepper + * To use TMC220x stepper drivers with Serial UART: + * - Connect PDN_UART to the #_SERIAL_TX_PIN through a 1K resistor. + * For reading capabilities also connect PDN_UART to #_SERIAL_RX_PIN with no resistor. + * Some boards have simple jumper connections! See your board's documentation. + * - These drivers can also be used with Hardware Serial. * * The TMC26XStepper library is required for TMC26X stepper drivers. - * https://github.com/MarlinFirmware/TMC26XStepper + * https://github.com/MarlinFirmware/TMC26XStepper + * + * The TMCStepper library is required for other TMC stepper drivers. + * https://github.com/teemuatlut/TMCStepper */ -#if HAS_TRINAMIC_CONFIG || HAS_DRIVER(TMC26X) +#if HAS_TRINAMIC_CONFIG || HAS_TMC26X #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current @@ -2616,7 +2619,7 @@ #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 - #define X_RSENSE 0.11 + #define X_RSENSE 0.11 // Multiplied x1000 for TMC26X #define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ... //#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis //#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis @@ -3095,7 +3098,7 @@ */ #define TMC_ADV() { } -#endif // HAS_TRINAMIC_CONFIG +#endif // HAS_TRINAMIC_CONFIG || HAS_TMC26X // @section L64XX From e0c1f8d492858517c3a0ee25752ec5195c2efd50 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 21 Jun 2022 22:48:28 -0500 Subject: [PATCH 4/4] shorter sanity check --- Marlin/src/core/types.h | 2 ++ Marlin/src/inc/Conditionals_adv.h | 3 ++- Marlin/src/inc/SanityCheck.h | 19 +++++++++++-------- Marlin/src/module/stepper/trinamic.cpp | 2 -- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index fc3ef178b6df..c450371458dd 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -36,6 +36,8 @@ struct IF { typedef R type; }; template struct IF { typedef L type; }; +#define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7 + #define NUM_AXIS_GANG(V...) GANG_N(NUM_AXES, V) #define NUM_AXIS_CODE(V...) CODE_N(NUM_AXES, V) #define NUM_AXIS_LIST(V...) LIST_N(NUM_AXES, V) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 130e68f61ee9..7120748ba1c6 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -936,8 +936,8 @@ #undef CALIBRATION_MEASURE_IMIN #undef CALIBRATION_MEASURE_IMAX #if NUM_AXES < 3 - #undef Z_IDLE_HEIGHT #undef STEALTHCHOP_Z + #undef Z_IDLE_HEIGHT #undef Z_PROBE_SLED #undef Z_SAFE_HOMING #undef HOME_Z_FIRST @@ -947,6 +947,7 @@ #undef CNC_WORKSPACE_PLANES #if NUM_AXES < 2 #undef STEALTHCHOP_Y + #undef QUICK_HOME #endif #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 273af8393060..d20ea03f33df 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -633,19 +633,22 @@ #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*." #elif defined(LEVEL_CENTER_TOO) #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." -#elif defined(X_MAX_CURRENT) || defined(X2_MAX_CURRENT) || defined(Y_MAX_CURRENT) || defined(Y2_MAX_CURRENT) || defined(Z_MAX_CURRENT) || defined(Z2_MAX_CURRENT) || defined(Z3_MAX_CURRENT) || defined(Z4_MAX_CURRENT) \ - || defined(I_MAX_CURRENT)|| defined(J_MAX_CURRENT)|| defined(K_MAX_CURRENT) || defined(U_MAX_CURRENT) || defined(V_MAX_CURRENT) || defined(W_MAX_CURRENT) \ - || defined(E0_MAX_CURRENT) || defined(E1_MAX_CURRENT) || defined(E2_MAX_CURRENT) || defined(E3_MAX_CURRENT) || defined(E4_MAX_CURRENT) || defined(E5_MAX_CURRENT) || defined(E6_MAX_CURRENT) || defined(E7_MAX_CURRENT) - #error "[AXIS]_MAX_CURRENT in section \"tmc\" is now [AXIS]_CURRENT in section \"tmc_smart\"." -#elif defined(X_SENSE_RESISTOR) || defined(X2_SENSE_RESISTOR) || defined(Y_SENSE_RESISTOR) || defined(Y2_SENSE_RESISTOR) || defined(Z_SENSE_RESISTOR) || defined(Z2_SENSE_RESISTOR) || defined(Z3_SENSE_RESISTOR) || defined(Z4_SENSE_RESISTOR) \ - || defined(I_SENSE_RESISTOR)|| defined(J_SENSE_RESISTOR)|| defined(K_SENSE_RESISTOR) || defined(U_SENSE_RESISTOR) || defined(V_SENSE_RESISTOR) || defined(W_SENSE_RESISTOR) \ - || defined(E0_SENSE_RESISTOR) || defined(E1_SENSE_RESISTOR) || defined(E2_SENSE_RESISTOR) || defined(E3_SENSE_RESISTOR) || defined(E4_SENSE_RESISTOR) || defined(E5_SENSE_RESISTOR) || defined(E6_SENSE_RESISTOR) || defined(E7_SENSE_RESISTOR) - #error "[AXIS]_SENSE_RESISTOR in section \"tmc\" is now [AXIS]_RSENSE in section \"tmc_smart\"" #endif constexpr float arm[] = AXIS_RELATIVE_MODES; static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); +// Consolidate TMC26X, validate migration (#24373) +#define _ISMAX_1(A) defined(A##_MAX_CURRENT) +#define _ISSNS_1(A) defined(A##_SENSE_RESISTOR) +#if DO(ISMAX,||,ALL_AXIS_NAMES) + #error "*_MAX_CURRENT is now set with *_CURRENT." +#elif DO(ISSNS,||,ALL_AXIS_NAMES) + #error "*_SENSE_RESISTOR (in Milli-Ohms) is now set with *_RSENSE (in Ohms), so you must divide values by 1000." +#endif +#undef _ISMAX_1 +#undef _ISSNS_1 + /** * Probe temp compensation requirements */ diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 76373515569e..1db290b6d0c2 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -1023,8 +1023,6 @@ void reset_trinamic_drivers() { // 2. For each axis in use, static_assert using a constexpr function, which counts the // number of matching/conflicting axis. If the value is not exactly 1, fail. -#define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7 - #if ANY_AXIS_HAS(HW_SERIAL) // Hardware serial names are compared as strings, since actually resolving them cannot occur in a constexpr. // Using a fixed-length character array for the port name allows this to be constexpr compatible.