소스 검색

Distinct Chopper Timing settings (#19781)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Jago Strong-Wright 4 년 전
부모
커밋
c2802d35bb
No account linked to committer's email address
3개의 변경된 파일135개의 추가작업 그리고 53개의 파일을 삭제
  1. 18
    2
      Marlin/Configuration_adv.h
  2. 34
    34
      Marlin/src/module/stepper/trinamic.cpp
  3. 83
    17
      Marlin/src/module/stepper/trinamic.h

+ 18
- 2
Marlin/Configuration_adv.h 파일 보기

2471
    * CHOPPER_PRUSAMK3_24V // Imported parameters from the official Průša firmware for MK3 (24V)
2471
    * CHOPPER_PRUSAMK3_24V // Imported parameters from the official Průša firmware for MK3 (24V)
2472
    * CHOPPER_MARLIN_119   // Old defaults from Marlin v1.1.9
2472
    * CHOPPER_MARLIN_119   // Old defaults from Marlin v1.1.9
2473
    *
2473
    *
2474
-   * Define you own with
2474
+   * Define your own with:
2475
    * { <off_time[1..15]>, <hysteresis_end[-3..12]>, hysteresis_start[1..8] }
2475
    * { <off_time[1..15]>, <hysteresis_end[-3..12]>, hysteresis_start[1..8] }
2476
    */
2476
    */
2477
-  #define CHOPPER_TIMING CHOPPER_DEFAULT_12V
2477
+  #define CHOPPER_TIMING CHOPPER_DEFAULT_12V        // All axes (override below)
2478
+  //#define CHOPPER_TIMING_X  CHOPPER_DEFAULT_12V   // For X Axes (override below)
2479
+  //#define CHOPPER_TIMING_X2 CHOPPER_DEFAULT_12V
2480
+  //#define CHOPPER_TIMING_Y  CHOPPER_DEFAULT_12V   // For Y Axes (override below)
2481
+  //#define CHOPPER_TIMING_Y2 CHOPPER_DEFAULT_12V
2482
+  //#define CHOPPER_TIMING_Z  CHOPPER_DEFAULT_12V   // For Z Axes (override below)
2483
+  //#define CHOPPER_TIMING_Z2 CHOPPER_DEFAULT_12V
2484
+  //#define CHOPPER_TIMING_Z3 CHOPPER_DEFAULT_12V
2485
+  //#define CHOPPER_TIMING_Z4 CHOPPER_DEFAULT_12V
2486
+  //#define CHOPPER_TIMING_E  CHOPPER_DEFAULT_12V   // For Extruders (override below)
2487
+  //#define CHOPPER_TIMING_E1 CHOPPER_DEFAULT_12V
2488
+  //#define CHOPPER_TIMING_E2 CHOPPER_DEFAULT_12V
2489
+  //#define CHOPPER_TIMING_E3 CHOPPER_DEFAULT_12V
2490
+  //#define CHOPPER_TIMING_E4 CHOPPER_DEFAULT_12V
2491
+  //#define CHOPPER_TIMING_E5 CHOPPER_DEFAULT_12V
2492
+  //#define CHOPPER_TIMING_E6 CHOPPER_DEFAULT_12V
2493
+  //#define CHOPPER_TIMING_E7 CHOPPER_DEFAULT_12V
2478
 
2494
 
2479
   /**
2495
   /**
2480
    * Monitor Trinamic drivers
2496
    * Monitor Trinamic drivers

+ 34
- 34
Marlin/src/module/stepper/trinamic.cpp 파일 보기

36
 #include <SPI.h>
36
 #include <SPI.h>
37
 
37
 
38
 enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
38
 enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
39
-#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX])
39
+#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST)
40
 
40
 
41
 //   IC = TMC model number
41
 //   IC = TMC model number
42
 //   ST = Stepper object letter
42
 //   ST = Stepper object letter
131
 
131
 
132
 #if HAS_DRIVER(TMC2130)
132
 #if HAS_DRIVER(TMC2130)
133
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
133
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
134
-  void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth) {
134
+  void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
135
     st.begin();
135
     st.begin();
136
 
136
 
137
     CHOPCONF_t chopconf{0};
137
     CHOPCONF_t chopconf{0};
138
-    chopconf.tbl = 1;
139
-    chopconf.toff = chopper_timing.toff;
138
+    chopconf.tbl = 0b01;
139
+    chopconf.toff = chop_init.toff;
140
     chopconf.intpol = INTERPOLATE;
140
     chopconf.intpol = INTERPOLATE;
141
-    chopconf.hend = chopper_timing.hend + 3;
142
-    chopconf.hstrt = chopper_timing.hstrt - 1;
141
+    chopconf.hend = chop_init.hend + 3;
142
+    chopconf.hstrt = chop_init.hstrt - 1;
143
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
143
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
144
     st.CHOPCONF(chopconf.sr);
144
     st.CHOPCONF(chopconf.sr);
145
 
145
 
166
 
166
 
167
 #if HAS_DRIVER(TMC2160)
167
 #if HAS_DRIVER(TMC2160)
168
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
168
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
169
-  void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth) {
169
+  void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
170
     st.begin();
170
     st.begin();
171
 
171
 
172
     CHOPCONF_t chopconf{0};
172
     CHOPCONF_t chopconf{0};
173
-    chopconf.tbl = 1;
174
-    chopconf.toff = chopper_timing.toff;
173
+    chopconf.tbl = 0b01;
174
+    chopconf.toff = chop_init.toff;
175
     chopconf.intpol = INTERPOLATE;
175
     chopconf.intpol = INTERPOLATE;
176
-    chopconf.hend = chopper_timing.hend + 3;
177
-    chopconf.hstrt = chopper_timing.hstrt - 1;
176
+    chopconf.hend = chop_init.hend + 3;
177
+    chopconf.hstrt = chop_init.hstrt - 1;
178
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
178
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
179
     st.CHOPCONF(chopconf.sr);
179
     st.CHOPCONF(chopconf.sr);
180
 
180
 
484
 
484
 
485
 #if HAS_DRIVER(TMC2208)
485
 #if HAS_DRIVER(TMC2208)
486
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
486
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
487
-  void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth) {
487
+  void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
488
     TMC2208_n::GCONF_t gconf{0};
488
     TMC2208_n::GCONF_t gconf{0};
489
     gconf.pdn_disable = true; // Use UART
489
     gconf.pdn_disable = true; // Use UART
490
     gconf.mstep_reg_select = true; // Select microsteps with UART
490
     gconf.mstep_reg_select = true; // Select microsteps with UART
495
 
495
 
496
     TMC2208_n::CHOPCONF_t chopconf{0};
496
     TMC2208_n::CHOPCONF_t chopconf{0};
497
     chopconf.tbl = 0b01; // blank_time = 24
497
     chopconf.tbl = 0b01; // blank_time = 24
498
-    chopconf.toff = chopper_timing.toff;
498
+    chopconf.toff = chop_init.toff;
499
     chopconf.intpol = INTERPOLATE;
499
     chopconf.intpol = INTERPOLATE;
500
-    chopconf.hend = chopper_timing.hend + 3;
501
-    chopconf.hstrt = chopper_timing.hstrt - 1;
500
+    chopconf.hend = chop_init.hend + 3;
501
+    chopconf.hstrt = chop_init.hstrt - 1;
502
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
502
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
503
     st.CHOPCONF(chopconf.sr);
503
     st.CHOPCONF(chopconf.sr);
504
 
504
 
526
 
526
 
527
 #if HAS_DRIVER(TMC2209)
527
 #if HAS_DRIVER(TMC2209)
528
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
528
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
529
-  void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth) {
529
+  void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
530
     TMC2208_n::GCONF_t gconf{0};
530
     TMC2208_n::GCONF_t gconf{0};
531
     gconf.pdn_disable = true; // Use UART
531
     gconf.pdn_disable = true; // Use UART
532
     gconf.mstep_reg_select = true; // Select microsteps with UART
532
     gconf.mstep_reg_select = true; // Select microsteps with UART
537
 
537
 
538
     TMC2208_n::CHOPCONF_t chopconf{0};
538
     TMC2208_n::CHOPCONF_t chopconf{0};
539
     chopconf.tbl = 0b01; // blank_time = 24
539
     chopconf.tbl = 0b01; // blank_time = 24
540
-    chopconf.toff = chopper_timing.toff;
540
+    chopconf.toff = chop_init.toff;
541
     chopconf.intpol = INTERPOLATE;
541
     chopconf.intpol = INTERPOLATE;
542
-    chopconf.hend = chopper_timing.hend + 3;
543
-    chopconf.hstrt = chopper_timing.hstrt - 1;
542
+    chopconf.hend = chop_init.hend + 3;
543
+    chopconf.hstrt = chop_init.hstrt - 1;
544
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
544
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
545
     st.CHOPCONF(chopconf.sr);
545
     st.CHOPCONF(chopconf.sr);
546
 
546
 
568
 
568
 
569
 #if HAS_DRIVER(TMC2660)
569
 #if HAS_DRIVER(TMC2660)
570
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
570
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
571
-  void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool) {
571
+  void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init) {
572
     st.begin();
572
     st.begin();
573
 
573
 
574
     TMC2660_n::CHOPCONF_t chopconf{0};
574
     TMC2660_n::CHOPCONF_t chopconf{0};
575
-    chopconf.tbl = 1;
576
-    chopconf.toff = chopper_timing.toff;
577
-    chopconf.hend = chopper_timing.hend + 3;
578
-    chopconf.hstrt = chopper_timing.hstrt - 1;
575
+    chopconf.tbl = 0b01;
576
+    chopconf.toff = chop_init.toff;
577
+    chopconf.hend = chop_init.hend + 3;
578
+    chopconf.hstrt = chop_init.hstrt - 1;
579
     st.CHOPCONF(chopconf.sr);
579
     st.CHOPCONF(chopconf.sr);
580
 
580
 
581
     st.sdoff(0);
581
     st.sdoff(0);
590
 
590
 
591
 #if HAS_DRIVER(TMC5130)
591
 #if HAS_DRIVER(TMC5130)
592
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
592
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
593
-  void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth) {
593
+  void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
594
     st.begin();
594
     st.begin();
595
 
595
 
596
     CHOPCONF_t chopconf{0};
596
     CHOPCONF_t chopconf{0};
597
-    chopconf.tbl = 1;
598
-    chopconf.toff = chopper_timing.toff;
597
+    chopconf.tbl = 0b01;
598
+    chopconf.toff = chop_init.toff;
599
     chopconf.intpol = INTERPOLATE;
599
     chopconf.intpol = INTERPOLATE;
600
-    chopconf.hend = chopper_timing.hend + 3;
601
-    chopconf.hstrt = chopper_timing.hstrt - 1;
600
+    chopconf.hend = chop_init.hend + 3;
601
+    chopconf.hstrt = chop_init.hstrt - 1;
602
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
602
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
603
     st.CHOPCONF(chopconf.sr);
603
     st.CHOPCONF(chopconf.sr);
604
 
604
 
625
 
625
 
626
 #if HAS_DRIVER(TMC5160)
626
 #if HAS_DRIVER(TMC5160)
627
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
627
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
628
-  void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth) {
628
+  void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
629
     st.begin();
629
     st.begin();
630
 
630
 
631
     CHOPCONF_t chopconf{0};
631
     CHOPCONF_t chopconf{0};
632
-    chopconf.tbl = 1;
633
-    chopconf.toff = chopper_timing.toff;
632
+    chopconf.tbl = 0b01;
633
+    chopconf.toff = chop_init.toff;
634
     chopconf.intpol = INTERPOLATE;
634
     chopconf.intpol = INTERPOLATE;
635
-    chopconf.hend = chopper_timing.hend + 3;
636
-    chopconf.hstrt = chopper_timing.hstrt - 1;
635
+    chopconf.hend = chop_init.hend + 3;
636
+    chopconf.hstrt = chop_init.hstrt - 1;
637
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
637
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
638
     st.CHOPCONF(chopconf.sr);
638
     st.CHOPCONF(chopconf.sr);
639
 
639
 

+ 83
- 17
Marlin/src/module/stepper/trinamic.h 파일 보기

76
   uint8_t hstrt;
76
   uint8_t hstrt;
77
 } chopper_timing_t;
77
 } chopper_timing_t;
78
 
78
 
79
-static constexpr chopper_timing_t chopper_timing = CHOPPER_TIMING;
79
+#ifndef CHOPPER_TIMING_X
80
+  #define CHOPPER_TIMING_X CHOPPER_TIMING
81
+#endif
82
+#ifndef CHOPPER_TIMING_Y
83
+  #define CHOPPER_TIMING_Y CHOPPER_TIMING
84
+#endif
85
+#ifndef CHOPPER_TIMING_Z
86
+  #define CHOPPER_TIMING_Z CHOPPER_TIMING
87
+#endif
88
+#ifndef CHOPPER_TIMING_E
89
+  #define CHOPPER_TIMING_E CHOPPER_TIMING
90
+#endif
80
 
91
 
81
 #if HAS_TMC220x
92
 #if HAS_TMC220x
82
   void tmc_serial_begin();
93
   void tmc_serial_begin();
90
 // X Stepper
101
 // X Stepper
91
 #if AXIS_IS_TMC(X)
102
 #if AXIS_IS_TMC(X)
92
   extern TMC_CLASS(X, X) stepperX;
103
   extern TMC_CLASS(X, X) stepperX;
104
+  static constexpr chopper_timing_t chopper_timing_X = CHOPPER_TIMING_X;
93
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
105
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
94
     #define X_ENABLE_INIT() NOOP
106
     #define X_ENABLE_INIT() NOOP
95
-    #define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing.toff : 0)
107
+    #define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing_X.toff : 0)
96
     #define X_ENABLE_READ() stepperX.isEnabled()
108
     #define X_ENABLE_READ() stepperX.isEnabled()
97
   #endif
109
   #endif
98
   #if AXIS_HAS_SQUARE_WAVE(X)
110
   #if AXIS_HAS_SQUARE_WAVE(X)
103
 // Y Stepper
115
 // Y Stepper
104
 #if AXIS_IS_TMC(Y)
116
 #if AXIS_IS_TMC(Y)
105
   extern TMC_CLASS(Y, Y) stepperY;
117
   extern TMC_CLASS(Y, Y) stepperY;
118
+  static constexpr chopper_timing_t chopper_timing_Y = CHOPPER_TIMING_Y;
106
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
119
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
107
     #define Y_ENABLE_INIT() NOOP
120
     #define Y_ENABLE_INIT() NOOP
108
-    #define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing.toff : 0)
121
+    #define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y.toff : 0)
109
     #define Y_ENABLE_READ() stepperY.isEnabled()
122
     #define Y_ENABLE_READ() stepperY.isEnabled()
110
   #endif
123
   #endif
111
   #if AXIS_HAS_SQUARE_WAVE(Y)
124
   #if AXIS_HAS_SQUARE_WAVE(Y)
116
 // Z Stepper
129
 // Z Stepper
117
 #if AXIS_IS_TMC(Z)
130
 #if AXIS_IS_TMC(Z)
118
   extern TMC_CLASS(Z, Z) stepperZ;
131
   extern TMC_CLASS(Z, Z) stepperZ;
132
+  static constexpr chopper_timing_t chopper_timing_Z = CHOPPER_TIMING_Z;
119
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
133
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
120
     #define Z_ENABLE_INIT() NOOP
134
     #define Z_ENABLE_INIT() NOOP
121
-    #define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
135
+    #define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z.toff : 0)
122
     #define Z_ENABLE_READ() stepperZ.isEnabled()
136
     #define Z_ENABLE_READ() stepperZ.isEnabled()
123
   #endif
137
   #endif
124
   #if AXIS_HAS_SQUARE_WAVE(Z)
138
   #if AXIS_HAS_SQUARE_WAVE(Z)
129
 // X2 Stepper
143
 // X2 Stepper
130
 #if HAS_X2_ENABLE && AXIS_IS_TMC(X2)
144
 #if HAS_X2_ENABLE && AXIS_IS_TMC(X2)
131
   extern TMC_CLASS(X2, X) stepperX2;
145
   extern TMC_CLASS(X2, X) stepperX2;
146
+  #ifndef CHOPPER_TIMING_X2
147
+    #define CHOPPER_TIMING_X2 CHOPPER_TIMING_E
148
+  #endif
149
+  static constexpr chopper_timing_t chopper_timing_X2 = CHOPPER_TIMING_X2;
132
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
150
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
133
     #define X2_ENABLE_INIT() NOOP
151
     #define X2_ENABLE_INIT() NOOP
134
-    #define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing.toff : 0)
152
+    #define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing_X2.toff : 0)
135
     #define X2_ENABLE_READ() stepperX2.isEnabled()
153
     #define X2_ENABLE_READ() stepperX2.isEnabled()
136
   #endif
154
   #endif
137
   #if AXIS_HAS_SQUARE_WAVE(X2)
155
   #if AXIS_HAS_SQUARE_WAVE(X2)
142
 // Y2 Stepper
160
 // Y2 Stepper
143
 #if HAS_Y2_ENABLE && AXIS_IS_TMC(Y2)
161
 #if HAS_Y2_ENABLE && AXIS_IS_TMC(Y2)
144
   extern TMC_CLASS(Y2, Y) stepperY2;
162
   extern TMC_CLASS(Y2, Y) stepperY2;
163
+  #ifndef CHOPPER_TIMING_Y2
164
+    #define CHOPPER_TIMING_Y2 CHOPPER_TIMING_E
165
+  #endif
166
+  static constexpr chopper_timing_t chopper_timing_Y2 = CHOPPER_TIMING_Y2;
145
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
167
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
146
     #define Y2_ENABLE_INIT() NOOP
168
     #define Y2_ENABLE_INIT() NOOP
147
-    #define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing.toff : 0)
169
+    #define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y2.toff : 0)
148
     #define Y2_ENABLE_READ() stepperY2.isEnabled()
170
     #define Y2_ENABLE_READ() stepperY2.isEnabled()
149
   #endif
171
   #endif
150
   #if AXIS_HAS_SQUARE_WAVE(Y2)
172
   #if AXIS_HAS_SQUARE_WAVE(Y2)
155
 // Z2 Stepper
177
 // Z2 Stepper
156
 #if HAS_Z2_ENABLE && AXIS_IS_TMC(Z2)
178
 #if HAS_Z2_ENABLE && AXIS_IS_TMC(Z2)
157
   extern TMC_CLASS(Z2, Z) stepperZ2;
179
   extern TMC_CLASS(Z2, Z) stepperZ2;
180
+  #ifndef CHOPPER_TIMING_Z2
181
+    #define CHOPPER_TIMING_Z2 CHOPPER_TIMING_E
182
+  #endif
183
+  static constexpr chopper_timing_t chopper_timing_Z2 = CHOPPER_TIMING_Z2;
158
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)
184
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)
159
     #define Z2_ENABLE_INIT() NOOP
185
     #define Z2_ENABLE_INIT() NOOP
160
-    #define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
186
+    #define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z2.toff : 0)
161
     #define Z2_ENABLE_READ() stepperZ2.isEnabled()
187
     #define Z2_ENABLE_READ() stepperZ2.isEnabled()
162
   #endif
188
   #endif
163
   #if AXIS_HAS_SQUARE_WAVE(Z2)
189
   #if AXIS_HAS_SQUARE_WAVE(Z2)
168
 // Z3 Stepper
194
 // Z3 Stepper
169
 #if HAS_Z3_ENABLE && AXIS_IS_TMC(Z3)
195
 #if HAS_Z3_ENABLE && AXIS_IS_TMC(Z3)
170
   extern TMC_CLASS(Z3, Z) stepperZ3;
196
   extern TMC_CLASS(Z3, Z) stepperZ3;
197
+  #ifndef CHOPPER_TIMING_Z3
198
+    #define CHOPPER_TIMING_Z3 CHOPPER_TIMING_E
199
+  #endif
200
+  static constexpr chopper_timing_t chopper_timing_Z3 = CHOPPER_TIMING_Z3;
171
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
201
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
172
     #define Z3_ENABLE_INIT() NOOP
202
     #define Z3_ENABLE_INIT() NOOP
173
-    #define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
203
+    #define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z3.toff : 0)
174
     #define Z3_ENABLE_READ() stepperZ3.isEnabled()
204
     #define Z3_ENABLE_READ() stepperZ3.isEnabled()
175
   #endif
205
   #endif
176
   #if AXIS_HAS_SQUARE_WAVE(Z3)
206
   #if AXIS_HAS_SQUARE_WAVE(Z3)
181
 // Z4 Stepper
211
 // Z4 Stepper
182
 #if HAS_Z4_ENABLE && AXIS_IS_TMC(Z4)
212
 #if HAS_Z4_ENABLE && AXIS_IS_TMC(Z4)
183
   extern TMC_CLASS(Z4, Z) stepperZ4;
213
   extern TMC_CLASS(Z4, Z) stepperZ4;
214
+  #ifndef CHOPPER_TIMING_Z4
215
+    #define CHOPPER_TIMING_Z4 CHOPPER_TIMING_E
216
+  #endif
217
+  static constexpr chopper_timing_t chopper_timing_Z4 = CHOPPER_TIMING_Z4;
184
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
218
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
185
     #define Z4_ENABLE_INIT() NOOP
219
     #define Z4_ENABLE_INIT() NOOP
186
-    #define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
220
+    #define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z4.toff : 0)
187
     #define Z4_ENABLE_READ() stepperZ4.isEnabled()
221
     #define Z4_ENABLE_READ() stepperZ4.isEnabled()
188
   #endif
222
   #endif
189
   #if AXIS_HAS_SQUARE_WAVE(Z4)
223
   #if AXIS_HAS_SQUARE_WAVE(Z4)
194
 // E0 Stepper
228
 // E0 Stepper
195
 #if AXIS_IS_TMC(E0)
229
 #if AXIS_IS_TMC(E0)
196
   extern TMC_CLASS_E(0) stepperE0;
230
   extern TMC_CLASS_E(0) stepperE0;
231
+  #ifndef CHOPPER_TIMING_E0
232
+    #define CHOPPER_TIMING_E0 CHOPPER_TIMING_E
233
+  #endif
234
+  static constexpr chopper_timing_t chopper_timing_E0 = CHOPPER_TIMING_E0;
197
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)
235
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)
198
     #define E0_ENABLE_INIT() NOOP
236
     #define E0_ENABLE_INIT() NOOP
199
-    #define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
237
+    #define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing_E0.toff : 0)
200
     #define E0_ENABLE_READ() stepperE0.isEnabled()
238
     #define E0_ENABLE_READ() stepperE0.isEnabled()
201
   #endif
239
   #endif
202
   #if AXIS_HAS_SQUARE_WAVE(E0)
240
   #if AXIS_HAS_SQUARE_WAVE(E0)
207
 // E1 Stepper
245
 // E1 Stepper
208
 #if AXIS_IS_TMC(E1)
246
 #if AXIS_IS_TMC(E1)
209
   extern TMC_CLASS_E(1) stepperE1;
247
   extern TMC_CLASS_E(1) stepperE1;
248
+  #ifndef CHOPPER_TIMING_E1
249
+    #define CHOPPER_TIMING_E1 CHOPPER_TIMING_E
250
+  #endif
251
+  static constexpr chopper_timing_t chopper_timing_E1 = CHOPPER_TIMING_E1;
210
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)
252
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)
211
     #define E1_ENABLE_INIT() NOOP
253
     #define E1_ENABLE_INIT() NOOP
212
-    #define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
254
+    #define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing_E1.toff : 0)
213
     #define E1_ENABLE_READ() stepperE1.isEnabled()
255
     #define E1_ENABLE_READ() stepperE1.isEnabled()
214
   #endif
256
   #endif
215
   #if AXIS_HAS_SQUARE_WAVE(E1)
257
   #if AXIS_HAS_SQUARE_WAVE(E1)
220
 // E2 Stepper
262
 // E2 Stepper
221
 #if AXIS_IS_TMC(E2)
263
 #if AXIS_IS_TMC(E2)
222
   extern TMC_CLASS_E(2) stepperE2;
264
   extern TMC_CLASS_E(2) stepperE2;
265
+  #ifndef CHOPPER_TIMING_E2
266
+    #define CHOPPER_TIMING_E2 CHOPPER_TIMING_E
267
+  #endif
268
+  static constexpr chopper_timing_t chopper_timing_E2 = CHOPPER_TIMING_E2;
223
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)
269
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)
224
     #define E2_ENABLE_INIT() NOOP
270
     #define E2_ENABLE_INIT() NOOP
225
-    #define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
271
+    #define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing_E2.toff : 0)
226
     #define E2_ENABLE_READ() stepperE2.isEnabled()
272
     #define E2_ENABLE_READ() stepperE2.isEnabled()
227
   #endif
273
   #endif
228
   #if AXIS_HAS_SQUARE_WAVE(E2)
274
   #if AXIS_HAS_SQUARE_WAVE(E2)
233
 // E3 Stepper
279
 // E3 Stepper
234
 #if AXIS_IS_TMC(E3)
280
 #if AXIS_IS_TMC(E3)
235
   extern TMC_CLASS_E(3) stepperE3;
281
   extern TMC_CLASS_E(3) stepperE3;
282
+  #ifndef CHOPPER_TIMING_E3
283
+    #define CHOPPER_TIMING_E3 CHOPPER_TIMING_E
284
+  #endif
285
+  static constexpr chopper_timing_t chopper_timing_E3 = CHOPPER_TIMING_E3;
236
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)
286
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)
237
     #define E3_ENABLE_INIT() NOOP
287
     #define E3_ENABLE_INIT() NOOP
238
-    #define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
288
+    #define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing_E3.toff : 0)
239
     #define E3_ENABLE_READ() stepperE3.isEnabled()
289
     #define E3_ENABLE_READ() stepperE3.isEnabled()
240
   #endif
290
   #endif
241
   #if AXIS_HAS_SQUARE_WAVE(E3)
291
   #if AXIS_HAS_SQUARE_WAVE(E3)
246
 // E4 Stepper
296
 // E4 Stepper
247
 #if AXIS_IS_TMC(E4)
297
 #if AXIS_IS_TMC(E4)
248
   extern TMC_CLASS_E(4) stepperE4;
298
   extern TMC_CLASS_E(4) stepperE4;
299
+  #ifndef CHOPPER_TIMING_E4
300
+    #define CHOPPER_TIMING_E4 CHOPPER_TIMING_E
301
+  #endif
302
+  static constexpr chopper_timing_t chopper_timing_E4 = CHOPPER_TIMING_E4;
249
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)
303
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)
250
     #define E4_ENABLE_INIT() NOOP
304
     #define E4_ENABLE_INIT() NOOP
251
-    #define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
305
+    #define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing_E4.toff : 0)
252
     #define E4_ENABLE_READ() stepperE4.isEnabled()
306
     #define E4_ENABLE_READ() stepperE4.isEnabled()
253
   #endif
307
   #endif
254
   #if AXIS_HAS_SQUARE_WAVE(E4)
308
   #if AXIS_HAS_SQUARE_WAVE(E4)
259
 // E5 Stepper
313
 // E5 Stepper
260
 #if AXIS_IS_TMC(E5)
314
 #if AXIS_IS_TMC(E5)
261
   extern TMC_CLASS_E(5) stepperE5;
315
   extern TMC_CLASS_E(5) stepperE5;
316
+  #ifndef CHOPPER_TIMING_E5
317
+    #define CHOPPER_TIMING_E5 CHOPPER_TIMING_E
318
+  #endif
319
+  static constexpr chopper_timing_t chopper_timing_E5 = CHOPPER_TIMING_E5;
262
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)
320
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)
263
     #define E5_ENABLE_INIT() NOOP
321
     #define E5_ENABLE_INIT() NOOP
264
-    #define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
322
+    #define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing_E5.toff : 0)
265
     #define E5_ENABLE_READ() stepperE5.isEnabled()
323
     #define E5_ENABLE_READ() stepperE5.isEnabled()
266
   #endif
324
   #endif
267
   #if AXIS_HAS_SQUARE_WAVE(E5)
325
   #if AXIS_HAS_SQUARE_WAVE(E5)
272
 // E6 Stepper
330
 // E6 Stepper
273
 #if AXIS_IS_TMC(E6)
331
 #if AXIS_IS_TMC(E6)
274
   extern TMC_CLASS_E(6) stepperE6;
332
   extern TMC_CLASS_E(6) stepperE6;
333
+  #ifndef CHOPPER_TIMING_E6
334
+    #define CHOPPER_TIMING_E6 CHOPPER_TIMING_E
335
+  #endif
336
+  static constexpr chopper_timing_t chopper_timing_E6 = CHOPPER_TIMING_E6;
275
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)
337
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)
276
     #define E6_ENABLE_INIT() NOOP
338
     #define E6_ENABLE_INIT() NOOP
277
-    #define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
339
+    #define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing_E6.toff : 0)
278
     #define E6_ENABLE_READ() stepperE6.isEnabled()
340
     #define E6_ENABLE_READ() stepperE6.isEnabled()
279
   #endif
341
   #endif
280
   #if AXIS_HAS_SQUARE_WAVE(E6)
342
   #if AXIS_HAS_SQUARE_WAVE(E6)
285
 // E7 Stepper
347
 // E7 Stepper
286
 #if AXIS_IS_TMC(E7)
348
 #if AXIS_IS_TMC(E7)
287
   extern TMC_CLASS_E(7) stepperE7;
349
   extern TMC_CLASS_E(7) stepperE7;
350
+  #ifndef CHOPPER_TIMING_E7
351
+    #define CHOPPER_TIMING_E7 CHOPPER_TIMING_E
352
+  #endif
353
+  static constexpr chopper_timing_t chopper_timing_E7 = CHOPPER_TIMING_E7;
288
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)
354
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)
289
     #define E7_ENABLE_INIT() NOOP
355
     #define E7_ENABLE_INIT() NOOP
290
-    #define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
356
+    #define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing_E7.toff : 0)
291
     #define E7_ENABLE_READ() stepperE7.isEnabled()
357
     #define E7_ENABLE_READ() stepperE7.isEnabled()
292
   #endif
358
   #endif
293
   #if AXIS_HAS_SQUARE_WAVE(E7)
359
   #if AXIS_HAS_SQUARE_WAVE(E7)

Loading…
취소
저장