diff --git a/Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h b/Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h index a8d51edfab..44bf8e4473 100644 --- a/Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h @@ -55,3 +55,7 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h b/Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h index 9c62a353e7..c5b0bc0537 100644 --- a/Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h @@ -28,3 +28,7 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/HAL/HAL_LINUX/inc/SanityCheck.h b/Marlin/src/HAL/HAL_LINUX/inc/SanityCheck.h index 776fa2f139..3b18dec730 100644 --- a/Marlin/src/HAL/HAL_LINUX/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_LINUX/inc/SanityCheck.h @@ -33,3 +33,7 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h index 9880722670..0c1e83115e 100644 --- a/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h @@ -46,3 +46,7 @@ #if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM) #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Activator" #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/HAL/HAL_STM32/HAL.cpp b/Marlin/src/HAL/HAL_STM32/HAL.cpp index 4fbfa7298c..1e9129b63f 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL.cpp +++ b/Marlin/src/HAL/HAL_STM32/HAL.cpp @@ -28,13 +28,7 @@ #include "../../inc/MarlinConfig.h" #include "../shared/Delay.h" -#if (__cplusplus == 201703L) && defined(__has_include) - #define HAS_SWSERIAL __has_include() -#else - #define HAS_SWSERIAL HAS_TMC220x -#endif - -#if HAS_SWSERIAL +#if TMC_HAS_SW_SERIAL #include "SoftwareSerial.h" #endif @@ -93,7 +87,7 @@ void HAL_init() { while (!LL_PWR_IsActiveFlag_BRR()); #endif // EEPROM_EMULATED_SRAM - #if HAS_SWSERIAL + #if TMC_HAS_SW_SERIAL SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0); #endif } diff --git a/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h b/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h index 69466a0a77..7673d8673a 100644 --- a/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h @@ -37,7 +37,7 @@ #error "FAST_PWM_FAN is not yet implemented for this platform." #endif -#if !defined(HAVE_SW_SERIAL) && HAS_TMC220x +#if !defined(HAVE_SW_SERIAL) && TMC_HAS_SW_SERIAL #warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER." #error "Missing SoftwareSerial implementation." #endif diff --git a/Marlin/src/HAL/HAL_STM32_F4_F7/inc/SanityCheck.h b/Marlin/src/HAL/HAL_STM32_F4_F7/inc/SanityCheck.h index 7b8d29aa7d..c647ea0c03 100644 --- a/Marlin/src/HAL/HAL_STM32_F4_F7/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_STM32_F4_F7/inc/SanityCheck.h @@ -35,3 +35,7 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/inc/SanityCheck.h b/Marlin/src/HAL/HAL_TEENSY31_32/inc/SanityCheck.h index 389d27824e..b680a1a445 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/inc/SanityCheck.h @@ -32,3 +32,7 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/inc/SanityCheck.h b/Marlin/src/HAL/HAL_TEENSY35_36/inc/SanityCheck.h index 6a126b683e..5cb2cbfc8c 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/inc/SanityCheck.h @@ -32,3 +32,7 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if TMC_HAS_SW_SERIAL + #error "TMC220x Software Serial is not supported on this platform." +#endif diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 44434581a5..56f4a6fa4a 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -86,6 +86,18 @@ || HAS_DRIVER(TMC5130) \ || HAS_DRIVER(TMC5160) ) +#define HAS_TRINAMIC_STANDALONE ( HAS_DRIVER(TMC2130_STANDALONE) \ + || HAS_DRIVER(TMC2208_STANDALONE) \ + || HAS_DRIVER(TMC2209_STANDALONE) \ + || HAS_DRIVER(TMC26X_STANDALONE) \ + || HAS_DRIVER(TMC2660_STANDALONE) \ + || HAS_DRIVER(TMC5130_STANDALONE) \ + || HAS_DRIVER(TMC5160_STANDALONE) \ + || HAS_DRIVER(TMC2160_STANDALONE) ) + +#define HAS_TMCX1X0 ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \ + || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)) + #define HAS_TMC220x (HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209)) #define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \ @@ -107,6 +119,8 @@ #define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) \ || AXIS_DRIVER_TYPE(A,TMC2209) ) +#define AXIS_HAS_SW_SERIAL(A) ((AXIS_HAS_UART(A) && !defined(A##_HARDWARE_SERIAL))) + #define AXIS_HAS_STALLGUARD(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \ || AXIS_DRIVER_TYPE(A,TMC2160) \ || AXIS_DRIVER_TYPE(A,TMC2209) \ @@ -121,19 +135,19 @@ || AXIS_DRIVER_TYPE(A,TMC5130) \ || AXIS_DRIVER_TYPE(A,TMC5160) ) -#define HAS_TMC_E_DRIVER ( HAS_E_DRIVER(TMC2130) \ - || HAS_E_DRIVER(TMC2160) \ - || HAS_E_DRIVER(TMC2660) \ - || HAS_E_DRIVER(TMC2209) \ - || HAS_E_DRIVER(TMC5130) \ - || HAS_E_DRIVER(TMC5160) ) +#define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(X2) \ + || AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \ + || AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) \ + || AXIS_HAS_##T(Z3) \ + || AXIS_HAS_##T(E0) || AXIS_HAS_##T(E1) \ + || AXIS_HAS_##T(E2) || AXIS_HAS_##T(E3) \ + || AXIS_HAS_##T(E4) || AXIS_HAS_##T(E5) ) + +#define HAS_STEALTHCHOP ANY_AXIS_HAS(STEALTHCHOP) +#define HAS_STALLGUARD ANY_AXIS_HAS(STALLGUARD) +#define TMC_HAS_SPI ANY_AXIS_HAS(SPI) +#define TMC_HAS_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL) -#define HAS_TMC_STANDALONE_E_DRIVER ( HAS_E_DRIVER(TMC2130_STANDALONE) \ - || HAS_E_DRIVER(TMC2160_STANDALONE) \ - || HAS_E_DRIVER(TMC2660_STANDALONE) \ - || HAS_E_DRIVER(TMC2209_STANDALONE) \ - || HAS_E_DRIVER(TMC5130_STANDALONE) \ - || HAS_E_DRIVER(TMC5160_STANDALONE) ) // // Stretching 'drivers.h' to include LPC/SAMD51 SD options // diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9c1393578c..28c1c93a0f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -556,8 +556,6 @@ * Preserve this ordering when adding new drivers. */ -#define TRINAMICS (HAS_TRINAMIC || HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC2209_STANDALONE) || HAS_DRIVER(TMC26X_STANDALONE) || HAS_DRIVER(TMC2660_STANDALONE) || HAS_DRIVER(TMC5130_STANDALONE) || HAS_DRIVER(TMC5160_STANDALONE) || HAS_DRIVER(TMC2160_STANDALONE)) - #ifndef MINIMUM_STEPPER_POST_DIR_DELAY #if HAS_DRIVER(TB6560) #define MINIMUM_STEPPER_POST_DIR_DELAY 15000 @@ -571,7 +569,7 @@ #define MINIMUM_STEPPER_POST_DIR_DELAY 400 #elif HAS_DRIVER(A4988) #define MINIMUM_STEPPER_POST_DIR_DELAY 200 - #elif TRINAMICS + #elif HAS_TRINAMIC || HAS_TRINAMIC_STANDALONE #define MINIMUM_STEPPER_POST_DIR_DELAY 20 #else #define MINIMUM_STEPPER_POST_DIR_DELAY 0 // Expect at least 10µS since one Stepper ISR must transpire @@ -970,11 +968,6 @@ // Trinamic Stepper Drivers #if HAS_TRINAMIC - #define HAS_TMCX1X0 (HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)) - #define TMC_HAS_SPI (HAS_TMCX1X0 || HAS_DRIVER(TMC2660)) - #define HAS_STALLGUARD (HAS_TMCX1X0 || HAS_DRIVER(TMC2209) || HAS_DRIVER(TMC2660)) - #define HAS_STEALTHCHOP (HAS_TMCX1X0 || HAS_TMC220x) - #define STEALTHCHOP_ENABLED ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E) #define USE_SENSORLESS EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) // Disable Z axis sensorless homing if a probe is used to home the Z axis diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c43b6698bd..9c5b7893fc 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2018,34 +2018,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #undef INVALID_TMC_ADDRESS -/** - * TMC2208/2209 software UART and ENDSTOP_INTERRUPTS both use pin change interrupts (PCI) - */ -#if HAS_TMC220x && !defined(TARGET_LPC1768) && ENABLED(ENDSTOP_INTERRUPTS_FEATURE) && !defined(TARGET_STM32F1) && !defined(TARGET_STM32F4) && !( \ - defined(X_HARDWARE_SERIAL ) || defined(X2_HARDWARE_SERIAL) \ - || defined(Y_HARDWARE_SERIAL ) || defined(Y2_HARDWARE_SERIAL) \ - || defined(Z_HARDWARE_SERIAL ) || defined(Z2_HARDWARE_SERIAL) \ - || defined(Z3_HARDWARE_SERIAL) || defined(E0_HARDWARE_SERIAL) \ - || defined(E1_HARDWARE_SERIAL) || defined(E2_HARDWARE_SERIAL) \ - || defined(E3_HARDWARE_SERIAL) || defined(E4_HARDWARE_SERIAL) \ - || defined(E5_HARDWARE_SERIAL) ) - #error "Select hardware UART for TMC2208 to use both TMC2208 and ENDSTOP_INTERRUPTS_FEATURE." -#endif - -/** - * TMC2208/2209 software UART is only supported on AVR, LPC, STM32F1 and STM32F4 - */ -#if HAS_TMC220x && !defined(__AVR__) && !defined(TARGET_LPC1768) && !defined(TARGET_STM32F1) && !defined(TARGET_STM32F4) && !( \ - defined(X_HARDWARE_SERIAL ) || defined(X2_HARDWARE_SERIAL) \ - || defined(Y_HARDWARE_SERIAL ) || defined(Y2_HARDWARE_SERIAL) \ - || defined(Z_HARDWARE_SERIAL ) || defined(Z2_HARDWARE_SERIAL) \ - || defined(Z3_HARDWARE_SERIAL) || defined(E0_HARDWARE_SERIAL) \ - || defined(E1_HARDWARE_SERIAL) || defined(E2_HARDWARE_SERIAL) \ - || defined(E3_HARDWARE_SERIAL) || defined(E4_HARDWARE_SERIAL) \ - || defined(E5_HARDWARE_SERIAL) ) - #error "TMC2208 Software Serial is supported only on AVR, LPC1768, STM32F1 and STM32F4 platforms." -#endif - #if ENABLED(DELTA) && (ENABLED(STEALTHCHOP_XY) != ENABLED(STEALTHCHOP_Z)) #error "STEALTHCHOP_XY and STEALTHCHOP_Z must be the same on DELTA." #endif