Browse Source

Fix extra TMC serial begin calls (#17351)

vanilla_fb_2.0.x
Simon Jouet 5 years ago
committed by GitHub
parent
commit
192c7c27b9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      Marlin/src/module/stepper/trinamic.cpp

43
Marlin/src/module/stepper/trinamic.cpp

@ -331,115 +331,126 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#endif #endif
#endif #endif
enum TMCAxis : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7, TOTAL };
void tmc_serial_begin() { void tmc_serial_begin() {
struct {
const void *ptr[TMCAxis::TOTAL];
bool began(const TMCAxis a, const void * const p) {
LOOP_L_N(i, a) if (p == ptr[i]) return true;
ptr[a] = p; return false;
};
} sp_helper;
#define HW_SERIAL_BEGIN(A) do{ if (sp_helper.began(TMCAxis::A, &A##_HARDWARE_SERIAL)) \
A##_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); }while(0)
#if AXIS_HAS_UART(X) #if AXIS_HAS_UART(X)
#ifdef X_HARDWARE_SERIAL #ifdef X_HARDWARE_SERIAL
X_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(X);
#else #else
stepperX.beginSerial(TMC_BAUD_RATE); stepperX.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(X2) #if AXIS_HAS_UART(X2)
#ifdef X2_HARDWARE_SERIAL #ifdef X2_HARDWARE_SERIAL
X2_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(X2);
#else #else
stepperX2.beginSerial(TMC_BAUD_RATE); stepperX2.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(Y) #if AXIS_HAS_UART(Y)
#ifdef Y_HARDWARE_SERIAL #ifdef Y_HARDWARE_SERIAL
Y_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(Y);
#else #else
stepperY.beginSerial(TMC_BAUD_RATE); stepperY.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(Y2) #if AXIS_HAS_UART(Y2)
#ifdef Y2_HARDWARE_SERIAL #ifdef Y2_HARDWARE_SERIAL
Y2_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(Y2);
#else #else
stepperY2.beginSerial(TMC_BAUD_RATE); stepperY2.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(Z) #if AXIS_HAS_UART(Z)
#ifdef Z_HARDWARE_SERIAL #ifdef Z_HARDWARE_SERIAL
Z_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(Z);
#else #else
stepperZ.beginSerial(TMC_BAUD_RATE); stepperZ.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(Z2) #if AXIS_HAS_UART(Z2)
#ifdef Z2_HARDWARE_SERIAL #ifdef Z2_HARDWARE_SERIAL
Z2_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(Z2);
#else #else
stepperZ2.beginSerial(TMC_BAUD_RATE); stepperZ2.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(Z3) #if AXIS_HAS_UART(Z3)
#ifdef Z3_HARDWARE_SERIAL #ifdef Z3_HARDWARE_SERIAL
Z3_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(Z3);
#else #else
stepperZ3.beginSerial(TMC_BAUD_RATE); stepperZ3.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(Z4) #if AXIS_HAS_UART(Z4)
#ifdef Z4_HARDWARE_SERIAL #ifdef Z4_HARDWARE_SERIAL
Z4_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(Z4);
#else #else
stepperZ4.beginSerial(TMC_BAUD_RATE); stepperZ4.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E0) #if AXIS_HAS_UART(E0)
#ifdef E0_HARDWARE_SERIAL #ifdef E0_HARDWARE_SERIAL
E0_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E0);
#else #else
stepperE0.beginSerial(TMC_BAUD_RATE); stepperE0.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E1) #if AXIS_HAS_UART(E1)
#ifdef E1_HARDWARE_SERIAL #ifdef E1_HARDWARE_SERIAL
E1_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E1);
#else #else
stepperE1.beginSerial(TMC_BAUD_RATE); stepperE1.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E2) #if AXIS_HAS_UART(E2)
#ifdef E2_HARDWARE_SERIAL #ifdef E2_HARDWARE_SERIAL
E2_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E2);
#else #else
stepperE2.beginSerial(TMC_BAUD_RATE); stepperE2.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E3) #if AXIS_HAS_UART(E3)
#ifdef E3_HARDWARE_SERIAL #ifdef E3_HARDWARE_SERIAL
E3_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E3);
#else #else
stepperE3.beginSerial(TMC_BAUD_RATE); stepperE3.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E4) #if AXIS_HAS_UART(E4)
#ifdef E4_HARDWARE_SERIAL #ifdef E4_HARDWARE_SERIAL
E4_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E4);
#else #else
stepperE4.beginSerial(TMC_BAUD_RATE); stepperE4.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E5) #if AXIS_HAS_UART(E5)
#ifdef E5_HARDWARE_SERIAL #ifdef E5_HARDWARE_SERIAL
E5_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E5);
#else #else
stepperE5.beginSerial(TMC_BAUD_RATE); stepperE5.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E6) #if AXIS_HAS_UART(E6)
#ifdef E6_HARDWARE_SERIAL #ifdef E6_HARDWARE_SERIAL
E6_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E6);
#else #else
stepperE6.beginSerial(TMC_BAUD_RATE); stepperE6.beginSerial(TMC_BAUD_RATE);
#endif #endif
#endif #endif
#if AXIS_HAS_UART(E7) #if AXIS_HAS_UART(E7)
#ifdef E7_HARDWARE_SERIAL #ifdef E7_HARDWARE_SERIAL
E7_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); HW_SERIAL_BEGIN(E7);
#else #else
stepperE7.beginSerial(TMC_BAUD_RATE); stepperE7.beginSerial(TMC_BAUD_RATE);
#endif #endif

Loading…
Cancel
Save