🐛 Fix TMC26X CS pins init (#23778)

This commit is contained in:
ellensp 2022-02-22 16:16:57 +13:00 committed by GitHub
parent 92f85e877d
commit f03c367739
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 68 deletions

View file

@ -145,7 +145,7 @@
#include "feature/encoder_i2c.h"
#endif
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF)
#include "feature/tmc_util.h"
#endif

View file

@ -128,7 +128,7 @@
// Test for a driver that uses SPI - this allows checking whether a _CS_ pin
// is considered sensitive
#define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|| AXIS_DRIVER_TYPE(A,TMC26X) || AXIS_DRIVER_TYPE(A,TMC2660) \
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
#define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) )

View file

@ -1178,69 +1178,6 @@
#endif // USE_SENSORLESS
#if HAS_TMC_SPI
#define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH)
void tmc_init_cs_pins() {
#if AXIS_HAS_SPI(X)
SET_CS_PIN(X);
#endif
#if AXIS_HAS_SPI(Y)
SET_CS_PIN(Y);
#endif
#if AXIS_HAS_SPI(Z)
SET_CS_PIN(Z);
#endif
#if AXIS_HAS_SPI(X2)
SET_CS_PIN(X2);
#endif
#if AXIS_HAS_SPI(Y2)
SET_CS_PIN(Y2);
#endif
#if AXIS_HAS_SPI(Z2)
SET_CS_PIN(Z2);
#endif
#if AXIS_HAS_SPI(Z3)
SET_CS_PIN(Z3);
#endif
#if AXIS_HAS_SPI(Z4)
SET_CS_PIN(Z4);
#endif
#if AXIS_HAS_SPI(I)
SET_CS_PIN(I);
#endif
#if AXIS_HAS_SPI(J)
SET_CS_PIN(J);
#endif
#if AXIS_HAS_SPI(K)
SET_CS_PIN(K);
#endif
#if AXIS_HAS_SPI(E0)
SET_CS_PIN(E0);
#endif
#if AXIS_HAS_SPI(E1)
SET_CS_PIN(E1);
#endif
#if AXIS_HAS_SPI(E2)
SET_CS_PIN(E2);
#endif
#if AXIS_HAS_SPI(E3)
SET_CS_PIN(E3);
#endif
#if AXIS_HAS_SPI(E4)
SET_CS_PIN(E4);
#endif
#if AXIS_HAS_SPI(E5)
SET_CS_PIN(E5);
#endif
#if AXIS_HAS_SPI(E6)
SET_CS_PIN(E6);
#endif
#if AXIS_HAS_SPI(E7)
SET_CS_PIN(E7);
#endif
}
#endif // HAS_TMC_SPI
template<typename TMC>
static bool test_connection(TMC &st) {
SERIAL_ECHOPGM("Testing ");
@ -1339,3 +1276,66 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) {
}
#endif // HAS_TRINAMIC_CONFIG
#if HAS_TMC_SPI
#define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH)
void tmc_init_cs_pins() {
#if AXIS_HAS_SPI(X)
SET_CS_PIN(X);
#endif
#if AXIS_HAS_SPI(Y)
SET_CS_PIN(Y);
#endif
#if AXIS_HAS_SPI(Z)
SET_CS_PIN(Z);
#endif
#if AXIS_HAS_SPI(X2)
SET_CS_PIN(X2);
#endif
#if AXIS_HAS_SPI(Y2)
SET_CS_PIN(Y2);
#endif
#if AXIS_HAS_SPI(Z2)
SET_CS_PIN(Z2);
#endif
#if AXIS_HAS_SPI(Z3)
SET_CS_PIN(Z3);
#endif
#if AXIS_HAS_SPI(Z4)
SET_CS_PIN(Z4);
#endif
#if AXIS_HAS_SPI(I)
SET_CS_PIN(I);
#endif
#if AXIS_HAS_SPI(J)
SET_CS_PIN(J);
#endif
#if AXIS_HAS_SPI(K)
SET_CS_PIN(K);
#endif
#if AXIS_HAS_SPI(E0)
SET_CS_PIN(E0);
#endif
#if AXIS_HAS_SPI(E1)
SET_CS_PIN(E1);
#endif
#if AXIS_HAS_SPI(E2)
SET_CS_PIN(E2);
#endif
#if AXIS_HAS_SPI(E3)
SET_CS_PIN(E3);
#endif
#if AXIS_HAS_SPI(E4)
SET_CS_PIN(E4);
#endif
#if AXIS_HAS_SPI(E5)
SET_CS_PIN(E5);
#endif
#if AXIS_HAS_SPI(E6)
SET_CS_PIN(E6);
#endif
#if AXIS_HAS_SPI(E7)
SET_CS_PIN(E7);
#endif
}
#endif // HAS_TMC_SPI

View file

@ -382,8 +382,8 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true));
#endif // USE_SENSORLESS
#endif // HAS_TRINAMIC_CONFIG
#if HAS_TMC_SPI
void tmc_init_cs_pins();
#endif
#endif // HAS_TRINAMIC_CONFIG

View file

@ -18,7 +18,8 @@ POSTMORTEM_DEBUGGING = src_filter=+<src/HAL/shared/cpu_excepti
build_flags=-funwind-tables
MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip
HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.3
src_filter=+<src/feature/tmc_util.cpp> +<src/module/stepper/trinamic.cpp> +<src/gcode/feature/trinamic/M122.cpp> +<src/gcode/feature/trinamic/M906.cpp> +<src/gcode/feature/trinamic/M911-M914.cpp> +<src/gcode/feature/trinamic/M919.cpp>
+<src/module/stepper/trinamic.cpp> +<src/gcode/feature/trinamic/M122.cpp> +<src/gcode/feature/trinamic/M906.cpp> +<src/gcode/feature/trinamic/M911-M914.cpp> +<src/gcode/feature/trinamic/M919.cpp>
HAS_T(RINAMIC_CONFIG|MC_SPI) = src_filter=+<src/feature/tmc_util.cpp>
HAS_STEALTHCHOP = src_filter=+<src/gcode/feature/trinamic/M569.cpp>
SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster