diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index eb77556b6..1f0bc0559 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -551,6 +551,29 @@ #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the probe. +/** + * Specify Stepper Driver types + * The options are used to determine driver pulse timings as well as more advanced functionality. + * Stepper timing options can be overridden in Configuration_adv.h + * + * Options: A4988, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100, + * TMC2130, TMC2130_STANDALONE, TMC2208, TMC2208_STANDALONE, + * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, + * TMC5130, TMC5130_STANDALONE + * :['A4988', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE'] + */ +#define X_DRIVER_TYPE A4988 +#define Y_DRIVER_TYPE A4988 +#define Z_DRIVER_TYPE A4988 +#define X2_DRIVER_TYPE A4988 +#define Y2_DRIVER_TYPE A4988 +#define Z2_DRIVER_TYPE A4988 +#define E0_DRIVER_TYPE A4988 +#define E1_DRIVER_TYPE A4988 +#define E2_DRIVER_TYPE A4988 +#define E3_DRIVER_TYPE A4988 +#define E4_DRIVER_TYPE A4988 + // Enable this feature if all enabled endstop pins are interrupt-capable. // This will remove the need to poll the interrupt pins, saving many CPU cycles. //#define ENDSTOP_INTERRUPTS_FEATURE diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index dfdd17e4e..42827a6ee 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -837,15 +837,17 @@ /** * Minimum delay after setting the stepper DIR (in ns) - * 0 : No delay (Expect at least 10µS since one Stepper ISR must transpire) - * 20 : Minimum for TMC2xxx drivers - * 200 : Minimum for A4988 drivers - * 500 : Minimum for LV8729 drivers (guess, no info in datasheet) - * 650 : Minimum for DRV8825 drivers - * 1500 : Minimum for TB6600 drivers (guess, no info in datasheet) - *15000 : Minimum for TB6560 drivers (guess, no info in datasheet) + * 0 : No delay (Expect at least 10µS since one Stepper ISR must transpire) + * 20 : Minimum for TMC2xxx drivers + * 200 : Minimum for A4988 drivers + * 500 : Minimum for LV8729 drivers (guess, no info in datasheet) + * 650 : Minimum for DRV8825 drivers + * 1500 : Minimum for TB6600 drivers (guess, no info in datasheet) + * 15000 : Minimum for TB6560 drivers (guess, no info in datasheet) + * + * Override the default value based on the driver type set in Configuration.h. */ -#define MINIMUM_STEPPER_DIR_DELAY 0 +//#define MINIMUM_STEPPER_DIR_DELAY 650 /** * Minimum stepper driver pulse width (in µs) @@ -855,8 +857,10 @@ * 2 : Minimum for DRV8825 stepper drivers * 3 : Minimum for TB6600 stepper drivers * 30 : Minimum for TB6560 stepper drivers + * + * Override the default value based on the driver type set in Configuration.h. */ -#define MINIMUM_STEPPER_PULSE 2 +//#define MINIMUM_STEPPER_PULSE 2 /** * Maximum stepping rate (in Hz) the stepper driver allows @@ -867,8 +871,10 @@ * 150000 : Maximum for TB6600 stepper driver * 130000 : Maximum for LV8729 stepper driver * 15000 : Maximum for TB6560 stepper driver + * + * Override the default value based on the driver type set in Configuration.h. */ -#define MAXIMUM_STEPPER_RATE 250000 +//#define MAXIMUM_STEPPER_RATE 250000 // @section temperature @@ -1036,23 +1042,12 @@ // @section tmc /** - * Enable this section if you have TMC26X motor drivers. - * You will need to import the TMC26XStepper library into the Arduino IDE for this - * (https://github.com/trinamic/TMC26XStepper.git) + * TMC26X Stepper Driver options + * + * The TMC26XStepper library is required for this stepper driver. + * https://github.com/trinamic/TMC26XStepper */ -//#define HAVE_TMC26X -#if ENABLED(HAVE_TMC26X) // Choose your axes here. This is mandatory! - //#define X_IS_TMC26X - //#define X2_IS_TMC26X - //#define Y_IS_TMC26X - //#define Y2_IS_TMC26X - //#define Z_IS_TMC26X - //#define Z2_IS_TMC26X - //#define E0_IS_TMC26X - //#define E1_IS_TMC26X - //#define E2_IS_TMC26X - //#define E3_IS_TMC26X - //#define E4_IS_TMC26X +#if HAS_DRIVER(TMC26X) #define X_MAX_CURRENT 1000 // in mA #define X_SENSE_RESISTOR 91 // in mOhms @@ -1098,62 +1093,29 @@ #define E4_SENSE_RESISTOR 91 #define E4_MICROSTEPS 16 -#endif +#endif // TMC26X // @section tmc_smart /** - * Enable this for SilentStepStick Trinamic TMC2130 SPI-configurable stepper drivers. - * - * You'll also need the TMC2130Stepper Arduino library - * (https://github.com/teemuatlut/TMC2130Stepper). - * * To use TMC2130 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. - */ -//#define HAVE_TMC2130 -#if ENABLED(HAVE_TMC2130) // Choose your axes here. This is mandatory! - //#define X_IS_TMC2130 - //#define X2_IS_TMC2130 - //#define Y_IS_TMC2130 - //#define Y2_IS_TMC2130 - //#define Z_IS_TMC2130 - //#define Z2_IS_TMC2130 - //#define E0_IS_TMC2130 - //#define E1_IS_TMC2130 - //#define E2_IS_TMC2130 - //#define E3_IS_TMC2130 - //#define E4_IS_TMC2130 -#endif - -/** - * Enable this for SilentStepStick Trinamic TMC2208 UART-configurable stepper drivers. - * Connect #_SERIAL_TX_PIN to the driver side PDN_UART pin with a 1K resistor. + * + * The TMC2130Stepper library is required for this stepper driver. + * https://github.com/teemuatlut/TMC2130Stepper + * + * 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. * - * You'll also need the TMC2208Stepper Arduino library - * (https://github.com/teemuatlut/TMC2208Stepper). + * The TMC2208Stepper library is required for this stepper driver. + * https://github.com/teemuatlut/TMC2208Stepper */ -//#define HAVE_TMC2208 -#if ENABLED(HAVE_TMC2208) // Choose your axes here. This is mandatory! - //#define X_IS_TMC2208 - //#define X2_IS_TMC2208 - //#define Y_IS_TMC2208 - //#define Y2_IS_TMC2208 - //#define Z_IS_TMC2208 - //#define Z2_IS_TMC2208 - //#define E0_IS_TMC2208 - //#define E1_IS_TMC2208 - //#define E2_IS_TMC2208 - //#define E3_IS_TMC2208 - //#define E4_IS_TMC2208 -#endif - -#if ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208) +#if HAS_TRINAMIC #define R_SENSE 0.11 // R_sense resistor for SilentStepStick2130 #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current @@ -1308,25 +1270,12 @@ // @section L6470 /** - * Enable this section if you have L6470 motor drivers. - * You need to import the L6470 library into the Arduino IDE for this. - * (https://github.com/ameyer/Arduino-L6470) + * L6470 Stepper Driver options + * + * The Arduino-L6470 library is required for this stepper driver. + * https://github.com/ameyer/Arduino-L6470 */ - -//#define HAVE_L6470DRIVER -#if ENABLED(HAVE_L6470DRIVER) - - //#define X_IS_L6470 - //#define X2_IS_L6470 - //#define Y_IS_L6470 - //#define Y2_IS_L6470 - //#define Z_IS_L6470 - //#define Z2_IS_L6470 - //#define E0_IS_L6470 - //#define E1_IS_L6470 - //#define E2_IS_L6470 - //#define E3_IS_L6470 - //#define E4_IS_L6470 +#if HAS_DRIVER(L6470) #define X_MICROSTEPS 16 // number of microsteps #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off @@ -1372,7 +1321,7 @@ #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 -#endif +#endif // L6470 /** * TWI/I2C BUS diff --git a/Marlin/src/HAL/HAL_AVR/SanityCheck.h b/Marlin/src/HAL/HAL_AVR/SanityCheck.h index f2907205d..254da910c 100644 --- a/Marlin/src/HAL/HAL_AVR/SanityCheck.h +++ b/Marlin/src/HAL/HAL_AVR/SanityCheck.h @@ -99,7 +99,7 @@ /** * TMC2208 software UART and ENDSTOP_INTERRUPTS both use pin change interrupts (PCI) */ -#if ENABLED(HAVE_TMC2208) && ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !( \ +#if HAS_DRIVER(TMC2208) && ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !( \ defined(X_HARDWARE_SERIAL ) \ || defined(X2_HARDWARE_SERIAL) \ || defined(Y_HARDWARE_SERIAL ) \ diff --git a/Marlin/src/HAL/HAL_DUE/SanityCheck.h b/Marlin/src/HAL/HAL_DUE/SanityCheck.h index 16e07bd3b..f24233a85 100644 --- a/Marlin/src/HAL/HAL_DUE/SanityCheck.h +++ b/Marlin/src/HAL/HAL_DUE/SanityCheck.h @@ -41,7 +41,7 @@ */ #define _IS_HW_SPI(P) (defined(TMC_SW_##P) && (TMC_SW_##P == MOSI_PIN || TMC_SW_##P == MISO_PIN || TMC_SW_##P == SCK_PIN)) -#if ENABLED(SDSUPPORT) && ENABLED(HAVE_TMC2130) +#if ENABLED(SDSUPPORT) && HAS_DRIVER(TMC2130) #if ENABLED(TMC_USE_SW_SPI) #if DISABLED(DUE_SOFTWARE_SPI) && (_IS_HW_SPI(MOSI) || _IS_HW_SPI(MISO) || _IS_HW_SPI(SCK)) #error "DUE hardware SPI is required but is incompatible with TMC2130 software SPI. Either disable TMC_USE_SW_SPI or use separate pins for the two SPIs." diff --git a/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h b/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h index a408a6c58..16299696a 100644 --- a/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h +++ b/Marlin/src/HAL/HAL_LPC1768/SanityCheck.h @@ -66,7 +66,7 @@ #endif #endif // SPINDLE_LASER_ENABLE -#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && ENABLED(HAVE_TMC2130) && DISABLED(TMC_USE_SW_SPI) \ +#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI) \ && (MB(RAMPS_14_RE_ARM_EFB) \ || MB(RAMPS_14_RE_ARM_EEB) \ || MB(RAMPS_14_RE_ARM_EFF) \ diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index dde04cca0..5e46d86fd 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -712,10 +712,10 @@ void setup() { SERIAL_PROTOCOLLNPGM("start"); SERIAL_ECHO_START(); - #if ENABLED(HAVE_TMC2130) + #if HAS_DRIVER(TMC2130) tmc_init_cs_pins(); #endif - #if ENABLED(HAVE_TMC2208) + #if HAS_DRIVER(TMC2208) tmc2208_serial_begin(); #endif diff --git a/Marlin/src/config/default/Configuration.h b/Marlin/src/config/default/Configuration.h index eb77556b6..1f0bc0559 100644 --- a/Marlin/src/config/default/Configuration.h +++ b/Marlin/src/config/default/Configuration.h @@ -551,6 +551,29 @@ #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the probe. +/** + * Specify Stepper Driver types + * The options are used to determine driver pulse timings as well as more advanced functionality. + * Stepper timing options can be overridden in Configuration_adv.h + * + * Options: A4988, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100, + * TMC2130, TMC2130_STANDALONE, TMC2208, TMC2208_STANDALONE, + * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, + * TMC5130, TMC5130_STANDALONE + * :['A4988', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE'] + */ +#define X_DRIVER_TYPE A4988 +#define Y_DRIVER_TYPE A4988 +#define Z_DRIVER_TYPE A4988 +#define X2_DRIVER_TYPE A4988 +#define Y2_DRIVER_TYPE A4988 +#define Z2_DRIVER_TYPE A4988 +#define E0_DRIVER_TYPE A4988 +#define E1_DRIVER_TYPE A4988 +#define E2_DRIVER_TYPE A4988 +#define E3_DRIVER_TYPE A4988 +#define E4_DRIVER_TYPE A4988 + // Enable this feature if all enabled endstop pins are interrupt-capable. // This will remove the need to poll the interrupt pins, saving many CPU cycles. //#define ENDSTOP_INTERRUPTS_FEATURE diff --git a/Marlin/src/config/default/Configuration_adv.h b/Marlin/src/config/default/Configuration_adv.h index dfdd17e4e..42827a6ee 100644 --- a/Marlin/src/config/default/Configuration_adv.h +++ b/Marlin/src/config/default/Configuration_adv.h @@ -837,15 +837,17 @@ /** * Minimum delay after setting the stepper DIR (in ns) - * 0 : No delay (Expect at least 10µS since one Stepper ISR must transpire) - * 20 : Minimum for TMC2xxx drivers - * 200 : Minimum for A4988 drivers - * 500 : Minimum for LV8729 drivers (guess, no info in datasheet) - * 650 : Minimum for DRV8825 drivers - * 1500 : Minimum for TB6600 drivers (guess, no info in datasheet) - *15000 : Minimum for TB6560 drivers (guess, no info in datasheet) + * 0 : No delay (Expect at least 10µS since one Stepper ISR must transpire) + * 20 : Minimum for TMC2xxx drivers + * 200 : Minimum for A4988 drivers + * 500 : Minimum for LV8729 drivers (guess, no info in datasheet) + * 650 : Minimum for DRV8825 drivers + * 1500 : Minimum for TB6600 drivers (guess, no info in datasheet) + * 15000 : Minimum for TB6560 drivers (guess, no info in datasheet) + * + * Override the default value based on the driver type set in Configuration.h. */ -#define MINIMUM_STEPPER_DIR_DELAY 0 +//#define MINIMUM_STEPPER_DIR_DELAY 650 /** * Minimum stepper driver pulse width (in µs) @@ -855,8 +857,10 @@ * 2 : Minimum for DRV8825 stepper drivers * 3 : Minimum for TB6600 stepper drivers * 30 : Minimum for TB6560 stepper drivers + * + * Override the default value based on the driver type set in Configuration.h. */ -#define MINIMUM_STEPPER_PULSE 2 +//#define MINIMUM_STEPPER_PULSE 2 /** * Maximum stepping rate (in Hz) the stepper driver allows @@ -867,8 +871,10 @@ * 150000 : Maximum for TB6600 stepper driver * 130000 : Maximum for LV8729 stepper driver * 15000 : Maximum for TB6560 stepper driver + * + * Override the default value based on the driver type set in Configuration.h. */ -#define MAXIMUM_STEPPER_RATE 250000 +//#define MAXIMUM_STEPPER_RATE 250000 // @section temperature @@ -1036,23 +1042,12 @@ // @section tmc /** - * Enable this section if you have TMC26X motor drivers. - * You will need to import the TMC26XStepper library into the Arduino IDE for this - * (https://github.com/trinamic/TMC26XStepper.git) + * TMC26X Stepper Driver options + * + * The TMC26XStepper library is required for this stepper driver. + * https://github.com/trinamic/TMC26XStepper */ -//#define HAVE_TMC26X -#if ENABLED(HAVE_TMC26X) // Choose your axes here. This is mandatory! - //#define X_IS_TMC26X - //#define X2_IS_TMC26X - //#define Y_IS_TMC26X - //#define Y2_IS_TMC26X - //#define Z_IS_TMC26X - //#define Z2_IS_TMC26X - //#define E0_IS_TMC26X - //#define E1_IS_TMC26X - //#define E2_IS_TMC26X - //#define E3_IS_TMC26X - //#define E4_IS_TMC26X +#if HAS_DRIVER(TMC26X) #define X_MAX_CURRENT 1000 // in mA #define X_SENSE_RESISTOR 91 // in mOhms @@ -1098,62 +1093,29 @@ #define E4_SENSE_RESISTOR 91 #define E4_MICROSTEPS 16 -#endif +#endif // TMC26X // @section tmc_smart /** - * Enable this for SilentStepStick Trinamic TMC2130 SPI-configurable stepper drivers. - * - * You'll also need the TMC2130Stepper Arduino library - * (https://github.com/teemuatlut/TMC2130Stepper). - * * To use TMC2130 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. - */ -//#define HAVE_TMC2130 -#if ENABLED(HAVE_TMC2130) // Choose your axes here. This is mandatory! - //#define X_IS_TMC2130 - //#define X2_IS_TMC2130 - //#define Y_IS_TMC2130 - //#define Y2_IS_TMC2130 - //#define Z_IS_TMC2130 - //#define Z2_IS_TMC2130 - //#define E0_IS_TMC2130 - //#define E1_IS_TMC2130 - //#define E2_IS_TMC2130 - //#define E3_IS_TMC2130 - //#define E4_IS_TMC2130 -#endif - -/** - * Enable this for SilentStepStick Trinamic TMC2208 UART-configurable stepper drivers. - * Connect #_SERIAL_TX_PIN to the driver side PDN_UART pin with a 1K resistor. + * + * The TMC2130Stepper library is required for this stepper driver. + * https://github.com/teemuatlut/TMC2130Stepper + * + * 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. * - * You'll also need the TMC2208Stepper Arduino library - * (https://github.com/teemuatlut/TMC2208Stepper). + * The TMC2208Stepper library is required for this stepper driver. + * https://github.com/teemuatlut/TMC2208Stepper */ -//#define HAVE_TMC2208 -#if ENABLED(HAVE_TMC2208) // Choose your axes here. This is mandatory! - //#define X_IS_TMC2208 - //#define X2_IS_TMC2208 - //#define Y_IS_TMC2208 - //#define Y2_IS_TMC2208 - //#define Z_IS_TMC2208 - //#define Z2_IS_TMC2208 - //#define E0_IS_TMC2208 - //#define E1_IS_TMC2208 - //#define E2_IS_TMC2208 - //#define E3_IS_TMC2208 - //#define E4_IS_TMC2208 -#endif - -#if ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208) +#if HAS_TRINAMIC #define R_SENSE 0.11 // R_sense resistor for SilentStepStick2130 #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current @@ -1308,25 +1270,12 @@ // @section L6470 /** - * Enable this section if you have L6470 motor drivers. - * You need to import the L6470 library into the Arduino IDE for this. - * (https://github.com/ameyer/Arduino-L6470) + * L6470 Stepper Driver options + * + * The Arduino-L6470 library is required for this stepper driver. + * https://github.com/ameyer/Arduino-L6470 */ - -//#define HAVE_L6470DRIVER -#if ENABLED(HAVE_L6470DRIVER) - - //#define X_IS_L6470 - //#define X2_IS_L6470 - //#define Y_IS_L6470 - //#define Y2_IS_L6470 - //#define Z_IS_L6470 - //#define Z2_IS_L6470 - //#define E0_IS_L6470 - //#define E1_IS_L6470 - //#define E2_IS_L6470 - //#define E3_IS_L6470 - //#define E4_IS_L6470 +#if HAS_DRIVER(L6470) #define X_MICROSTEPS 16 // number of microsteps #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off @@ -1372,7 +1321,7 @@ #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 -#endif +#endif // L6470 /** * TWI/I2C BUS diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h new file mode 100644 index 000000000..06610880e --- /dev/null +++ b/Marlin/src/core/drivers.h @@ -0,0 +1,57 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define A4988 0x001 +#define DRV8825 0x002 +#define LV8729 0x003 +#define L6470 0x104 +#define TB6560 0x005 +#define TB6600 0x006 +#define TMC2100 0x007 +#define TMC2130 0x108 +#define TMC2130_STANDALONE 0x008 +#define TMC2208 0x109 +#define TMC2208_STANDALONE 0x009 +#define TMC26X 0x10A +#define TMC26X_STANDALONE 0x00A +#define TMC2660 0x10B +#define TMC2660_STANDALONE 0x00B + +#define AXIS_DRIVER_TYPE(A, T) ( defined(A##_DRIVER_TYPE) && (A##_DRIVER_TYPE == T) ) + +#define HAS_DRIVER(T) (AXIS_DRIVER_TYPE( X,T) || AXIS_DRIVER_TYPE(X2,T) || \ + AXIS_DRIVER_TYPE( Y,T) || AXIS_DRIVER_TYPE(Y2,T) || \ + AXIS_DRIVER_TYPE( Z,T) || AXIS_DRIVER_TYPE(Z2,T) || \ + AXIS_DRIVER_TYPE(E0,T) || \ + AXIS_DRIVER_TYPE(E1,T) || \ + AXIS_DRIVER_TYPE(E2,T) || \ + AXIS_DRIVER_TYPE(E3,T) || \ + AXIS_DRIVER_TYPE(E4,T) ) + +// Test for supported TMC drivers that require advanced configuration +// Does not match standalone configurations +#define HAS_TRINAMIC ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2660) ) + +#define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A, TMC2130) || \ + AXIS_DRIVER_TYPE(A, TMC2208) || \ + AXIS_DRIVER_TYPE(A, TMC2660) ) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 224170bff..fc551b8e1 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -20,8 +20,8 @@ * */ -#ifndef MACROS_H -#define MACROS_H +#ifndef _CORE_MACROS_H_ +#define _CORE_MACROS_H_ #define NUM_AXIS 4 #define ABCE 4 @@ -270,4 +270,4 @@ #define FMOD(x, y) fmodf(x, y) #define HYPOT(x,y) SQRT(HYPOT2(x,y)) -#endif //__MACROS_H +#endif // _CORE_MACROS_H_ diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index a5dc42859..c7d6cacb1 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -52,7 +52,7 @@ bool report_tmc_status = false; bool is_ot; bool is_error; }; - #if ENABLED(HAVE_TMC2130) + #if HAS_DRIVER(TMC2130) static uint32_t get_pwm_scale(TMC2130Stepper &st) { return st.PWM_SCALE(); } static uint8_t get_status_response(TMC2130Stepper &st) { return st.status_response & 0xF; } static TMC_driver_data get_driver_data(TMC2130Stepper &st) { @@ -70,7 +70,7 @@ bool report_tmc_status = false; return data; } #endif - #if ENABLED(HAVE_TMC2208) + #if HAS_DRIVER(TMC2208) static uint32_t get_pwm_scale(TMC2208Stepper &st) { return st.pwm_scale_sum(); } static uint8_t get_status_response(TMC2208Stepper &st) { uint32_t drv_status = st.DRV_STATUS(); @@ -159,21 +159,21 @@ bool report_tmc_status = false; } } - #define HAS_HW_COMMS(ST) ENABLED(ST##_IS_TMC2130)|| (ENABLED(ST##_IS_TMC2208) && defined(ST##_HARDWARE_SERIAL)) + #define HAS_HW_COMMS(ST) AXIS_DRIVER_TYPE(ST, TMC2130) || (AXIS_DRIVER_TYPE(ST, TMC2208) && defined(ST##_HARDWARE_SERIAL)) void monitor_tmc_driver() { static millis_t next_cOT = 0; if (ELAPSED(millis(), next_cOT)) { next_cOT = millis() + 500; - #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS) + #if HAS_HW_COMMS(X) static uint8_t x_otpw_cnt = 0; monitor_tmc_driver(stepperX, TMC_X, x_otpw_cnt); #endif - #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS) + #if HAS_HW_COMMS(Y) static uint8_t y_otpw_cnt = 0; monitor_tmc_driver(stepperY, TMC_Y, y_otpw_cnt); #endif - #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS) + #if HAS_HW_COMMS(Z) static uint8_t z_otpw_cnt = 0; monitor_tmc_driver(stepperZ, TMC_Z, z_otpw_cnt); #endif @@ -189,7 +189,7 @@ bool report_tmc_status = false; static uint8_t z2_otpw_cnt = 0; monitor_tmc_driver(stepperZ2, TMC_Z, z2_otpw_cnt); #endif - #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS) + #if HAS_HW_COMMS(E0) static uint8_t e0_otpw_cnt = 0; monitor_tmc_driver(stepperE0, TMC_E0, e0_otpw_cnt); #endif @@ -311,7 +311,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { SERIAL_EOL(); } - #if ENABLED(HAVE_TMC2130) + #if HAS_DRIVER(TMC2130) static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { switch (i) { case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; @@ -331,7 +331,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { } #endif - #if ENABLED(HAVE_TMC2208) + #if HAS_DRIVER(TMC2208) static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) { switch (i) { case TMC_TSTEP: { uint32_t data = 0; st.TSTEP(&data); SERIAL_PROTOCOL(data); break; } @@ -420,52 +420,52 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { } static void tmc_debug_loop(const TMC_debug_enum i) { - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) tmc_status(stepperX, TMC_X, i, planner.axis_steps_per_mm[X_AXIS]); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) tmc_status(stepperX2, TMC_X2, i, planner.axis_steps_per_mm[X_AXIS]); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) tmc_status(stepperY, TMC_Y, i, planner.axis_steps_per_mm[Y_AXIS]); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) tmc_status(stepperY2, TMC_Y2, i, planner.axis_steps_per_mm[Y_AXIS]); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) tmc_status(stepperZ, TMC_Z, i, planner.axis_steps_per_mm[Z_AXIS]); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) tmc_status(stepperZ2, TMC_Z2, i, planner.axis_steps_per_mm[Z_AXIS]); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) tmc_status(stepperE0, TMC_E0, i, planner.axis_steps_per_mm[E_AXIS]); #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) tmc_status(stepperE1, TMC_E1, i, planner.axis_steps_per_mm[E_AXIS #if ENABLED(DISTINCT_E_FACTORS) + 1 #endif ]); #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) tmc_status(stepperE2, TMC_E2, i, planner.axis_steps_per_mm[E_AXIS #if ENABLED(DISTINCT_E_FACTORS) + 2 #endif ]); #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) tmc_status(stepperE3, TMC_E3, i, planner.axis_steps_per_mm[E_AXIS #if ENABLED(DISTINCT_E_FACTORS) + 3 #endif ]); #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) tmc_status(stepperE4, TMC_E4, i, planner.axis_steps_per_mm[E_AXIS #if ENABLED(DISTINCT_E_FACTORS) + 4 @@ -477,40 +477,40 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { } static void drv_status_loop(const TMC_drv_status_enum i) { - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) tmc_parse_drv_status(stepperX, TMC_X, i); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) tmc_parse_drv_status(stepperX2, TMC_X2, i); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) tmc_parse_drv_status(stepperY, TMC_Y, i); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) tmc_parse_drv_status(stepperY2, TMC_Y2, i); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) tmc_parse_drv_status(stepperZ, TMC_Z, i); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) tmc_parse_drv_status(stepperZ2, TMC_Z2, i); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) tmc_parse_drv_status(stepperE0, TMC_E0, i); #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) tmc_parse_drv_status(stepperE1, TMC_E1, i); #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) tmc_parse_drv_status(stepperE2, TMC_E2, i); #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) tmc_parse_drv_status(stepperE3, TMC_E3, i); #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) tmc_parse_drv_status(stepperE4, TMC_E4, i); #endif @@ -553,7 +553,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { TMC_REPORT("Stallguard thrs", TMC_SGT); DRV_REPORT("DRVSTATUS", TMC_DRV_CODES); - #if ENABLED(HAVE_TMC2130) + #if HAS_DRIVER(TMC2130) DRV_REPORT("stallguard\t", TMC_STALLGUARD); DRV_REPORT("sg_result\t", TMC_SG_RESULT); DRV_REPORT("fsactive\t", TMC_FSACTIVE); @@ -565,7 +565,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { DRV_REPORT("s2ga\t", TMC_S2GA); DRV_REPORT("otpw\t", TMC_DRV_OTPW); DRV_REPORT("ot\t", TMC_OT); - #if ENABLED(HAVE_TMC2208) + #if HAS_DRIVER(TMC2208) DRV_REPORT("157C\t", TMC_T157); DRV_REPORT("150C\t", TMC_T150); DRV_REPORT("143C\t", TMC_T143); @@ -591,43 +591,43 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { #endif // SENSORLESS_HOMING -#if ENABLED(HAVE_TMC2130) +#if HAS_DRIVER(TMC2130) #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) void tmc_init_cs_pins() { - #if ENABLED(X_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X, TMC2130) SET_CS_PIN(X); #endif - #if ENABLED(Y_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y, TMC2130) SET_CS_PIN(Y); #endif - #if ENABLED(Z_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z, TMC2130) SET_CS_PIN(Z); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X2, TMC2130) SET_CS_PIN(X2); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y2, TMC2130) SET_CS_PIN(Y2); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z2, TMC2130) SET_CS_PIN(Z2); #endif - #if ENABLED(E0_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E0, TMC2130) SET_CS_PIN(E0); #endif - #if ENABLED(E1_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E1, TMC2130) SET_CS_PIN(E1); #endif - #if ENABLED(E2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E2, TMC2130) SET_CS_PIN(E2); #endif - #if ENABLED(E3_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E3, TMC2130) SET_CS_PIN(E3); #endif - #if ENABLED(E4_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E4, TMC2130) SET_CS_PIN(E4); #endif } -#endif // HAVE_TMC2130 +#endif // TMC2130 #endif // HAS_TRINAMIC diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 094b65e9b..6f11955ac 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -25,11 +25,11 @@ #include "../inc/MarlinConfigPre.h" -#if ENABLED(HAVE_TMC2130) +#if HAS_DRIVER(TMC2130) #include #endif -#if ENABLED(HAVE_TMC2208) +#if HAS_DRIVER(TMC2208) #include #endif @@ -100,7 +100,7 @@ void monitor_tmc_driver(); void tmc_sensorless_homing(TMC2130Stepper &st, const bool enable=true); #endif -#if ENABLED(HAVE_TMC2130) +#if HAS_DRIVER(TMC2130) void tmc_init_cs_pins(); #endif diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index 36545a2c2..22d9a3f90 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -42,45 +42,45 @@ void GcodeSuite::M906() { report = false; switch (i) { case X_AXIS: - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) if (index == 0) TMC_SET_CURRENT(X); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) if (index == 1) TMC_SET_CURRENT(X2); #endif break; case Y_AXIS: - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) if (index == 0) TMC_SET_CURRENT(Y); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) if (index == 1) TMC_SET_CURRENT(Y2); #endif break; case Z_AXIS: - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) if (index == 0) TMC_SET_CURRENT(Z); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) if (index == 1) TMC_SET_CURRENT(Z2); #endif break; case E_AXIS: { if (get_target_extruder_from_command()) return; switch (target_extruder) { - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) case 0: TMC_SET_CURRENT(E0); break; #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) case 1: TMC_SET_CURRENT(E1); break; #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) case 2: TMC_SET_CURRENT(E2); break; #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) case 3: TMC_SET_CURRENT(E3); break; #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) case 4: TMC_SET_CURRENT(E4); break; #endif } @@ -89,37 +89,37 @@ void GcodeSuite::M906() { } if (report) { - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) TMC_SAY_CURRENT(X); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) TMC_SAY_CURRENT(X2); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) TMC_SAY_CURRENT(Y); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) TMC_SAY_CURRENT(Y2); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) TMC_SAY_CURRENT(Z); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) TMC_SAY_CURRENT(Z2); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) TMC_SAY_CURRENT(E0); #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) TMC_SAY_CURRENT(E1); #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) TMC_SAY_CURRENT(E2); #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) TMC_SAY_CURRENT(E3); #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) TMC_SAY_CURRENT(E4); #endif } diff --git a/Marlin/src/gcode/feature/trinamic/M911-M915.cpp b/Marlin/src/gcode/feature/trinamic/M911-M915.cpp index d7b971c97..6ba9ee5e9 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M915.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M915.cpp @@ -30,37 +30,33 @@ #include "../../../module/planner.h" #include "../../queue.h" -#define M91x_USE(A) (ENABLED(A##_IS_TMC2130) || (ENABLED(A##_IS_TMC2208) && PIN_EXISTS(A##_SERIAL_RX))) +#define M91x_USE(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || (AXIS_DRIVER_TYPE(ST, TMC2208) && PIN_EXISTS(ST##_SERIAL_RX))) #define M91x_USE_E(N) (E_STEPPERS > N && M91x_USE(E##N)) -#define M91x_USE_X (ENABLED(IS_TRAMS) || M91x_USE(X)) -#define M91x_USE_Y (ENABLED(IS_TRAMS) || M91x_USE(Y)) -#define M91x_USE_Z (ENABLED(IS_TRAMS) || M91x_USE(Z)) -#define M91x_USE_E0 (ENABLED(IS_TRAMS) || M91x_USE_E(0)) /** * M911: Report TMC stepper driver overtemperature pre-warn flag * This flag is held by the library, persisting until cleared by M912 */ void GcodeSuite::M911() { - #if M91x_USE_X + #if M91x_USE(X) tmc_report_otpw(stepperX, TMC_X); #endif #if M91x_USE(X2) tmc_report_otpw(stepperX2, TMC_X2); #endif - #if M91x_USE_Y + #if M91x_USE(Y) tmc_report_otpw(stepperY, TMC_Y); #endif #if M91x_USE(Y2) tmc_report_otpw(stepperY2, TMC_Y2); #endif - #if M91x_USE_Z + #if M91x_USE(Z) tmc_report_otpw(stepperZ, TMC_Z); #endif #if M91x_USE(Z2) tmc_report_otpw(stepperZ2, TMC_Z2); #endif - #if M91x_USE_E0 + #if M91x_USE_E(0) tmc_report_otpw(stepperE0, TMC_E0); #endif #if M91x_USE_E(1) @@ -96,9 +92,9 @@ void GcodeSuite::M912() { hasE = parser.seen(axis_codes[E_AXIS]), hasNone = !hasX && !hasY && !hasZ && !hasE; - #if M91x_USE_X || M91x_USE(X2) + #if M91x_USE(X) || M91x_USE(X2) const uint8_t xval = parser.byteval(axis_codes[X_AXIS], 10); - #if M91x_USE_X + #if M91x_USE(X) if (hasNone || xval == 1 || (hasX && xval == 10)) tmc_clear_otpw(stepperX, TMC_X); #endif #if M91x_USE(X2) @@ -106,9 +102,9 @@ void GcodeSuite::M912() { #endif #endif - #if M91x_USE_Y || M91x_USE(Y2) + #if M91x_USE(Y) || M91x_USE(Y2) const uint8_t yval = parser.byteval(axis_codes[Y_AXIS], 10); - #if M91x_USE_Y + #if M91x_USE(Y) if (hasNone || yval == 1 || (hasY && yval == 10)) tmc_clear_otpw(stepperY, TMC_Y); #endif #if M91x_USE(Y2) @@ -116,9 +112,9 @@ void GcodeSuite::M912() { #endif #endif - #if M91x_USE_Z || M91x_USE(Z2) + #if M91x_USE(Z) || M91x_USE(Z2) const uint8_t zval = parser.byteval(axis_codes[Z_AXIS], 10); - #if M91x_USE_Z + #if M91x_USE(Z) if (hasNone || zval == 1 || (hasZ && zval == 10)) tmc_clear_otpw(stepperZ, TMC_Z); #endif #if M91x_USE(Z2) @@ -126,9 +122,9 @@ void GcodeSuite::M912() { #endif #endif - #if M91x_USE_E0 || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) + #if M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) const uint8_t eval = parser.byteval(axis_codes[E_AXIS], 10); - #if M91x_USE_E0 + #if M91x_USE_E(0) if (hasNone || eval == 0 || (hasE && eval == 10)) tmc_clear_otpw(stepperE0, TMC_E0); #endif #if M91x_USE_E(1) @@ -162,45 +158,45 @@ void GcodeSuite::M912() { report = false; switch (i) { case X_AXIS: - #if X_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X) if (index < 2) TMC_SET_PWMTHRS(X,X); #endif - #if X2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X2) if (!(index & 1)) TMC_SET_PWMTHRS(X,X2); #endif break; case Y_AXIS: - #if Y_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y) if (index < 2) TMC_SET_PWMTHRS(Y,Y); #endif - #if Y2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y2) if (!(index & 1)) TMC_SET_PWMTHRS(Y,Y2); #endif break; case Z_AXIS: - #if Z_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z) if (index < 2) TMC_SET_PWMTHRS(Z,Z); #endif - #if Z2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z2) if (!(index & 1)) TMC_SET_PWMTHRS(Z,Z2); #endif break; case E_AXIS: { if (get_target_extruder_from_command()) return; switch (target_extruder) { - #if E0_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E0) case 0: TMC_SET_PWMTHRS_E(0); break; #endif - #if E_STEPPERS > 1 && E1_IS_TRINAMIC + #if E_STEPPERS > 1 && AXIS_HAS_STEALTHCHOP(E1) case 1: TMC_SET_PWMTHRS_E(1); break; #endif - #if E_STEPPERS > 2 && E2_IS_TRINAMIC + #if E_STEPPERS > 2 && AXIS_HAS_STEALTHCHOP(E2) case 2: TMC_SET_PWMTHRS_E(2); break; #endif - #if E_STEPPERS > 3 && E3_IS_TRINAMIC + #if E_STEPPERS > 3 && AXIS_HAS_STEALTHCHOP(E3) case 3: TMC_SET_PWMTHRS_E(3); break; #endif - #if E_STEPPERS > 4 && E4_IS_TRINAMIC + #if E_STEPPERS > 4 && AXIS_HAS_STEALTHCHOP(E4) case 4: TMC_SET_PWMTHRS_E(4); break; #endif } @@ -209,37 +205,37 @@ void GcodeSuite::M912() { } if (report) { - #if X_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X) TMC_SAY_PWMTHRS(X,X); #endif - #if X2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X2) TMC_SAY_PWMTHRS(X,X2); #endif - #if Y_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y) TMC_SAY_PWMTHRS(Y,Y); #endif - #if Y2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y2) TMC_SAY_PWMTHRS(Y,Y2); #endif - #if Z_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z) TMC_SAY_PWMTHRS(Z,Z); #endif - #if Z2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z2) TMC_SAY_PWMTHRS(Z,Z2); #endif - #if E0_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E0) TMC_SAY_PWMTHRS_E(0); #endif - #if E_STEPPERS > 1 && E1_IS_TRINAMIC + #if E_STEPPERS > 1 && AXIS_HAS_STEALTHCHOP(E1) TMC_SAY_PWMTHRS_E(1); #endif - #if E_STEPPERS > 2 && E2_IS_TRINAMIC + #if E_STEPPERS > 2 && AXIS_HAS_STEALTHCHOP(E2) TMC_SAY_PWMTHRS_E(2); #endif - #if E_STEPPERS > 3 && E3_IS_TRINAMIC + #if E_STEPPERS > 3 && AXIS_HAS_STEALTHCHOP(E3) TMC_SAY_PWMTHRS_E(3); #endif - #if E_STEPPERS > 4 && E4_IS_TRINAMIC + #if E_STEPPERS > 4 && AXIS_HAS_STEALTHCHOP(E4) TMC_SAY_PWMTHRS_E(4); #endif } @@ -262,30 +258,30 @@ void GcodeSuite::M912() { switch (i) { #if X_SENSORLESS case X_AXIS: - #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(X) if (index < 2) TMC_SET_SGT(X); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(X2) if (!(index & 1)) TMC_SET_SGT(X2); #endif break; #endif #if Y_SENSORLESS case Y_AXIS: - #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(Y) if (index < 2) TMC_SET_SGT(Y); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(Y2) if (!(index & 1)) TMC_SET_SGT(Y2); #endif break; #endif #if Z_SENSORLESS case Z_AXIS: - #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(Z) if (index < 2) TMC_SET_SGT(Z); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(Z2) if (!(index & 1)) TMC_SET_SGT(Z2); #endif break; @@ -295,26 +291,26 @@ void GcodeSuite::M912() { if (report) { #if X_SENSORLESS - #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(X) TMC_SAY_SGT(X); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(X2) TMC_SAY_SGT(X2); #endif #endif #if Y_SENSORLESS - #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(Y) TMC_SAY_SGT(Y); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(Y2) TMC_SAY_SGT(Y2); #endif #endif #if Z_SENSORLESS - #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(Z) TMC_SAY_SGT(Z); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(Z2) TMC_SAY_SGT(Z2); #endif #endif @@ -335,11 +331,11 @@ void GcodeSuite::M912() { return; } - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) const uint16_t Z_current_1 = stepperZ.getCurrent(); stepperZ.setCurrent(_rms, R_SENSE, HOLD_MULTIPLIER); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) const uint16_t Z2_current_1 = stepperZ2.getCurrent(); stepperZ2.setCurrent(_rms, R_SENSE, HOLD_MULTIPLIER); #endif @@ -350,10 +346,10 @@ void GcodeSuite::M912() { do_blocking_move_to_z(Z_MAX_POS+_z); - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) stepperZ.setCurrent(Z_current_1, R_SENSE, HOLD_MULTIPLIER); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) stepperZ2.setCurrent(Z2_current_1, R_SENSE, HOLD_MULTIPLIER); #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6f847337f..2130b1636 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -132,7 +132,7 @@ * M119 - Report endstops status. * M120 - Enable endstops detection. * M121 - Disable endstops detection. - * M122 - Debug stepper (Requires HAVE_TMC2130 or HAVE_TMC2208) + * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * M126 - Solenoid Air Valve Open. (Requires BARICUDA) * M127 - Solenoid Air Valve Closed. (Requires BARICUDA) @@ -219,13 +219,13 @@ * M868 - Report or set position encoder module error correction threshold. * M869 - Report position encoder module error. * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) - * M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires HAVE_TMC2130 or HAVE_TMC2208) + * M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M908 - Control digital trimpot directly. (Requires DAC_STEPPER_CURRENT or DIGIPOTSS_PIN) * M909 - Print digipot/DAC current value. (Requires DAC_STEPPER_CURRENT) * M910 - Commit digipot/DAC value to external EEPROM via I2C. (Requires DAC_STEPPER_CURRENT) - * M911 - Report stepper driver overtemperature pre-warn condition. (Requires HAVE_TMC2130 or HAVE_TMC2208) - * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires HAVE_TMC2130 or HAVE_TMC2208) + * M911 - Report stepper driver overtemperature pre-warn condition. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660) + * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) * M914 - Set SENSORLESS_HOMING sensitivity. (Requires SENSORLESS_HOMING) * diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 24d4015f6..03214b3c1 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -426,6 +426,63 @@ #define ARRAY_BY_HOTENDS(...) ARRAY_N(HOTENDS, __VA_ARGS__) #define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1, v1, v1) +/** + * Driver Timings + * NOTE: Driver timing order is longest-to-shortest duration. + * Preserve this ordering when adding new drivers. + */ +#ifndef MINIMUM_STEPPER_DIR_DELAY + #if HAS_DRIVER(TB6560) + #define MINIMUM_STEPPER_DIR_DELAY 15000 + #elif HAS_DRIVER(TB6600) + #define MINIMUM_STEPPER_DIR_DELAY 1500 + #elif HAS_DRIVER(DRV8825) + #define MINIMUM_STEPPER_DIR_DELAY 650 + #elif HAS_DRIVER(LV8729) + #define MINIMUM_STEPPER_DIR_DELAY 500 + #elif HAS_DRIVER(A4988) + #define MINIMUM_STEPPER_DIR_DELAY 200 + #elif HAS_TRINAMIC || HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC26X_STANDALONE) || HAS_DRIVER(TMC2660_STANDALONE) + #define MINIMUM_STEPPER_DIR_DELAY 20 + #else + #define MINIMUM_STEPPER_DIR_DELAY 0 // Expect at least 10µS since one Stepper ISR must transpire + #endif +#endif + +#ifndef MINIMUM_STEPPER_PULSE + #if HAS_DRIVER(TB6560) + #define MINIMUM_STEPPER_PULSE 30 + #elif HAS_DRIVER(TB6600) + #define MINIMUM_STEPPER_PULSE 3 + #elif HAS_DRIVER(DRV8825) + #define MINIMUM_STEPPER_PULSE 2 + #elif HAS_DRIVER(A4988) || HAS_DRIVER(LV8729) + #define MINIMUM_STEPPER_PULSE 1 + #elif HAS_TRINAMIC || HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC26X_STANDALONE) || HAS_DRIVER(TMC2660_STANDALONE) + #define MINIMUM_STEPPER_PULSE 0 + #else + #define MINIMUM_STEPPER_PULSE 2 + #endif +#endif + +#ifndef MAXIMUM_STEPPER_RATE + #if HAS_DRIVER(TB6560) + #define MAXIMUM_STEPPER_RATE 15000 + #elif HAS_DRIVER(LV8729) + #define MAXIMUM_STEPPER_RATE 130000 + #elif HAS_DRIVER(TB6600) + #define MAXIMUM_STEPPER_RATE 150000 + #elif HAS_DRIVER(DRV8825) + #define MAXIMUM_STEPPER_RATE 250000 + #elif HAS_TRINAMIC || HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC26X_STANDALONE) || HAS_DRIVER(TMC2660_STANDALONE) + #define MAXIMUM_STEPPER_RATE 400000 + #elif HAS_DRIVER(A4988) + #define MAXIMUM_STEPPER_RATE 500000 + #else + #define MAXIMUM_STEPPER_RATE 250000 + #endif +#endif + /** * X_DUAL_ENDSTOPS endstop reassignment */ @@ -711,27 +768,19 @@ #define HAS_SOLENOID_4 (PIN_EXISTS(SOL4)) // Trinamic Stepper Drivers -#define HAS_TRINAMIC (ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208) || ENABLED(IS_TRAMS)) -#define X_IS_TRINAMIC (ENABLED( X_IS_TMC2130) || ENABLED( X_IS_TMC2208) || ENABLED(IS_TRAMS)) -#define X2_IS_TRINAMIC (ENABLED(X2_IS_TMC2130) || ENABLED(X2_IS_TMC2208)) -#define Y_IS_TRINAMIC (ENABLED( Y_IS_TMC2130) || ENABLED( Y_IS_TMC2208) || ENABLED(IS_TRAMS)) -#define Y2_IS_TRINAMIC (ENABLED(Y2_IS_TMC2130) || ENABLED(Y2_IS_TMC2208)) -#define Z_IS_TRINAMIC (ENABLED( Z_IS_TMC2130) || ENABLED( Z_IS_TMC2208) || ENABLED(IS_TRAMS)) -#define Z2_IS_TRINAMIC (ENABLED(Z2_IS_TMC2130) || ENABLED(Z2_IS_TMC2208)) -#define E0_IS_TRINAMIC (ENABLED(E0_IS_TMC2130) || ENABLED(E0_IS_TMC2208) || ENABLED(IS_TRAMS)) -#define E1_IS_TRINAMIC (ENABLED(E1_IS_TMC2130) || ENABLED(E1_IS_TMC2208)) -#define E2_IS_TRINAMIC (ENABLED(E2_IS_TMC2130) || ENABLED(E2_IS_TMC2208)) -#define E3_IS_TRINAMIC (ENABLED(E3_IS_TMC2130) || ENABLED(E3_IS_TMC2208)) -#define E4_IS_TRINAMIC (ENABLED(E4_IS_TMC2130) || ENABLED(E4_IS_TMC2208)) +#define HAS_STEALTHCHOP (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2208)) +#define HAS_STALLGUARD (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2660)) +#define AXIS_HAS_STEALTHCHOP(ST) ( AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2208) ) +#define AXIS_HAS_STALLGUARD(ST) ( AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2660) ) #if ENABLED(SENSORLESS_HOMING) // Disable Z axis sensorless homing if a probe is used to home the Z axis #if HOMING_Z_WITH_PROBE #undef Z_HOMING_SENSITIVITY #endif - #define X_SENSORLESS (ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY)) - #define Y_SENSORLESS (ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY)) - #define Z_SENSORLESS (ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY)) + #define X_SENSORLESS (AXIS_HAS_STALLGUARD(X) && defined(X_HOMING_SENSITIVITY)) + #define Y_SENSORLESS (AXIS_HAS_STALLGUARD(Y) && defined(Y_HOMING_SENSITIVITY)) + #define Z_SENSORLESS (AXIS_HAS_STALLGUARD(Z) && defined(Z_HOMING_SENSITIVITY)) #endif // Endstops and bed probe diff --git a/Marlin/src/inc/MarlinConfigPre.h b/Marlin/src/inc/MarlinConfigPre.h index 9ed1ee8ff..c29de37c9 100644 --- a/Marlin/src/inc/MarlinConfigPre.h +++ b/Marlin/src/inc/MarlinConfigPre.h @@ -29,6 +29,7 @@ #include "../core/types.h" #include "Version.h" #include "../../Configuration.h" +#include "../core/drivers.h" #include "Conditionals_LCD.h" #include "../../Configuration_adv.h" #include "Conditionals_adv.h" diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f40dc239f..c6cf4bb4e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -265,10 +265,28 @@ #elif defined(MEASURED_LOWER_LIMIT) || defined(MEASURED_UPPER_LIMIT) #error "MEASURED_(UPPER|LOWER)_LIMIT is now FILWIDTH_ERROR_MARGIN. Please update your configuration." #elif defined(HAVE_TMCDRIVER) - #error "HAVE_TMCDRIVER is now HAVE_TMC26X. Please update your Configuration_adv.h." + #error "HAVE_TMCDRIVER is now [AXIS]_DRIVER_TYPE TMC26X. Please update your Configuration.h." +#elif defined(HAVE_TMC26X) + #error "HAVE_TMC26X is now [AXIS]_DRIVER_TYPE TMC26X. Please update your Configuration.h." +#elif defined(HAVE_TMC2130) + #error "HAVE_TMC2130 is now [AXIS]_DRIVER_TYPE TMC2130. Please update your Configuration.h." +#elif defined(HAVE_L6470DRIVER) + #error "HAVE_L6470DRIVER is now [AXIS]_DRIVER_TYPE L6470. Please update your Configuration.h." #elif defined(X_IS_TMC) || defined(X2_IS_TMC) || defined(Y_IS_TMC) || defined(Y2_IS_TMC) || defined(Z_IS_TMC) || defined(Z2_IS_TMC) \ || defined(E0_IS_TMC) || defined(E1_IS_TMC) || defined(E2_IS_TMC) || defined(E3_IS_TMC) || defined(E4_IS_TMC) - #error "[AXIS]_IS_TMC is now [AXIS]_IS_TMC26X. Please update your Configuration_adv.h." + #error "[AXIS]_IS_TMC is now [AXIS]_DRIVER_TYPE TMC26X. Please update your Configuration.h." +#elif defined(X_IS_TMC26X) || defined(X2_IS_TMC26X) || defined(Y_IS_TMC26X) || defined(Y2_IS_TMC26X) || defined(Z_IS_TMC26X) || defined(Z2_IS_TMC26X) \ + || defined(E0_IS_TMC26X) || defined(E1_IS_TMC26X) || defined(E2_IS_TMC26X) || defined(E3_IS_TMC26X) || defined(E4_IS_TMC26X) + #error "[AXIS]_IS_TMC26X is now [AXIS]_DRIVER_TYPE TMC26X. Please update your Configuration.h." +#elif defined(X_IS_TMC2130) || defined(X2_IS_TMC2130) || defined(Y_IS_TMC2130) || defined(Y2_IS_TMC2130) || defined(Z_IS_TMC2130) || defined(Z2_IS_TMC2130) \ + || defined(E0_IS_TMC2130) || defined(E1_IS_TMC2130) || defined(E2_IS_TMC2130) || defined(E3_IS_TMC2130) || defined(E4_IS_TMC2130) + #error "[AXIS]_IS_TMC2130 is now [AXIS]_DRIVER_TYPE TMC2130. Please update your Configuration.h." +#elif defined(X_IS_TMC2208) || defined(X2_IS_TMC2208) || defined(Y_IS_TMC2208) || defined(Y2_IS_TMC2208) || defined(Z_IS_TMC2208) || defined(Z2_IS_TMC2208) \ + || defined(E0_IS_TMC2208) || defined(E1_IS_TMC2208) || defined(E2_IS_TMC2208) || defined(E3_IS_TMC2208) || defined(E4_IS_TMC2208) + #error "[AXIS]_IS_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208. Please update your Configuration.h." +#elif defined(X_IS_L6470) || defined(X2_IS_L6470) || defined(Y_IS_L6470) || defined(Y2_IS_L6470) || defined(Z_IS_L6470) || defined(Z2_IS_L6470) \ + || defined(E0_IS_L6470) || defined(E1_IS_L6470) || defined(E2_IS_L6470) || defined(E3_IS_L6470) || defined(E4_IS_L6470) + #error "[AXIS]_IS_L6470 is now [AXIS]_DRIVER_TYPE L6470. Please update your Configuration.h." #elif defined(AUTOMATIC_CURRENT_CONTROL) #error "AUTOMATIC_CURRENT_CONTROL is now MONITOR_DRIVER_STATUS. Please update your configuration." #elif defined(FILAMENT_CHANGE_LOAD_LENGTH) @@ -974,15 +992,11 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE, */ #if ENABLED(Z_SAFE_HOMING) #if HAS_BED_PROBE - static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, MIN_PROBE_X, MAX_PROBE_X), - "Z_SAFE_HOMING_X_POINT is outside the probe region."); - static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, MIN_PROBE_Y, MAX_PROBE_Y), - "Z_SAFE_HOMING_Y_POINT is outside the probe region."); + static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, MIN_PROBE_X, MAX_PROBE_X), "Z_SAFE_HOMING_X_POINT is outside the probe region."); + static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, MIN_PROBE_Y, MAX_PROBE_Y), "Z_SAFE_HOMING_Y_POINT is outside the probe region."); #else - static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, X_MIN_POS, X_MAX_POS), - "Z_SAFE_HOMING_X_POINT can't be reached by the nozzle."); - static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, Y_MIN_POS, Y_MAX_POS), - "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle."); + static_assert(WITHIN(Z_SAFE_HOMING_X_POINT, X_MIN_POS, X_MAX_POS), "Z_SAFE_HOMING_X_POINT can't be reached by the nozzle."); + static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, Y_MIN_POS, Y_MAX_POS), "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle."); #endif #endif // Z_SAFE_HOMING @@ -1458,128 +1472,36 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE, #endif /** - * Make sure HAVE_TMC26X is warranted + * Check existing CS pins against enabled TMC SPI drivers. */ -#if ENABLED(HAVE_TMC26X) && !( \ - ENABLED( X_IS_TMC26X ) \ - || ENABLED( X2_IS_TMC26X ) \ - || ENABLED( Y_IS_TMC26X ) \ - || ENABLED( Y2_IS_TMC26X ) \ - || ENABLED( Z_IS_TMC26X ) \ - || ENABLED( Z2_IS_TMC26X ) \ - || ENABLED( E0_IS_TMC26X ) \ - || ENABLED( E1_IS_TMC26X ) \ - || ENABLED( E2_IS_TMC26X ) \ - || ENABLED( E3_IS_TMC26X ) \ - || ENABLED( E4_IS_TMC26X ) \ - ) - #error "HAVE_TMC26X requires at least one TMC26X stepper to be set." -#endif - -/** - * Make sure HAVE_TMC2130 is warranted - */ -#if ENABLED(HAVE_TMC2130) - #if !( ENABLED( X_IS_TMC2130 ) \ - || ENABLED( X2_IS_TMC2130 ) \ - || ENABLED( Y_IS_TMC2130 ) \ - || ENABLED( Y2_IS_TMC2130 ) \ - || ENABLED( Z_IS_TMC2130 ) \ - || ENABLED( Z2_IS_TMC2130 ) \ - || ENABLED( E0_IS_TMC2130 ) \ - || ENABLED( E1_IS_TMC2130 ) \ - || ENABLED( E2_IS_TMC2130 ) \ - || ENABLED( E3_IS_TMC2130 ) \ - || ENABLED( E4_IS_TMC2130 ) ) - #error "HAVE_TMC2130 requires at least one TMC2130 stepper to be set." - #elif ENABLED(HYBRID_THRESHOLD) && DISABLED(STEALTHCHOP) - #error "Enable STEALTHCHOP to use HYBRID_THRESHOLD." - #endif - - #if ENABLED(X_IS_TMC2130) && !PIN_EXISTS(X_CS) - #error "X_CS_PIN is required for X_IS_TMC2130. Define X_CS_PIN in Configuration_adv.h." - #elif ENABLED(X2_IS_TMC2130) && !PIN_EXISTS(X2_CS) - #error "X2_CS_PIN is required for X2_IS_TMC2130. Define X2_CS_PIN in Configuration_adv.h." - #elif ENABLED(Y_IS_TMC2130) && !PIN_EXISTS(Y_CS) - #error "Y_CS_PIN is required for Y_IS_TMC2130. Define Y_CS_PIN in Configuration_adv.h." - #elif ENABLED(Y2_IS_TMC2130) && !PIN_EXISTS(Y2_CS) - #error "Y2_CS_PIN is required for Y2_IS_TMC2130. Define Y2_CS_PIN in Configuration_adv.h." - #elif ENABLED(Z_IS_TMC2130) && !PIN_EXISTS(Z_CS) - #error "Z_CS_PIN is required for Z_IS_TMC2130. Define Z_CS_PIN in Configuration_adv.h." - #elif ENABLED(Z2_IS_TMC2130) && !PIN_EXISTS(Z2_CS) - #error "Z2_CS_PIN is required for Z2_IS_TMC2130. Define Z2_CS_PIN in Configuration_adv.h." - #elif ENABLED(E0_IS_TMC2130) && !PIN_EXISTS(E0_CS) - #error "E0_CS_PIN is required for E0_IS_TMC2130. Define E0_CS_PIN in Configuration_adv.h." - #elif ENABLED(E1_IS_TMC2130) && !PIN_EXISTS(E1_CS) - #error "E1_CS_PIN is required for E1_IS_TMC2130. Define E1_CS_PIN in Configuration_adv.h." - #elif ENABLED(E2_IS_TMC2130) && !PIN_EXISTS(E2_CS) - #error "E2_CS_PIN is required for E2_IS_TMC2130. Define E2_CS_PIN in Configuration_adv.h." - #elif ENABLED(E3_IS_TMC2130) && !PIN_EXISTS(E3_CS) - #error "E3_CS_PIN is required for E3_IS_TMC2130. Define E3_CS_PIN in Configuration_adv.h." - #elif ENABLED(E4_IS_TMC2130) && !PIN_EXISTS(E4_CS) - #error "E4_CS_PIN is required for E4_IS_TMC2130. Define E4_CS_PIN in Configuration_adv.h." - #endif - - #if ENABLED(SENSORLESS_HOMING) - // Require STEALTHCHOP for SENSORLESS_HOMING on DELTA as the transition from spreadCycle to stealthChop - // is necessary in order to reset the stallGuard indication between the initial movement of all three - // towers to +Z and the individual homing of each tower. This restriction can be removed once a means of - // clearing the stallGuard activated status is found. - #if ENABLED(DELTA) && !ENABLED(STEALTHCHOP) - #error "SENSORLESS_HOMING on DELTA currently requires STEALTHCHOP." - #elif X_SENSORLESS && X_HOME_DIR == -1 && (DISABLED(X_MIN_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_XMIN)) - #error "SENSORLESS_HOMING requires X_MIN_ENDSTOP_INVERTING and ENDSTOPPULLUP_XMIN when homing to X_MIN." - #elif X_SENSORLESS && X_HOME_DIR == 1 && (DISABLED(X_MAX_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_XMAX)) - #error "SENSORLESS_HOMING requires X_MAX_ENDSTOP_INVERTING and ENDSTOPPULLUP_XMAX when homing to X_MAX." - #elif Y_SENSORLESS && Y_HOME_DIR == -1 && (DISABLED(Y_MIN_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_YMIN)) - #error "SENSORLESS_HOMING requires Y_MIN_ENDSTOP_INVERTING and ENDSTOPPULLUP_YMIN when homing to Y_MIN." - #elif Y_SENSORLESS && Y_HOME_DIR == 1 && (DISABLED(Y_MAX_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_YMAX)) - #error "SENSORLESS_HOMING requires Y_MAX_ENDSTOP_INVERTING and ENDSTOPPULLUP_YMAX when homing to Y_MAX." - #elif Z_SENSORLESS && Z_HOME_DIR == -1 && (DISABLED(Z_MIN_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_ZMIN)) - #error "SENSORLESS_HOMING requires Z_MIN_ENDSTOP_INVERTING and ENDSTOPPULLUP_ZMIN when homing to Z_MIN." - #elif Z_SENSORLESS && Z_HOME_DIR == 1 && (DISABLED(Z_MAX_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_ZMAX)) - #error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING and ENDSTOPPULLUP_ZMAX when homing to Z_MAX." - #elif ENABLED(ENDSTOP_NOISE_FILTER) - #error "SENSORLESS_HOMING is incompatible with ENDSTOP_NOISE_FILTER." - #endif - #endif - - // Sensorless homing is required for both combined steppers in an H-bot - #if CORE_IS_XY && X_SENSORLESS != Y_SENSORLESS - #error "CoreXY requires both X and Y to use sensorless homing if either does." - #elif CORE_IS_XZ && X_SENSORLESS != Z_SENSORLESS - #error "CoreXZ requires both X and Z to use sensorless homing if either does." - #elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS - #error "CoreYZ requires both Y and Z to use sensorless homing if either does." - #endif - -#elif ENABLED(SENSORLESS_HOMING) - - #error "SENSORLESS_HOMING requires TMC2130 stepper drivers." - -#endif - -/** - * Make sure HAVE_TMC2208 is warranted - */ -#if ENABLED(HAVE_TMC2208) && !( \ - ENABLED( X_IS_TMC2208 ) \ - || ENABLED( X2_IS_TMC2208 ) \ - || ENABLED( Y_IS_TMC2208 ) \ - || ENABLED( Y2_IS_TMC2208 ) \ - || ENABLED( Z_IS_TMC2208 ) \ - || ENABLED( Z2_IS_TMC2208 ) \ - || ENABLED( E0_IS_TMC2208 ) \ - || ENABLED( E1_IS_TMC2208 ) \ - || ENABLED( E2_IS_TMC2208 ) \ - || ENABLED( E3_IS_TMC2208 ) ) - #error "HAVE_TMC2208 requires at least one TMC2208 stepper to be set." +#if AXIS_DRIVER_TYPE(X, TMC2130) && !PIN_EXISTS(X_CS) + #error "X_CS_PIN is required for TMC2130. Define X_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(X2, TMC2130) && !PIN_EXISTS(X2_CS) + #error "X2_CS_PIN is required for X2. Define X2_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(Y, TMC2130) && !PIN_EXISTS(Y_CS) + #error "Y_CS_PIN is required for TMC2130. Define Y_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(Y2, TMC2130) && !PIN_EXISTS(Y2_CS) + #error "Y2_CS_PIN is required for TMC2130. Define Y2_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(Z, TMC2130) && !PIN_EXISTS(Z_CS) + #error "Z_CS_PIN is required for TMC2130. Define Z_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(Z2, TMC2130) && !PIN_EXISTS(Z2_CS) + #error "Z2_CS_PIN is required for TMC2130. Define Z2_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(E0, TMC2130) && !PIN_EXISTS(E0_CS) + #error "E0_CS_PIN is required for TMC2130. Define E0_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(E1, TMC2130) && !PIN_EXISTS(E1_CS) + #error "E1_CS_PIN is required for TMC2130. Define E1_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(E2, TMC2130) && !PIN_EXISTS(E2_CS) + #error "E2_CS_PIN is required for TMC2130. Define E2_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(E3, TMC2130) && !PIN_EXISTS(E3_CS) + #error "E3_CS_PIN is required for TMC2130. Define E3_CS_PIN in Configuration_adv.h." +#elif AXIS_DRIVER_TYPE(E4, TMC2130) && !PIN_EXISTS(E4_CS) + #error "E4_CS_PIN is required for TMC2130. Define E4_CS_PIN in Configuration_adv.h." #endif /** * TMC2208 software UART and ENDSTOP_INTERRUPTS both use pin change interrupts (PCI) */ -#if ENABLED(HAVE_TMC2208) && ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !( \ +#if HAS_DRIVER(TMC2208) && ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !( \ defined(X_HARDWARE_SERIAL ) \ || defined(X2_HARDWARE_SERIAL) \ || defined(Y_HARDWARE_SERIAL ) \ @@ -1594,113 +1516,52 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE, #error "select hardware UART for TMC2208 to use both TMC2208 and ENDSTOP_INTERRUPTS_FEATURE." #endif -#if ENABLED(HYBRID_THRESHOLD) && DISABLED(STEALTHCHOP) - #error "Enable STEALTHCHOP to use HYBRID_THRESHOLD." -#endif - -#if ENABLED(TMC_Z_CALIBRATION) && !Z_IS_TRINAMIC && !Z2_IS_TRINAMIC - #error "TMC_Z_CALIBRATION requires at least one TMC driver on Z axis" +#if ENABLED(SENSORLESS_HOMING) + // Require STEALTHCHOP for SENSORLESS_HOMING on DELTA as the transition from spreadCycle to stealthChop + // is necessary in order to reset the stallGuard indication between the initial movement of all three + // towers to +Z and the individual homing of each tower. This restriction can be removed once a means of + // clearing the stallGuard activated status is found. + #if ENABLED(DELTA) && !ENABLED(STEALTHCHOP) + #error "SENSORLESS_HOMING on DELTA currently requires STEALTHCHOP." + #elif X_SENSORLESS && X_HOME_DIR == -1 && (DISABLED(X_MIN_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_XMIN)) + #error "SENSORLESS_HOMING requires X_MIN_ENDSTOP_INVERTING and ENDSTOPPULLUP_XMIN when homing to X_MIN." + #elif X_SENSORLESS && X_HOME_DIR == 1 && (DISABLED(X_MAX_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_XMAX)) + #error "SENSORLESS_HOMING requires X_MAX_ENDSTOP_INVERTING and ENDSTOPPULLUP_XMAX when homing to X_MAX." + #elif Y_SENSORLESS && Y_HOME_DIR == -1 && (DISABLED(Y_MIN_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_YMIN)) + #error "SENSORLESS_HOMING requires Y_MIN_ENDSTOP_INVERTING and ENDSTOPPULLUP_YMIN when homing to Y_MIN." + #elif Y_SENSORLESS && Y_HOME_DIR == 1 && (DISABLED(Y_MAX_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_YMAX)) + #error "SENSORLESS_HOMING requires Y_MAX_ENDSTOP_INVERTING and ENDSTOPPULLUP_YMAX when homing to Y_MAX." + #elif Z_SENSORLESS && Z_HOME_DIR == -1 && (DISABLED(Z_MIN_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_ZMIN)) + #error "SENSORLESS_HOMING requires Z_MIN_ENDSTOP_INVERTING and ENDSTOPPULLUP_ZMIN when homing to Z_MIN." + #elif Z_SENSORLESS && Z_HOME_DIR == 1 && (DISABLED(Z_MAX_ENDSTOP_INVERTING) || DISABLED(ENDSTOPPULLUP_ZMAX)) + #error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING and ENDSTOPPULLUP_ZMAX when homing to Z_MAX." + #elif ENABLED(ENDSTOP_NOISE_FILTER) + #error "SENSORLESS_HOMING is incompatible with ENDSTOP_NOISE_FILTER." + #endif #endif -/** - * Make sure HAVE_L6470DRIVER is warranted - */ -#if ENABLED(HAVE_L6470DRIVER) && !( \ - ENABLED( X_IS_L6470 ) \ - || ENABLED( X2_IS_L6470 ) \ - || ENABLED( Y_IS_L6470 ) \ - || ENABLED( Y2_IS_L6470 ) \ - || ENABLED( Z_IS_L6470 ) \ - || ENABLED( Z2_IS_L6470 ) \ - || ENABLED( E0_IS_L6470 ) \ - || ENABLED( E1_IS_L6470 ) \ - || ENABLED( E2_IS_L6470 ) \ - || ENABLED( E3_IS_L6470 ) \ - || ENABLED( E4_IS_L6470 ) \ - ) - #error "HAVE_L6470DRIVER requires at least one L6470 stepper to be set." +// Sensorless homing is required for both combined steppers in an H-bot +#if CORE_IS_XY && X_SENSORLESS != Y_SENSORLESS + #error "CoreXY requires both X and Y to use sensorless homing if either does." +#elif CORE_IS_XZ && X_SENSORLESS != Z_SENSORLESS + #error "CoreXZ requires both X and Z to use sensorless homing if either does." +#elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS + #error "CoreYZ requires both Y and Z to use sensorless homing if either does." #endif -/** - * Check that each axis has only one driver selected - */ -#if 1 < 0 \ - + ENABLED(X_IS_TMC26X) \ - + ENABLED(X_IS_TMC2130) \ - + ENABLED(X_IS_TMC2208) \ - + ENABLED(X_IS_L6470) - #error "Please enable only one stepper driver for the X axis." -#endif -#if 1 < 0 \ - + ENABLED(X2_IS_TMC26X) \ - + ENABLED(X2_IS_TMC2130) \ - + ENABLED(X2_IS_TMC2208) \ - + ENABLED(X2_IS_L6470) - #error "Please enable only one stepper driver for the X2 axis." -#endif -#if 1 < 0 \ - + ENABLED(Y_IS_TMC26X) \ - + ENABLED(Y_IS_TMC2130) \ - + ENABLED(Y_IS_TMC2208) \ - + ENABLED(Y_IS_L6470) - #error "Please enable only one stepper driver for the Y axis." -#endif -#if 1 < 0 \ - + ENABLED(Y2_IS_TMC26X) \ - + ENABLED(Y2_IS_TMC2130) \ - + ENABLED(Y2_IS_TMC2208) \ - + ENABLED(Y2_IS_L6470) - #error "Please enable only one stepper driver for the Y2 axis." -#endif -#if 1 < 0 \ - + ENABLED(Z_IS_TMC26X) \ - + ENABLED(Z_IS_TMC2130) \ - + ENABLED(Z_IS_TMC2208) \ - + ENABLED(Z_IS_L6470) - #error "Please enable only one stepper driver for the Z axis." -#endif -#if 1 < 0 \ - + ENABLED(Z2_IS_TMC26X) \ - + ENABLED(Z2_IS_TMC2130) \ - + ENABLED(Z2_IS_TMC2208) \ - + ENABLED(Z2_IS_L6470) - #error "Please enable only one stepper driver for the Z2 axis." -#endif -#if 1 < 0 \ - + ENABLED(E0_IS_TMC26X) \ - + ENABLED(E0_IS_TMC2130) \ - + ENABLED(E0_IS_TMC2208) \ - + ENABLED(E0_IS_L6470) - #error "Please enable only one stepper driver for the E0 axis." -#endif -#if 1 < 0 \ - + ENABLED(E1_IS_TMC26X) \ - + ENABLED(E1_IS_TMC2130) \ - + ENABLED(E1_IS_TMC2208) \ - + ENABLED(E1_IS_L6470) - #error "Please enable only one stepper driver for the E1 axis." -#endif -#if 1 < 0 \ - + ENABLED(E2_IS_TMC26X) \ - + ENABLED(E2_IS_TMC2130) \ - + ENABLED(E2_IS_TMC2208) \ - + ENABLED(E2_IS_L6470) - #error "Please enable only one stepper driver for the E2 axis." +#if ENABLED(HYBRID_THRESHOLD) && DISABLED(STEALTHCHOP) + #error "Enable STEALTHCHOP to use HYBRID_THRESHOLD." #endif -#if 1 < 0 \ - + ENABLED(E3_IS_TMC26X) \ - + ENABLED(E3_IS_TMC2130) \ - + ENABLED(E3_IS_TMC2208) \ - + ENABLED(E3_IS_L6470) - #error "Please enable only one stepper driver for the E3 axis." +#if ENABLED(TMC_Z_CALIBRATION) && !AXIS_IS_TMC(Z) && !AXIS_IS_TMC(Z2) + #error "TMC_Z_CALIBRATION requires at least one TMC driver on Z axis" #endif -#if 1 < 0 \ - + ENABLED(E4_IS_TMC26X) \ - + ENABLED(E4_IS_TMC2130) \ - + ENABLED(E4_IS_TMC2208) \ - + ENABLED(E4_IS_L6470) - #error "Please enable only one stepper driver for the E4 axis." + +#if ENABLED(SENSORLESS_HOMING) && !HAS_STALLGUARD + #error "SENSORLESS_HOMING requires TMC2130 or TMC2660 stepper drivers." #endif +#if ENABLED(STEALTHCHOP) && !HAS_STEALTHCHOP + #error "STEALTHCHOP requires TMC2130 or TMC2208 stepper drivers." + #endif /** * Digipot requirement diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index f9fdbd380..8af22648b 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -681,57 +681,57 @@ void MarlinSettings::postprocess() { uint16_t tmc_stepper_current[TMC_AXES] = { #if HAS_TRINAMIC - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) stepperX.getCurrent(), #else 0, #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) stepperY.getCurrent(), #else 0, #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) stepperZ.getCurrent(), #else 0, #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) stepperX2.getCurrent(), #else 0, #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) stepperY2.getCurrent(), #else 0, #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) stepperZ2.getCurrent(), #else 0, #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) stepperE0.getCurrent(), #else 0, #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) stepperE1.getCurrent(), #else 0, #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) stepperE2.getCurrent(), #else 0, #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) stepperE3.getCurrent(), #else 0, #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) stepperE4.getCurrent() #else 0 @@ -750,57 +750,57 @@ void MarlinSettings::postprocess() { uint32_t tmc_hybrid_threshold[TMC_AXES] = { #if ENABLED(HYBRID_THRESHOLD) - #if X_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X) TMC_GET_PWMTHRS(X, X), #else X_HYBRID_THRESHOLD, #endif - #if Y_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y) TMC_GET_PWMTHRS(Y, Y), #else Y_HYBRID_THRESHOLD, #endif - #if Z_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z) TMC_GET_PWMTHRS(Z, Z), #else Z_HYBRID_THRESHOLD, #endif - #if X2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X2) TMC_GET_PWMTHRS(X, X2), #else X2_HYBRID_THRESHOLD, #endif - #if Y2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y2) TMC_GET_PWMTHRS(Y, Y2), #else Y2_HYBRID_THRESHOLD, #endif - #if Z2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z2) TMC_GET_PWMTHRS(Z, Z2), #else Z2_HYBRID_THRESHOLD, #endif - #if E0_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E0) TMC_GET_PWMTHRS(E, E0), #else E0_HYBRID_THRESHOLD, #endif - #if E1_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E1) TMC_GET_PWMTHRS(E, E1), #else E1_HYBRID_THRESHOLD, #endif - #if E2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E2) TMC_GET_PWMTHRS(E, E2), #else E2_HYBRID_THRESHOLD, #endif - #if E3_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E3) TMC_GET_PWMTHRS(E, E3), #else E3_HYBRID_THRESHOLD, #endif - #if E4_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E4) TMC_GET_PWMTHRS(E, E4) #else E4_HYBRID_THRESHOLD @@ -818,17 +818,17 @@ void MarlinSettings::postprocess() { // int16_t tmc_sgt[XYZ] = { #if ENABLED(SENSORLESS_HOMING) - #if defined(X_HOMING_SENSITIVITY) && (ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)) + #if X_SENSORLESS stepperX.sgt(), #else 0, #endif - #if defined(Y_HOMING_SENSITIVITY) && (ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)) + #if Y_SENSORLESS stepperY.sgt(), #else 0, #endif - #if defined(Z_HOMING_SENSITIVITY) && (ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)) + #if Z_SENSORLESS stepperZ.sgt() #else 0 @@ -1311,37 +1311,37 @@ void MarlinSettings::postprocess() { uint16_t currents[TMC_AXES]; EEPROM_READ(currents); if (!validating) { - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) SET_CURR(X); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) SET_CURR(Y); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) SET_CURR(Z); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) SET_CURR(X2); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) SET_CURR(Y2); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) SET_CURR(Z2); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) SET_CURR(E0); #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) SET_CURR(E1); #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) SET_CURR(E2); #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) SET_CURR(E3); #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) SET_CURR(E4); #endif } @@ -1355,37 +1355,37 @@ void MarlinSettings::postprocess() { uint32_t tmc_hybrid_threshold[TMC_AXES]; EEPROM_READ(tmc_hybrid_threshold); if (!validating) { - #if X_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X) TMC_SET_PWMTHRS(X, X); #endif - #if Y_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y) TMC_SET_PWMTHRS(Y, Y); #endif - #if Z_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z) TMC_SET_PWMTHRS(Z, Z); #endif - #if X2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(X2) TMC_SET_PWMTHRS(X, X2); #endif - #if Y2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Y2) TMC_SET_PWMTHRS(Y, Y2); #endif - #if Z2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(Z2) TMC_SET_PWMTHRS(Z, Z2); #endif - #if E0_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E0) TMC_SET_PWMTHRS(E, E0); #endif - #if E1_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E1) TMC_SET_PWMTHRS(E, E1); #endif - #if E2_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E2) TMC_SET_PWMTHRS(E, E2); #endif - #if E3_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E3) TMC_SET_PWMTHRS(E, E3); #endif - #if E4_IS_TRINAMIC + #if AXIS_HAS_STEALTHCHOP(E4) TMC_SET_PWMTHRS(E, E4); #endif } @@ -1405,26 +1405,26 @@ void MarlinSettings::postprocess() { #if ENABLED(SENSORLESS_HOMING) if (!validating) { #ifdef X_HOMING_SENSITIVITY - #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(X) stepperX.sgt(tmc_sgt[0]); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(X2) stepperX2.sgt(tmc_sgt[0]); #endif #endif #ifdef Y_HOMING_SENSITIVITY - #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(Y) stepperY.sgt(tmc_sgt[1]); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(Y2) stepperY2.sgt(tmc_sgt[1]); #endif #endif #ifdef Z_HOMING_SENSITIVITY - #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_HAS_STALLGUARD(Z) stepperZ.sgt(tmc_sgt[2]); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_HAS_STALLGUARD(Z2) stepperZ2.sgt(tmc_sgt[2]); #endif #endif @@ -2445,61 +2445,61 @@ void MarlinSettings::reset(PORTARG_SOLO) { #if HAS_TRINAMIC /** - * TMC2130 / TMC2208 / TRAMS stepper driver current + * TMC2130 / TMC2208 stepper driver current */ if (!forReplay) { CONFIG_ECHO_START; SERIAL_ECHOLNPGM_P(port, "Stepper driver current:"); } CONFIG_ECHO_START; - #if X_IS_TRINAMIC || Y_IS_TRINAMIC || Z_IS_TRINAMIC + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) say_M906(PORTVAR_SOLO); #endif - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) SERIAL_ECHOPAIR_P(port, " X", stepperX.getCurrent()); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) SERIAL_ECHOPAIR_P(port, " Y", stepperY.getCurrent()); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) SERIAL_ECHOPAIR_P(port, " Z", stepperZ.getCurrent()); #endif - #if X_IS_TRINAMIC || Y_IS_TRINAMIC || Z_IS_TRINAMIC + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) SERIAL_EOL_P(port); #endif - #if X2_IS_TRINAMIC || Y2_IS_TRINAMIC || Z2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) say_M906(PORTVAR_SOLO); SERIAL_ECHOPGM_P(port, " I1"); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) SERIAL_ECHOPAIR_P(port, " X", stepperX2.getCurrent()); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) SERIAL_ECHOPAIR_P(port, " Y", stepperY2.getCurrent()); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) SERIAL_ECHOPAIR_P(port, " Z", stepperZ2.getCurrent()); #endif - #if X2_IS_TRINAMIC || Y2_IS_TRINAMIC || Z2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) SERIAL_EOL_P(port); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) say_M906(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T0 E", stepperE0.getCurrent()); #endif - #if E_STEPPERS > 1 && E1_IS_TRINAMIC + #if E_STEPPERS > 1 && AXIS_IS_TMC(E1) say_M906(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T1 E", stepperE1.getCurrent()); #endif - #if E_STEPPERS > 2 && E2_IS_TRINAMIC + #if E_STEPPERS > 2 && AXIS_IS_TMC(E2) say_M906(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T2 E", stepperE2.getCurrent()); #endif - #if E_STEPPERS > 3 && E3_IS_TRINAMIC + #if E_STEPPERS > 3 && AXIS_IS_TMC(E3) say_M906(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T3 E", stepperE3.getCurrent()); #endif - #if E_STEPPERS > 4 && E4_IS_TRINAMIC + #if E_STEPPERS > 4 && AXIS_IS_TMC(E4) say_M906(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T4 E", stepperE4.getCurrent()); #endif @@ -2514,54 +2514,54 @@ void MarlinSettings::reset(PORTARG_SOLO) { SERIAL_ECHOLNPGM_P(port, "Hybrid Threshold:"); } CONFIG_ECHO_START; - #if X_IS_TRINAMIC || Y_IS_TRINAMIC || Z_IS_TRINAMIC + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) say_M913(PORTVAR_SOLO); #endif - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) SERIAL_ECHOPAIR_P(port, " X", TMC_GET_PWMTHRS(X, X)); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) SERIAL_ECHOPAIR_P(port, " Y", TMC_GET_PWMTHRS(Y, Y)); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) SERIAL_ECHOPAIR_P(port, " Z", TMC_GET_PWMTHRS(Z, Z)); #endif - #if X_IS_TRINAMIC || Y_IS_TRINAMIC || Z_IS_TRINAMIC + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) SERIAL_EOL_P(port); #endif - #if X2_IS_TRINAMIC || Y2_IS_TRINAMIC || Z2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) say_M913(PORTVAR_SOLO); SERIAL_ECHOPGM_P(port, " I1"); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) SERIAL_ECHOPAIR_P(port, " X", TMC_GET_PWMTHRS(X, X2)); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) SERIAL_ECHOPAIR_P(port, " Y", TMC_GET_PWMTHRS(Y, Y2)); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) SERIAL_ECHOPAIR_P(port, " Z", TMC_GET_PWMTHRS(Z, Z2)); #endif - #if X2_IS_TRINAMIC || Y2_IS_TRINAMIC || Z2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) SERIAL_EOL_P(port); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) say_M913(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T0 E", TMC_GET_PWMTHRS(E, E0)); #endif - #if E_STEPPERS > 1 && E1_IS_TRINAMIC + #if E_STEPPERS > 1 && AXIS_IS_TMC(E1) say_M913(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T1 E", TMC_GET_PWMTHRS(E, E1)); #endif - #if E_STEPPERS > 2 && E2_IS_TRINAMIC + #if E_STEPPERS > 2 && AXIS_IS_TMC(E2) say_M913(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T2 E", TMC_GET_PWMTHRS(E, E2)); #endif - #if E_STEPPERS > 3 && E3_IS_TRINAMIC + #if E_STEPPERS > 3 && AXIS_IS_TMC(E3) say_M913(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T3 E", TMC_GET_PWMTHRS(E, E3)); #endif - #if E_STEPPERS > 4 && E4_IS_TRINAMIC + #if E_STEPPERS > 4 && AXIS_IS_TMC(E4) say_M913(PORTVAR_SOLO); SERIAL_ECHOLNPAIR_P(port, " T4 E", TMC_GET_PWMTHRS(E, E4)); #endif @@ -2577,26 +2577,23 @@ void MarlinSettings::reset(PORTARG_SOLO) { SERIAL_ECHOLNPGM_P(port, "Sensorless homing threshold:"); } CONFIG_ECHO_START; - #define HAS_X_SENSORLESS (defined(X_HOMING_SENSITIVITY) && (ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS))) - #define HAS_Y_SENSORLESS (defined(Y_HOMING_SENSITIVITY) && (ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS))) - #define HAS_Z_SENSORLESS (defined(Z_HOMING_SENSITIVITY) && (ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS))) - #if HAS_X_SENSORLESS || HAS_Y_SENSORLESS || HAS_Z_SENSORLESS + #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS say_M914(PORTVAR_SOLO); - #if HAS_X_SENSORLESS + #if X_SENSORLESS SERIAL_ECHOPAIR_P(port, " X", stepperX.sgt()); #endif - #if HAS_Y_SENSORLESS + #if Y_SENSORLESS SERIAL_ECHOPAIR_P(port, " Y", stepperY.sgt()); #endif - #if HAS_Z_SENSORLESS + #if Z_SENSORLESS SERIAL_ECHOPAIR_P(port, " Z", stepperZ.sgt()); #endif SERIAL_EOL_P(port); #endif - #define HAS_X2_SENSORLESS (defined(X_HOMING_SENSITIVITY) && ENABLED(X2_IS_TMC2130)) - #define HAS_Y2_SENSORLESS (defined(Y_HOMING_SENSITIVITY) && ENABLED(Y2_IS_TMC2130)) - #define HAS_Z2_SENSORLESS (defined(Z_HOMING_SENSITIVITY) && ENABLED(Z2_IS_TMC2130)) + #define HAS_X2_SENSORLESS (defined(X_HOMING_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2)) + #define HAS_Y2_SENSORLESS (defined(Y_HOMING_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2)) + #define HAS_Z2_SENSORLESS (defined(Z_HOMING_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2)) #if HAS_X2_SENSORLESS || HAS_Y2_SENSORLESS || HAS_Z2_SENSORLESS say_M914(PORTVAR_SOLO); SERIAL_ECHOPGM_P(port, " I1"); diff --git a/Marlin/src/module/stepper_indirection.cpp b/Marlin/src/module/stepper_indirection.cpp index bf63e61b6..8858d22fd 100644 --- a/Marlin/src/module/stepper_indirection.cpp +++ b/Marlin/src/module/stepper_indirection.cpp @@ -38,7 +38,7 @@ // // TMC26X Driver objects and inits // -#if ENABLED(HAVE_TMC26X) +#if HAS_DRIVER(TMC26X) #include #ifdef STM32F7 @@ -49,37 +49,37 @@ #define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR) - #if ENABLED(X_IS_TMC26X) + #if AXIS_DRIVER_TYPE(X, TMC26X) _TMC26X_DEFINE(X); #endif - #if ENABLED(X2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(X2, TMC26X) _TMC26X_DEFINE(X2); #endif - #if ENABLED(Y_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Y, TMC26X) _TMC26X_DEFINE(Y); #endif - #if ENABLED(Y2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Y2, TMC26X) _TMC26X_DEFINE(Y2); #endif - #if ENABLED(Z_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Z, TMC26X) _TMC26X_DEFINE(Z); #endif - #if ENABLED(Z2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Z2, TMC26X) _TMC26X_DEFINE(Z2); #endif - #if ENABLED(E0_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E0, TMC26X) _TMC26X_DEFINE(E0); #endif - #if ENABLED(E1_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E1, TMC26X) _TMC26X_DEFINE(E1); #endif - #if ENABLED(E2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E2, TMC26X) _TMC26X_DEFINE(E2); #endif - #if ENABLED(E3_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E3, TMC26X) _TMC26X_DEFINE(E3); #endif - #if ENABLED(E4_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E4, TMC26X) _TMC26X_DEFINE(E4); #endif @@ -89,46 +89,46 @@ }while(0) void tmc26x_init_to_defaults() { - #if ENABLED(X_IS_TMC26X) + #if AXIS_DRIVER_TYPE(X, TMC26X) _TMC26X_INIT(X); #endif - #if ENABLED(X2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(X2, TMC26X) _TMC26X_INIT(X2); #endif - #if ENABLED(Y_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Y, TMC26X) _TMC26X_INIT(Y); #endif - #if ENABLED(Y2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Y2, TMC26X) _TMC26X_INIT(Y2); #endif - #if ENABLED(Z_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Z, TMC26X) _TMC26X_INIT(Z); #endif - #if ENABLED(Z2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Z2, TMC26X) _TMC26X_INIT(Z2); #endif - #if ENABLED(E0_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E0, TMC26X) _TMC26X_INIT(E0); #endif - #if ENABLED(E1_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E1, TMC26X) _TMC26X_INIT(E1); #endif - #if ENABLED(E2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E2, TMC26X) _TMC26X_INIT(E2); #endif - #if ENABLED(E3_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E3, TMC26X) _TMC26X_INIT(E3); #endif - #if ENABLED(E4_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E4, TMC26X) _TMC26X_INIT(E4); #endif } -#endif // HAVE_TMC26X +#endif // TMC26X // // TMC2130 Driver objects and inits // -#if ENABLED(HAVE_TMC2130) +#if HAS_DRIVER(TMC2130) #include #include @@ -146,37 +146,37 @@ #endif // Stepper objects of TMC2130 steppers used - #if ENABLED(X_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X, TMC2130) _TMC2130_DEFINE(X); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X2, TMC2130) _TMC2130_DEFINE(X2); #endif - #if ENABLED(Y_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y, TMC2130) _TMC2130_DEFINE(Y); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y2, TMC2130) _TMC2130_DEFINE(Y2); #endif - #if ENABLED(Z_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z, TMC2130) _TMC2130_DEFINE(Z); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z2, TMC2130) _TMC2130_DEFINE(Z2); #endif - #if ENABLED(E0_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E0, TMC2130) _TMC2130_DEFINE(E0); #endif - #if ENABLED(E1_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E1, TMC2130) _TMC2130_DEFINE(E1); #endif - #if ENABLED(E2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E2, TMC2130) _TMC2130_DEFINE(E2); #endif - #if ENABLED(E3_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E3, TMC2130) _TMC2130_DEFINE(E3); #endif - #if ENABLED(E4_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E4, TMC2130) _TMC2130_DEFINE(E4); #endif @@ -213,74 +213,74 @@ #define _TMC2130_INIT(ST, SPMM) tmc2130_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM) void tmc2130_init_to_defaults() { - #if ENABLED(X_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X, TMC2130) _TMC2130_INIT( X, planner.axis_steps_per_mm[X_AXIS]); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X2, TMC2130) _TMC2130_INIT(X2, planner.axis_steps_per_mm[X_AXIS]); #endif - #if ENABLED(Y_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y, TMC2130) _TMC2130_INIT( Y, planner.axis_steps_per_mm[Y_AXIS]); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y2, TMC2130) _TMC2130_INIT(Y2, planner.axis_steps_per_mm[Y_AXIS]); #endif - #if ENABLED(Z_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z, TMC2130) _TMC2130_INIT( Z, planner.axis_steps_per_mm[Z_AXIS]); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z2, TMC2130) _TMC2130_INIT(Z2, planner.axis_steps_per_mm[Z_AXIS]); #endif - #if ENABLED(E0_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E0, TMC2130) _TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]); #endif - #if ENABLED(E1_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E1, TMC2130) { constexpr int extruder = 1; _TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); } #endif - #if ENABLED(E2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E2, TMC2130) { constexpr int extruder = 2; _TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); } #endif - #if ENABLED(E3_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E3, TMC2130) { constexpr int extruder = 3; _TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); } #endif - #if ENABLED(E4_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E4, TMC2130) { constexpr int extruder = 4; _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); } #endif #if ENABLED(SENSORLESS_HOMING) #define TMC_INIT_SGT(P,Q) stepper##Q.sgt(P##_HOMING_SENSITIVITY); #if X_SENSORLESS - #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_DRIVER_TYPE(X, TMC2130) stepperX.sgt(X_HOMING_SENSITIVITY); #endif - #if ENABLED(X2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X2, TMC2130) stepperX2.sgt(X_HOMING_SENSITIVITY); #endif #endif #if Y_SENSORLESS - #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_DRIVER_TYPE(Y, TMC2130) stepperY.sgt(Y_HOMING_SENSITIVITY); #endif - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y2, TMC2130) stepperY2.sgt(Y_HOMING_SENSITIVITY); #endif #endif #if Z_SENSORLESS - #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) + #if AXIS_DRIVER_TYPE(Z, TMC2130) stepperZ.sgt(Z_HOMING_SENSITIVITY); #endif - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z2, TMC2130) stepperZ2.sgt(Z_HOMING_SENSITIVITY); #endif #endif #endif } -#endif // HAVE_TMC2130 +#endif // TMC2130 // // TMC2208 Driver objects and inits // -#if ENABLED(HAVE_TMC2208) +#if HAS_DRIVER(TMC2208) #include #include @@ -296,77 +296,77 @@ TMC2208Stepper stepper##ST(&ST##_HARDWARE_SERIAL, ST##_SERIAL_RX_PIN > -1) // Stepper objects of TMC2208 steppers used - #if ENABLED(X_IS_TMC2208) + #if AXIS_DRIVER_TYPE(X, TMC2208) #ifdef X_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(X); #else _TMC2208_DEFINE_SOFTWARE(X); #endif #endif - #if ENABLED(X2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(X2, TMC2208) #ifdef X2_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(X2); #else _TMC2208_DEFINE_SOFTWARE(X2); #endif #endif - #if ENABLED(Y_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Y, TMC2208) #ifdef Y_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(Y); #else _TMC2208_DEFINE_SOFTWARE(Y); #endif #endif - #if ENABLED(Y2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Y2, TMC2208) #ifdef Y2_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(Y2); #else _TMC2208_DEFINE_SOFTWARE(Y2); #endif #endif - #if ENABLED(Z_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Z, TMC2208) #ifdef Z_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(Z); #else _TMC2208_DEFINE_SOFTWARE(Z); #endif #endif - #if ENABLED(Z2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Z2, TMC2208) #ifdef Z2_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(Z2); #else _TMC2208_DEFINE_SOFTWARE(Z2); #endif #endif - #if ENABLED(E0_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E0, TMC2208) #ifdef E0_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(E0); #else _TMC2208_DEFINE_SOFTWARE(E0); #endif #endif - #if ENABLED(E1_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E1, TMC2208) #ifdef E1_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(E1); #else _TMC2208_DEFINE_SOFTWARE(E1); #endif #endif - #if ENABLED(E2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E2, TMC2208) #ifdef E2_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(E2); #else _TMC2208_DEFINE_SOFTWARE(E2); #endif #endif - #if ENABLED(E3_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E3, TMC2208) #ifdef E3_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(E3); #else _TMC2208_DEFINE_SOFTWARE(E3); #endif #endif - #if ENABLED(E4_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E4, TMC2208) #ifdef E4_HARDWARE_SERIAL _TMC2208_DEFINE_HARDWARE(E4); #else @@ -375,37 +375,37 @@ #endif void tmc2208_serial_begin() { - #if ENABLED(X_IS_TMC2208) + #if AXIS_DRIVER_TYPE(X, TMC2208) X_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(X2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(X2, TMC2208) X2_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(Y_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Y, TMC2208) Y_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(Y2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Y2, TMC2208) Y2_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(Z_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Z, TMC2208) Z_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(Z2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Z2, TMC2208) Z2_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(E0_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E0, TMC2208) E0_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(E1_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E1, TMC2208) E1_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(E2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E2, TMC2208) E2_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(E3_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E3, TMC2208) E3_HARDWARE_SERIAL.begin(115200); #endif - #if ENABLED(E4_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E4, TMC2208) E4_HARDWARE_SERIAL.begin(115200); #endif } @@ -449,94 +449,94 @@ #define _TMC2208_INIT(ST, SPMM) tmc2208_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM) void tmc2208_init_to_defaults() { - #if ENABLED(X_IS_TMC2208) + #if AXIS_DRIVER_TYPE(X, TMC2208) _TMC2208_INIT(X, planner.axis_steps_per_mm[X_AXIS]); #endif - #if ENABLED(X2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(X2, TMC2208) _TMC2208_INIT(X2, planner.axis_steps_per_mm[X_AXIS]); #endif - #if ENABLED(Y_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Y, TMC2208) _TMC2208_INIT(Y, planner.axis_steps_per_mm[Y_AXIS]); #endif - #if ENABLED(Y2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Y2, TMC2208) _TMC2208_INIT(Y2, planner.axis_steps_per_mm[Y_AXIS]); #endif - #if ENABLED(Z_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Z, TMC2208) _TMC2208_INIT(Z, planner.axis_steps_per_mm[Z_AXIS]); #endif - #if ENABLED(Z2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(Z2, TMC2208) _TMC2208_INIT(Z2, planner.axis_steps_per_mm[Z_AXIS]); #endif - #if ENABLED(E0_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E0, TMC2208) _TMC2208_INIT(E0, planner.axis_steps_per_mm[E_AXIS]); #endif - #if ENABLED(E1_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E1, TMC2208) { constexpr int extruder = 1; _TMC2208_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); } #endif - #if ENABLED(E2_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E2, TMC2208) { constexpr int extruder = 2; _TMC2208_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); } #endif - #if ENABLED(E3_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E3, TMC2208) { constexpr int extruder = 3; _TMC2208_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); } #endif - #if ENABLED(E4_IS_TMC2208) + #if AXIS_DRIVER_TYPE(E4, TMC2208) { constexpr int extruder = 4; _TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); } #endif } -#endif // HAVE_TMC2208 +#endif // TMC2208 void restore_stepper_drivers() { - #if X_IS_TRINAMIC + #if AXIS_IS_TMC(X) stepperX.push(); #endif - #if X2_IS_TRINAMIC + #if AXIS_IS_TMC(X2) stepperX2.push(); #endif - #if Y_IS_TRINAMIC + #if AXIS_IS_TMC(Y) stepperY.push(); #endif - #if Y2_IS_TRINAMIC + #if AXIS_IS_TMC(Y2) stepperY2.push(); #endif - #if Z_IS_TRINAMIC + #if AXIS_IS_TMC(Z) stepperZ.push(); #endif - #if Z2_IS_TRINAMIC + #if AXIS_IS_TMC(Z2) stepperZ2.push(); #endif - #if E0_IS_TRINAMIC + #if AXIS_IS_TMC(E0) stepperE0.push(); #endif - #if E1_IS_TRINAMIC + #if AXIS_IS_TMC(E1) stepperE1.push(); #endif - #if E2_IS_TRINAMIC + #if AXIS_IS_TMC(E2) stepperE2.push(); #endif - #if E3_IS_TRINAMIC + #if AXIS_IS_TMC(E3) stepperE3.push(); #endif - #if E4_IS_TRINAMIC + #if AXIS_IS_TMC(E4) stepperE4.push(); #endif } void reset_stepper_drivers() { - #if ENABLED(HAVE_TMC26X) + #if HAS_DRIVER(TMC26X) tmc26x_init_to_defaults(); #endif - #if ENABLED(HAVE_TMC2130) + #if HAS_DRIVER(TMC2130) delay(100); tmc2130_init_to_defaults(); #endif - #if ENABLED(HAVE_TMC2208) + #if HAS_DRIVER(TMC2208) delay(100); tmc2208_init_to_defaults(); #endif #ifdef TMC_ADV TMC_ADV() #endif - #if ENABLED(HAVE_L6470DRIVER) + #if HAS_DRIVER(L6470) L6470_init_to_defaults(); #endif } @@ -544,7 +544,7 @@ void reset_stepper_drivers() { // // L6470 Driver objects and inits // -#if ENABLED(HAVE_L6470DRIVER) +#if HAS_DRIVER(L6470) #include #include @@ -552,37 +552,37 @@ void reset_stepper_drivers() { #define _L6470_DEFINE(ST) L6470 stepper##ST(ST##_ENABLE_PIN) // L6470 Stepper objects - #if ENABLED(X_IS_L6470) + #if AXIS_DRIVER_TYPE(X, L6470) _L6470_DEFINE(X); #endif - #if ENABLED(X2_IS_L6470) + #if AXIS_DRIVER_TYPE(X2, L6470) _L6470_DEFINE(X2); #endif - #if ENABLED(Y_IS_L6470) + #if AXIS_DRIVER_TYPE(Y, L6470) _L6470_DEFINE(Y); #endif - #if ENABLED(Y2_IS_L6470) + #if AXIS_DRIVER_TYPE(Y2, L6470) _L6470_DEFINE(Y2); #endif - #if ENABLED(Z_IS_L6470) + #if AXIS_DRIVER_TYPE(Z, L6470) _L6470_DEFINE(Z); #endif - #if ENABLED(Z2_IS_L6470) + #if AXIS_DRIVER_TYPE(Z2, L6470) _L6470_DEFINE(Z2); #endif - #if ENABLED(E0_IS_L6470) + #if AXIS_DRIVER_TYPE(E0, L6470) _L6470_DEFINE(E0); #endif - #if ENABLED(E1_IS_L6470) + #if AXIS_DRIVER_TYPE(E1, L6470) _L6470_DEFINE(E1); #endif - #if ENABLED(E2_IS_L6470) + #if AXIS_DRIVER_TYPE(E2, L6470) _L6470_DEFINE(E2); #endif - #if ENABLED(E3_IS_L6470) + #if AXIS_DRIVER_TYPE(E3, L6470) _L6470_DEFINE(E3); #endif - #if ENABLED(E4_IS_L6470) + #if AXIS_DRIVER_TYPE(E4, L6470) _L6470_DEFINE(E4); #endif @@ -595,39 +595,39 @@ void reset_stepper_drivers() { }while(0) void L6470_init_to_defaults() { - #if ENABLED(X_IS_L6470) + #if AXIS_DRIVER_TYPE(X, L6470) _L6470_INIT(X); #endif - #if ENABLED(X2_IS_L6470) + #if AXIS_DRIVER_TYPE(X2, L6470) _L6470_INIT(X2); #endif - #if ENABLED(Y_IS_L6470) + #if AXIS_DRIVER_TYPE(Y, L6470) _L6470_INIT(Y); #endif - #if ENABLED(Y2_IS_L6470) + #if AXIS_DRIVER_TYPE(Y2, L6470) _L6470_INIT(Y2); #endif - #if ENABLED(Z_IS_L6470) + #if AXIS_DRIVER_TYPE(Z, L6470) _L6470_INIT(Z); #endif - #if ENABLED(Z2_IS_L6470) + #if AXIS_DRIVER_TYPE(Z2, L6470) _L6470_INIT(Z2); #endif - #if ENABLED(E0_IS_L6470) + #if AXIS_DRIVER_TYPE(E0, L6470) _L6470_INIT(E0); #endif - #if ENABLED(E1_IS_L6470) + #if AXIS_DRIVER_TYPE(E1, L6470) _L6470_INIT(E1); #endif - #if ENABLED(E2_IS_L6470) + #if AXIS_DRIVER_TYPE(E2, L6470) _L6470_INIT(E2); #endif - #if ENABLED(E3_IS_L6470) + #if AXIS_DRIVER_TYPE(E3, L6470) _L6470_INIT(E3); #endif - #if ENABLED(E4_IS_L6470) + #if AXIS_DRIVER_TYPE(E4, L6470) _L6470_INIT(E4); #endif } -#endif // HAVE_L6470DRIVER +#endif // L6470 diff --git a/Marlin/src/module/stepper_indirection.h b/Marlin/src/module/stepper_indirection.h index 7b80a459b..8ac4a0d8e 100644 --- a/Marlin/src/module/stepper_indirection.h +++ b/Marlin/src/module/stepper_indirection.h @@ -47,7 +47,7 @@ #include "../inc/MarlinConfig.h" // TMC26X drivers have STEP/DIR on normal pins, but ENABLE via SPI -#if ENABLED(HAVE_TMC26X) +#if HAS_DRIVER(TMC26X) #include #ifdef STM32F7 #include "../HAL/HAL_STM32F7/TMC2660.h" @@ -57,19 +57,19 @@ void tmc26x_init_to_defaults(); #endif -#if ENABLED(HAVE_TMC2130) +#if HAS_DRIVER(TMC2130) #include void tmc2130_init_to_defaults(); #endif -#if ENABLED(HAVE_TMC2208) +#if HAS_DRIVER(TMC2208) #include void tmc2208_serial_begin(); void tmc2208_init_to_defaults(); #endif // L6470 has STEP on normal pins, but DIR/ENABLE via SPI -#if ENABLED(HAVE_L6470DRIVER) +#if HAS_DRIVER(L6470) #include #include void L6470_init_to_defaults(); @@ -79,7 +79,7 @@ void restore_stepper_drivers(); // Called by PSU_ON void reset_stepper_drivers(); // Called by settings.load / settings.reset // X Stepper -#if ENABLED(X_IS_L6470) +#if AXIS_DRIVER_TYPE(X, L6470) extern L6470 stepperX; #define X_ENABLE_INIT NOOP #define X_ENABLE_WRITE(STATE) do{ if (STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree(); }while(0) @@ -88,15 +88,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define X_DIR_WRITE(STATE) stepperX.Step_Clock(STATE) #define X_DIR_READ (stepperX.getStatus() & STATUS_DIR) #else - #if ENABLED(X_IS_TMC26X) + #if AXIS_DRIVER_TYPE(X, TMC26X) extern TMC26XStepper stepperX; #define X_ENABLE_INIT NOOP #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE) #define X_ENABLE_READ stepperX.isEnabled() #else - #if ENABLED(X_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X, TMC2130) extern TMC2130Stepper stepperX; - #elif ENABLED(X_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(X, TMC2208) extern TMC2208Stepper stepperX; #endif #define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN) @@ -112,7 +112,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define X_STEP_READ READ(X_STEP_PIN) // Y Stepper -#if ENABLED(Y_IS_L6470) +#if AXIS_DRIVER_TYPE(Y, L6470) extern L6470 stepperY; #define Y_ENABLE_INIT NOOP #define Y_ENABLE_WRITE(STATE) do{ if (STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree(); }while(0) @@ -121,15 +121,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Y_DIR_WRITE(STATE) stepperY.Step_Clock(STATE) #define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR) #else - #if ENABLED(Y_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Y, TMC26X) extern TMC26XStepper stepperY; #define Y_ENABLE_INIT NOOP #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE) #define Y_ENABLE_READ stepperY.isEnabled() #else - #if ENABLED(Y_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y, TMC2130) extern TMC2130Stepper stepperY; - #elif ENABLED(Y_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(Y, TMC2208) extern TMC2208Stepper stepperY; #endif #define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN) @@ -145,7 +145,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Y_STEP_READ READ(Y_STEP_PIN) // Z Stepper -#if ENABLED(Z_IS_L6470) +#if AXIS_DRIVER_TYPE(Z, L6470) extern L6470 stepperZ; #define Z_ENABLE_INIT NOOP #define Z_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree(); }while(0) @@ -154,15 +154,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Z_DIR_WRITE(STATE) stepperZ.Step_Clock(STATE) #define Z_DIR_READ (stepperZ.getStatus() & STATUS_DIR) #else - #if ENABLED(Z_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Z, TMC26X) extern TMC26XStepper stepperZ; #define Z_ENABLE_INIT NOOP #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE) #define Z_ENABLE_READ stepperZ.isEnabled() #else - #if ENABLED(Z_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z, TMC2130) extern TMC2130Stepper stepperZ; - #elif ENABLED(Z_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(Z, TMC2208) extern TMC2208Stepper stepperZ; #endif #define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN) @@ -179,7 +179,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // X2 Stepper #if HAS_X2_ENABLE - #if ENABLED(X2_IS_L6470) + #if AXIS_DRIVER_TYPE(X2, L6470) extern L6470 stepperX2; #define X2_ENABLE_INIT NOOP #define X2_ENABLE_WRITE(STATE) do{ if (STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree(); }while(0) @@ -188,15 +188,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define X2_DIR_WRITE(STATE) stepperX2.Step_Clock(STATE) #define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR) #else - #if ENABLED(X2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(X2, TMC26X) extern TMC26XStepper stepperX2; #define X2_ENABLE_INIT NOOP #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE) #define X2_ENABLE_READ stepperX2.isEnabled() #else - #if ENABLED(X2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(X2, TMC2130) extern TMC2130Stepper stepperX2; - #elif ENABLED(X2_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(X2, TMC2208) extern TMC2208Stepper stepperX2; #endif #define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN) @@ -214,7 +214,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // Y2 Stepper #if HAS_Y2_ENABLE - #if ENABLED(Y2_IS_L6470) + #if AXIS_DRIVER_TYPE(Y2, L6470) extern L6470 stepperY2; #define Y2_ENABLE_INIT NOOP #define Y2_ENABLE_WRITE(STATE) do{ if (STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree(); }while(0) @@ -223,15 +223,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Y2_DIR_WRITE(STATE) stepperY2.Step_Clock(STATE) #define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR) #else - #if ENABLED(Y2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Y2, TMC26X) extern TMC26XStepper stepperY2; #define Y2_ENABLE_INIT NOOP #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE) #define Y2_ENABLE_READ stepperY2.isEnabled() #else - #if ENABLED(Y2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Y2, TMC2130) extern TMC2130Stepper stepperY2; - #elif ENABLED(Y2_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(Y2, TMC2208) extern TMC2208Stepper stepperY2; #endif #define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN) @@ -249,7 +249,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // Z2 Stepper #if HAS_Z2_ENABLE - #if ENABLED(Z2_IS_L6470) + #if AXIS_DRIVER_TYPE(Z2, L6470) extern L6470 stepperZ2; #define Z2_ENABLE_INIT NOOP #define Z2_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree(); }while(0) @@ -258,15 +258,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Z2_DIR_WRITE(STATE) stepperZ2.Step_Clock(STATE) #define Z2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR) #else - #if ENABLED(Z2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(Z2, TMC26X) extern TMC26XStepper stepperZ2; #define Z2_ENABLE_INIT NOOP #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE) #define Z2_ENABLE_READ stepperZ2.isEnabled() #else - #if ENABLED(Z2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(Z2, TMC2130) extern TMC2130Stepper stepperZ2; - #elif ENABLED(Z2_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(Z2, TMC2208) extern TMC2208Stepper stepperZ2; #endif #define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN) @@ -283,7 +283,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // E0 Stepper -#if ENABLED(E0_IS_L6470) +#if AXIS_DRIVER_TYPE(E0, L6470) extern L6470 stepperE0; #define E0_ENABLE_INIT NOOP #define E0_ENABLE_WRITE(STATE) do{ if (STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree(); }while(0) @@ -292,15 +292,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E0_DIR_WRITE(STATE) stepperE0.Step_Clock(STATE) #define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR) #else - #if ENABLED(E0_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E0, TMC26X) extern TMC26XStepper stepperE0; #define E0_ENABLE_INIT NOOP #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE) #define E0_ENABLE_READ stepperE0.isEnabled() #else - #if ENABLED(E0_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E0, TMC2130) extern TMC2130Stepper stepperE0; - #elif ENABLED(E0_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(E0, TMC2208) extern TMC2208Stepper stepperE0; #endif #define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN) @@ -316,7 +316,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E0_STEP_READ READ(E0_STEP_PIN) // E1 Stepper -#if ENABLED(E1_IS_L6470) +#if AXIS_DRIVER_TYPE(E1, L6470) extern L6470 stepperE1; #define E1_ENABLE_INIT NOOP #define E1_ENABLE_WRITE(STATE) do{ if (STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree(); }while(0) @@ -325,15 +325,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E1_DIR_WRITE(STATE) stepperE1.Step_Clock(STATE) #define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR) #else - #if ENABLED(E1_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E1, TMC26X) extern TMC26XStepper stepperE1; #define E1_ENABLE_INIT NOOP #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE) #define E1_ENABLE_READ stepperE1.isEnabled() #else - #if ENABLED(E1_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E1, TMC2130) extern TMC2130Stepper stepperE1; - #elif ENABLED(E1_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(E1, TMC2208) extern TMC2208Stepper stepperE1; #endif #define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN) @@ -349,7 +349,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E1_STEP_READ READ(E1_STEP_PIN) // E2 Stepper -#if ENABLED(E2_IS_L6470) +#if AXIS_DRIVER_TYPE(E2, L6470) extern L6470 stepperE2; #define E2_ENABLE_INIT NOOP #define E2_ENABLE_WRITE(STATE) do{ if (STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree(); }while(0) @@ -358,15 +358,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E2_DIR_WRITE(STATE) stepperE2.Step_Clock(STATE) #define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR) #else - #if ENABLED(E2_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E2, TMC26X) extern TMC26XStepper stepperE2; #define E2_ENABLE_INIT NOOP #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE) #define E2_ENABLE_READ stepperE2.isEnabled() #else - #if ENABLED(E2_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E2, TMC2130) extern TMC2130Stepper stepperE2; - #elif ENABLED(E2_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(E2, TMC2208) extern TMC2208Stepper stepperE2; #endif #define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN) @@ -382,7 +382,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E2_STEP_READ READ(E2_STEP_PIN) // E3 Stepper -#if ENABLED(E3_IS_L6470) +#if AXIS_DRIVER_TYPE(E3, L6470) extern L6470 stepperE3; #define E3_ENABLE_INIT NOOP #define E3_ENABLE_WRITE(STATE) do{ if (STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree(); }while(0) @@ -391,15 +391,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E3_DIR_WRITE(STATE) stepperE3.Step_Clock(STATE) #define E3_DIR_READ (stepperE3.getStatus() & STATUS_DIR) #else - #if ENABLED(E3_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E3, TMC26X) extern TMC26XStepper stepperE3; #define E3_ENABLE_INIT NOOP #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE) #define E3_ENABLE_READ stepperE3.isEnabled() #else - #if ENABLED(E3_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E3, TMC2130) extern TMC2130Stepper stepperE3; - #elif ENABLED(E3_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(E3, TMC2208) extern TMC2208Stepper stepperE3; #endif #define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN) @@ -415,7 +415,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E3_STEP_READ READ(E3_STEP_PIN) // E4 Stepper -#if ENABLED(E4_IS_L6470) +#if AXIS_DRIVER_TYPE(E4, L6470) extern L6470 stepperE4; #define E4_ENABLE_INIT NOOP #define E4_ENABLE_WRITE(STATE) do{ if (STATE) stepperE4.Step_Clock(stepperE4.getStatus() & STATUS_HIZ); else stepperE4.softFree(); }while(0) @@ -424,15 +424,15 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E4_DIR_WRITE(STATE) stepperE4.Step_Clock(STATE) #define E4_DIR_READ (stepperE4.getStatus() & STATUS_DIR) #else - #if ENABLED(E4_IS_TMC26X) + #if AXIS_DRIVER_TYPE(E4, TMC26X) extern TMC26XStepper stepperE4; #define E4_ENABLE_INIT NOOP #define E4_ENABLE_WRITE(STATE) stepperE4.setEnabled(STATE) #define E4_ENABLE_READ stepperE4.isEnabled() #else - #if ENABLED(E4_IS_TMC2130) + #if AXIS_DRIVER_TYPE(E4, TMC2130) extern TMC2130Stepper stepperE4; - #elif ENABLED(E4_IS_TMC2208) + #elif AXIS_DRIVER_TYPE(E4, TMC2208) extern TMC2208Stepper stepperE4; #endif #define E4_ENABLE_INIT SET_OUTPUT(E4_ENABLE_PIN) diff --git a/Marlin/src/pins/pins_EINSY_RAMBO.h b/Marlin/src/pins/pins_EINSY_RAMBO.h index b3c1d1caa..428dc047c 100644 --- a/Marlin/src/pins/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/pins_EINSY_RAMBO.h @@ -33,10 +33,8 @@ // // TMC2130 Configuration_adv defaults for EinsyRambo // -#if DISABLED(HAVE_TMC2130) - #error "You must enable TMC2130 support in Configuration_adv.h for EinsyRambo." -#elif DISABLED(X_IS_TMC2130) || DISABLED(Y_IS_TMC2130) || DISABLED(Z_IS_TMC2130) || DISABLED(E0_IS_TMC2130) - #error "You must enable ([XYZ]|E0)_IS_TMC2130 in Configuration_adv.h for EinsyRambo." +#if !AXIS_DRIVER_TYPE(X, TMC2130) || !AXIS_DRIVER_TYPE(Y, TMC2130) || !AXIS_DRIVER_TYPE(Z, TMC2130) || !AXIS_DRIVER_TYPE(E0, TMC2130) + #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRambo." #endif // TMC2130 Diag Pins (currently just for reference) diff --git a/Marlin/src/pins/pins_EINSY_RETRO.h b/Marlin/src/pins/pins_EINSY_RETRO.h index df4f1c20b..a100d9329 100644 --- a/Marlin/src/pins/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/pins_EINSY_RETRO.h @@ -33,10 +33,8 @@ // // TMC2130 Configuration_adv defaults for EinsyRetro // -#if DISABLED(HAVE_TMC2130) - #error "You must enable TMC2130 support in Configuration_adv.h for EinsyRetro." -#elif DISABLED(X_IS_TMC2130) || DISABLED(Y_IS_TMC2130) || DISABLED(Z_IS_TMC2130) || DISABLED(E0_IS_TMC2130) - #error "You must enable ([XYZ]|E0)_IS_TMC2130 in Configuration_adv.h for EinsyRetro." +#if !AXIS_DRIVER_TYPE(X, TMC2130) || !AXIS_DRIVER_TYPE(Y, TMC2130) || !AXIS_DRIVER_TYPE(Z, TMC2130) || !AXIS_DRIVER_TYPE(E0, TMC2130) + #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRetro." #endif // TMC2130 Diag Pins (currently just for reference) diff --git a/Marlin/src/pins/pins_RAMPS.h b/Marlin/src/pins/pins_RAMPS.h index a85f3b604..b8c6233da 100644 --- a/Marlin/src/pins/pins_RAMPS.h +++ b/Marlin/src/pins/pins_RAMPS.h @@ -146,7 +146,7 @@ #endif #endif -#if ENABLED(HAVE_TMC2208) +#if HAS_DRIVER(TMC2208) /** * TMC2208 stepper drivers * diff --git a/Marlin/src/pins/pins_RAMPS_FD_V1.h b/Marlin/src/pins/pins_RAMPS_FD_V1.h index d8cdeb54f..b6266fab8 100644 --- a/Marlin/src/pins/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/pins_RAMPS_FD_V1.h @@ -178,7 +178,7 @@ #endif // ULTRA_LCD -#if ENABLED(HAVE_TMC2208) +#if HAS_DRIVER(TMC2208) /** * TMC2208 stepper drivers * diff --git a/buildroot/share/tests/megaatmega2560_tests b/buildroot/share/tests/megaatmega2560_tests index e13085594..faf7cd0af 100755 --- a/buildroot/share/tests/megaatmega2560_tests +++ b/buildroot/share/tests/megaatmega2560_tests @@ -287,14 +287,20 @@ exec_test $1 $2 "Delta Config (FLSUN AC because it's complex)" # use_example_configs SCARA opt_enable AUTO_BED_LEVELING_BILINEAR FIX_MOUNTED_PROBE USE_ZMIN_PLUG EEPROM_SETTINGS EEPROM_CHITCHAT ULTIMAKERCONTROLLER -opt_enable_adv HAVE_TMC2130 X_IS_TMC2130 Y_IS_TMC2130 Z_IS_TMC2130 +opt_set X_DRIVER_TYPE TMC2130 +opt_set Y_DRIVER_TYPE TMC2130 +opt_set Z_DRIVER_TYPE TMC2130 +opt_set E0_DRIVER_TYPE TMC2130 opt_enable_adv MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD SENSORLESS_HOMING exec_test $1 $2 "SCARA with TMC2130" # # TMC2208 Config # restore_configs -opt_enable_adv HAVE_TMC2208 X_IS_TMC2208 Y_IS_TMC2208 Z_IS_TMC2208 +opt_set X_DRIVER_TYPE TMC2208 +opt_set Y_DRIVER_TYPE TMC2208 +opt_set Z_DRIVER_TYPE TMC2208 +opt_set E0_DRIVER_TYPE TMC2208 opt_enable_adv MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD TMC_DEBUG exec_test $1 $2 "TMC2208 Config" #