Refactor TMC-related macros and sanity checks (#16384)

2.0.x
Jason Smith 5 years ago committed by Scott Lahteine
parent ac32ed74b4
commit 4e1f2f89f6

@ -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

@ -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

@ -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

@ -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

@ -28,13 +28,7 @@
#include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h"
#if (__cplusplus == 201703L) && defined(__has_include)
#define HAS_SWSERIAL __has_include(<SoftwareSerial.h>)
#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
}

@ -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

@ -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

@ -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

@ -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

@ -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
//

@ -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

@ -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

Loading…
Cancel
Save