|
@@ -117,16 +117,12 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
117
|
117
|
#endif
|
118
|
118
|
|
119
|
119
|
#ifndef TMC_BAUD_RATE
|
120
|
|
- #if HAS_TMC_SW_SERIAL
|
121
|
|
- // Reduce baud rate for boards not already overriding TMC_BAUD_RATE for software serial.
|
122
|
|
- // Testing has shown that 115200 is not 100% reliable on AVR platforms, occasionally
|
123
|
|
- // failing to read status properly. 32-bit platforms typically define an even lower
|
124
|
|
- // TMC_BAUD_RATE, due to differences in how SoftwareSerial libraries work on different
|
125
|
|
- // platforms.
|
126
|
|
- #define TMC_BAUD_RATE 57600
|
127
|
|
- #else
|
128
|
|
- #define TMC_BAUD_RATE 115200
|
129
|
|
- #endif
|
|
120
|
+ // Reduce baud rate for boards not already overriding TMC_BAUD_RATE for software serial.
|
|
121
|
+ // Testing has shown that 115200 is not 100% reliable on AVR platforms, occasionally
|
|
122
|
+ // failing to read status properly. 32-bit platforms typically define an even lower
|
|
123
|
+ // TMC_BAUD_RATE, due to differences in how SoftwareSerial libraries work on different
|
|
124
|
+ // platforms.
|
|
125
|
+ #define TMC_BAUD_RATE TERN(HAS_TMC_SW_SERIAL, 57600, 115200)
|
130
|
126
|
#endif
|
131
|
127
|
|
132
|
128
|
#if HAS_DRIVER(TMC2130)
|
|
@@ -158,11 +154,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
158
|
154
|
pwmconf.pwm_ampl = 180;
|
159
|
155
|
st.PWMCONF(pwmconf.sr);
|
160
|
156
|
|
161
|
|
- #if ENABLED(HYBRID_THRESHOLD)
|
162
|
|
- st.set_pwm_thrs(hyb_thrs);
|
163
|
|
- #else
|
164
|
|
- UNUSED(hyb_thrs);
|
165
|
|
- #endif
|
|
157
|
+ TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
166
|
158
|
|
167
|
159
|
st.GSTAT(); // Clear GSTAT
|
168
|
160
|
}
|
|
@@ -200,11 +192,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
200
|
192
|
pwmconf.pwm_ofs = 36;
|
201
|
193
|
st.PWMCONF(pwmconf.sr);
|
202
|
194
|
|
203
|
|
- #if ENABLED(HYBRID_THRESHOLD)
|
204
|
|
- st.set_pwm_thrs(hyb_thrs);
|
205
|
|
- #else
|
206
|
|
- UNUSED(hyb_thrs);
|
207
|
|
- #endif
|
|
195
|
+ TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
208
|
196
|
|
209
|
197
|
st.GSTAT(); // Clear GSTAT
|
210
|
198
|
}
|
|
@@ -489,11 +477,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
489
|
477
|
pwmconf.pwm_ofs = 36;
|
490
|
478
|
st.PWMCONF(pwmconf.sr);
|
491
|
479
|
|
492
|
|
- #if ENABLED(HYBRID_THRESHOLD)
|
493
|
|
- st.set_pwm_thrs(hyb_thrs);
|
494
|
|
- #else
|
495
|
|
- UNUSED(hyb_thrs);
|
496
|
|
- #endif
|
|
480
|
+ TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
497
|
481
|
|
498
|
482
|
st.GSTAT(0b111); // Clear
|
499
|
483
|
delay(200);
|
|
@@ -535,11 +519,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
535
|
519
|
pwmconf.pwm_ofs = 36;
|
536
|
520
|
st.PWMCONF(pwmconf.sr);
|
537
|
521
|
|
538
|
|
- #if ENABLED(HYBRID_THRESHOLD)
|
539
|
|
- st.set_pwm_thrs(hyb_thrs);
|
540
|
|
- #else
|
541
|
|
- UNUSED(hyb_thrs);
|
542
|
|
- #endif
|
|
522
|
+ TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
543
|
523
|
|
544
|
524
|
st.GSTAT(0b111); // Clear
|
545
|
525
|
delay(200);
|
|
@@ -597,11 +577,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
597
|
577
|
pwmconf.pwm_ampl = 180;
|
598
|
578
|
st.PWMCONF(pwmconf.sr);
|
599
|
579
|
|
600
|
|
- #if ENABLED(HYBRID_THRESHOLD)
|
601
|
|
- st.set_pwm_thrs(hyb_thrs);
|
602
|
|
- #else
|
603
|
|
- UNUSED(hyb_thrs);
|
604
|
|
- #endif
|
|
580
|
+ TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
605
|
581
|
|
606
|
582
|
st.GSTAT(); // Clear GSTAT
|
607
|
583
|
}
|
|
@@ -700,25 +676,7 @@ void restore_trinamic_drivers() {
|
700
|
676
|
}
|
701
|
677
|
|
702
|
678
|
void reset_trinamic_drivers() {
|
703
|
|
- static constexpr bool stealthchop_by_axis[] = {
|
704
|
|
- #if ENABLED(STEALTHCHOP_XY)
|
705
|
|
- true
|
706
|
|
- #else
|
707
|
|
- false
|
708
|
|
- #endif
|
709
|
|
- ,
|
710
|
|
- #if ENABLED(STEALTHCHOP_Z)
|
711
|
|
- true
|
712
|
|
- #else
|
713
|
|
- false
|
714
|
|
- #endif
|
715
|
|
- ,
|
716
|
|
- #if ENABLED(STEALTHCHOP_E)
|
717
|
|
- true
|
718
|
|
- #else
|
719
|
|
- false
|
720
|
|
- #endif
|
721
|
|
- };
|
|
679
|
+ static constexpr bool stealthchop_by_axis[] = { ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_Z), ENABLED(STEALTHCHOP_E) };
|
722
|
680
|
|
723
|
681
|
#if AXIS_IS_TMC(X)
|
724
|
682
|
TMC_INIT(X, STEALTH_AXIS_XY);
|
|
@@ -770,14 +728,30 @@ void reset_trinamic_drivers() {
|
770
|
728
|
#endif
|
771
|
729
|
|
772
|
730
|
#if USE_SENSORLESS
|
773
|
|
- TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY));
|
774
|
|
- TERN_(X2_SENSORLESS, stepperX2.homing_threshold(X2_STALL_SENSITIVITY));
|
775
|
|
- TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY));
|
776
|
|
- TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(Y2_STALL_SENSITIVITY));
|
777
|
|
- TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY));
|
778
|
|
- TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(Z2_STALL_SENSITIVITY));
|
779
|
|
- TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(Z3_STALL_SENSITIVITY));
|
780
|
|
- TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(Z4_STALL_SENSITIVITY));
|
|
731
|
+ #if X_SENSORLESS
|
|
732
|
+ stepperX.homing_threshold(X_STALL_SENSITIVITY);
|
|
733
|
+ #if AXIS_HAS_STALLGUARD(X2)
|
|
734
|
+ stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY));
|
|
735
|
+ #endif
|
|
736
|
+ #endif
|
|
737
|
+ #if Y_SENSORLESS
|
|
738
|
+ stepperY.homing_threshold(Y_STALL_SENSITIVITY);
|
|
739
|
+ #if AXIS_HAS_STALLGUARD(Y2)
|
|
740
|
+ stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY));
|
|
741
|
+ #endif
|
|
742
|
+ #endif
|
|
743
|
+ #if Z_SENSORLESS
|
|
744
|
+ stepperZ.homing_threshold(Z_STALL_SENSITIVITY);
|
|
745
|
+ #if AXIS_HAS_STALLGUARD(Z2)
|
|
746
|
+ stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY));
|
|
747
|
+ #endif
|
|
748
|
+ #if AXIS_HAS_STALLGUARD(Z3)
|
|
749
|
+ stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY));
|
|
750
|
+ #endif
|
|
751
|
+ #if AXIS_HAS_STALLGUARD(Z4)
|
|
752
|
+ stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY));
|
|
753
|
+ #endif
|
|
754
|
+ #endif
|
781
|
755
|
#endif
|
782
|
756
|
|
783
|
757
|
#ifdef TMC_ADV
|