|
|
|
@ -76,7 +76,18 @@ typedef struct {
|
|
|
|
|
uint8_t hstrt;
|
|
|
|
|
} chopper_timing_t;
|
|
|
|
|
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing = CHOPPER_TIMING;
|
|
|
|
|
#ifndef CHOPPER_TIMING_X
|
|
|
|
|
#define CHOPPER_TIMING_X CHOPPER_TIMING
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef CHOPPER_TIMING_Y
|
|
|
|
|
#define CHOPPER_TIMING_Y CHOPPER_TIMING
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef CHOPPER_TIMING_Z
|
|
|
|
|
#define CHOPPER_TIMING_Z CHOPPER_TIMING
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef CHOPPER_TIMING_E
|
|
|
|
|
#define CHOPPER_TIMING_E CHOPPER_TIMING
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAS_TMC220x
|
|
|
|
|
void tmc_serial_begin();
|
|
|
|
@ -90,9 +101,10 @@ void reset_trinamic_drivers();
|
|
|
|
|
// X Stepper
|
|
|
|
|
#if AXIS_IS_TMC(X)
|
|
|
|
|
extern TMC_CLASS(X, X) stepperX;
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_X = CHOPPER_TIMING_X;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define X_ENABLE_INIT() NOOP
|
|
|
|
|
#define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing_X.toff : 0)
|
|
|
|
|
#define X_ENABLE_READ() stepperX.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(X)
|
|
|
|
@ -103,9 +115,10 @@ void reset_trinamic_drivers();
|
|
|
|
|
// Y Stepper
|
|
|
|
|
#if AXIS_IS_TMC(Y)
|
|
|
|
|
extern TMC_CLASS(Y, Y) stepperY;
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_Y = CHOPPER_TIMING_Y;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define Y_ENABLE_INIT() NOOP
|
|
|
|
|
#define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y.toff : 0)
|
|
|
|
|
#define Y_ENABLE_READ() stepperY.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(Y)
|
|
|
|
@ -116,9 +129,10 @@ void reset_trinamic_drivers();
|
|
|
|
|
// Z Stepper
|
|
|
|
|
#if AXIS_IS_TMC(Z)
|
|
|
|
|
extern TMC_CLASS(Z, Z) stepperZ;
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_Z = CHOPPER_TIMING_Z;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define Z_ENABLE_INIT() NOOP
|
|
|
|
|
#define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z.toff : 0)
|
|
|
|
|
#define Z_ENABLE_READ() stepperZ.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(Z)
|
|
|
|
@ -129,9 +143,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// X2 Stepper
|
|
|
|
|
#if HAS_X2_ENABLE && AXIS_IS_TMC(X2)
|
|
|
|
|
extern TMC_CLASS(X2, X) stepperX2;
|
|
|
|
|
#ifndef CHOPPER_TIMING_X2
|
|
|
|
|
#define CHOPPER_TIMING_X2 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_X2 = CHOPPER_TIMING_X2;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define X2_ENABLE_INIT() NOOP
|
|
|
|
|
#define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing_X2.toff : 0)
|
|
|
|
|
#define X2_ENABLE_READ() stepperX2.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(X2)
|
|
|
|
@ -142,9 +160,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// Y2 Stepper
|
|
|
|
|
#if HAS_Y2_ENABLE && AXIS_IS_TMC(Y2)
|
|
|
|
|
extern TMC_CLASS(Y2, Y) stepperY2;
|
|
|
|
|
#ifndef CHOPPER_TIMING_Y2
|
|
|
|
|
#define CHOPPER_TIMING_Y2 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_Y2 = CHOPPER_TIMING_Y2;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define Y2_ENABLE_INIT() NOOP
|
|
|
|
|
#define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y2.toff : 0)
|
|
|
|
|
#define Y2_ENABLE_READ() stepperY2.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(Y2)
|
|
|
|
@ -155,9 +177,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// Z2 Stepper
|
|
|
|
|
#if HAS_Z2_ENABLE && AXIS_IS_TMC(Z2)
|
|
|
|
|
extern TMC_CLASS(Z2, Z) stepperZ2;
|
|
|
|
|
#ifndef CHOPPER_TIMING_Z2
|
|
|
|
|
#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_Z2 = CHOPPER_TIMING_Z2;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)
|
|
|
|
|
#define Z2_ENABLE_INIT() NOOP
|
|
|
|
|
#define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z2.toff : 0)
|
|
|
|
|
#define Z2_ENABLE_READ() stepperZ2.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(Z2)
|
|
|
|
@ -168,9 +194,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// Z3 Stepper
|
|
|
|
|
#if HAS_Z3_ENABLE && AXIS_IS_TMC(Z3)
|
|
|
|
|
extern TMC_CLASS(Z3, Z) stepperZ3;
|
|
|
|
|
#ifndef CHOPPER_TIMING_Z3
|
|
|
|
|
#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_Z3 = CHOPPER_TIMING_Z3;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define Z3_ENABLE_INIT() NOOP
|
|
|
|
|
#define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z3.toff : 0)
|
|
|
|
|
#define Z3_ENABLE_READ() stepperZ3.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(Z3)
|
|
|
|
@ -181,9 +211,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// Z4 Stepper
|
|
|
|
|
#if HAS_Z4_ENABLE && AXIS_IS_TMC(Z4)
|
|
|
|
|
extern TMC_CLASS(Z4, Z) stepperZ4;
|
|
|
|
|
#ifndef CHOPPER_TIMING_Z4
|
|
|
|
|
#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_Z4 = CHOPPER_TIMING_Z4;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE)
|
|
|
|
|
#define Z4_ENABLE_INIT() NOOP
|
|
|
|
|
#define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z4.toff : 0)
|
|
|
|
|
#define Z4_ENABLE_READ() stepperZ4.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(Z4)
|
|
|
|
@ -194,9 +228,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E0 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E0)
|
|
|
|
|
extern TMC_CLASS_E(0) stepperE0;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E0
|
|
|
|
|
#define CHOPPER_TIMING_E0 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E0 = CHOPPER_TIMING_E0;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)
|
|
|
|
|
#define E0_ENABLE_INIT() NOOP
|
|
|
|
|
#define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing_E0.toff : 0)
|
|
|
|
|
#define E0_ENABLE_READ() stepperE0.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E0)
|
|
|
|
@ -207,9 +245,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E1 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E1)
|
|
|
|
|
extern TMC_CLASS_E(1) stepperE1;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E1
|
|
|
|
|
#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E1 = CHOPPER_TIMING_E1;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)
|
|
|
|
|
#define E1_ENABLE_INIT() NOOP
|
|
|
|
|
#define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing_E1.toff : 0)
|
|
|
|
|
#define E1_ENABLE_READ() stepperE1.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E1)
|
|
|
|
@ -220,9 +262,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E2 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E2)
|
|
|
|
|
extern TMC_CLASS_E(2) stepperE2;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E2
|
|
|
|
|
#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E2 = CHOPPER_TIMING_E2;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)
|
|
|
|
|
#define E2_ENABLE_INIT() NOOP
|
|
|
|
|
#define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing_E2.toff : 0)
|
|
|
|
|
#define E2_ENABLE_READ() stepperE2.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E2)
|
|
|
|
@ -233,9 +279,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E3 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E3)
|
|
|
|
|
extern TMC_CLASS_E(3) stepperE3;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E3
|
|
|
|
|
#define CHOPPER_TIMING_E3 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E3 = CHOPPER_TIMING_E3;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)
|
|
|
|
|
#define E3_ENABLE_INIT() NOOP
|
|
|
|
|
#define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing_E3.toff : 0)
|
|
|
|
|
#define E3_ENABLE_READ() stepperE3.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E3)
|
|
|
|
@ -246,9 +296,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E4 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E4)
|
|
|
|
|
extern TMC_CLASS_E(4) stepperE4;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E4
|
|
|
|
|
#define CHOPPER_TIMING_E4 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E4 = CHOPPER_TIMING_E4;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)
|
|
|
|
|
#define E4_ENABLE_INIT() NOOP
|
|
|
|
|
#define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing_E4.toff : 0)
|
|
|
|
|
#define E4_ENABLE_READ() stepperE4.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E4)
|
|
|
|
@ -259,9 +313,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E5 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E5)
|
|
|
|
|
extern TMC_CLASS_E(5) stepperE5;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E5
|
|
|
|
|
#define CHOPPER_TIMING_E5 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E5 = CHOPPER_TIMING_E5;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)
|
|
|
|
|
#define E5_ENABLE_INIT() NOOP
|
|
|
|
|
#define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing_E5.toff : 0)
|
|
|
|
|
#define E5_ENABLE_READ() stepperE5.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E5)
|
|
|
|
@ -272,9 +330,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E6 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E6)
|
|
|
|
|
extern TMC_CLASS_E(6) stepperE6;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E6
|
|
|
|
|
#define CHOPPER_TIMING_E6 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E6 = CHOPPER_TIMING_E6;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)
|
|
|
|
|
#define E6_ENABLE_INIT() NOOP
|
|
|
|
|
#define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing_E6.toff : 0)
|
|
|
|
|
#define E6_ENABLE_READ() stepperE6.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E6)
|
|
|
|
@ -285,9 +347,13 @@ void reset_trinamic_drivers();
|
|
|
|
|
// E7 Stepper
|
|
|
|
|
#if AXIS_IS_TMC(E7)
|
|
|
|
|
extern TMC_CLASS_E(7) stepperE7;
|
|
|
|
|
#ifndef CHOPPER_TIMING_E7
|
|
|
|
|
#define CHOPPER_TIMING_E7 CHOPPER_TIMING_E
|
|
|
|
|
#endif
|
|
|
|
|
static constexpr chopper_timing_t chopper_timing_E7 = CHOPPER_TIMING_E7;
|
|
|
|
|
#if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)
|
|
|
|
|
#define E7_ENABLE_INIT() NOOP
|
|
|
|
|
#define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
|
|
|
|
|
#define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing_E7.toff : 0)
|
|
|
|
|
#define E7_ENABLE_READ() stepperE7.isEnabled()
|
|
|
|
|
#endif
|
|
|
|
|
#if AXIS_HAS_SQUARE_WAVE(E7)
|
|
|
|
|