Преглед на файлове

Consolidate smart stepper driver initialization

Scott Lahteine преди 7 години
родител
ревизия
48d7036874

+ 5
- 0
Marlin/src/feature/power.cpp Целия файл

88
 void Power::power_on() {
88
 void Power::power_on() {
89
   lastPowerOn = millis();
89
   lastPowerOn = millis();
90
   PSU_PIN_ON();
90
   PSU_PIN_ON();
91
+
92
+  #if HAS_TRINAMIC
93
+    delay(100); // Wait for power to settle
94
+    restore_stepper_drivers();
95
+  #endif
91
 }
96
 }
92
 
97
 
93
 void Power::power_off() {
98
 void Power::power_off() {

+ 3
- 8
Marlin/src/gcode/control/M80_M81.cpp Целия файл

76
       OUT_WRITE(SUICIDE_PIN, HIGH);
76
       OUT_WRITE(SUICIDE_PIN, HIGH);
77
     #endif
77
     #endif
78
 
78
 
79
-    #if ENABLED(HAVE_TMC2130)
80
-      delay(100);
81
-      tmc2130_init(); // Settings only stick when the driver has power
82
-    #endif
83
-
84
-    #if ENABLED(HAVE_TMC2208)
85
-      delay(100);
86
-      tmc2208_init();
79
+    #if DISABLED(AUTO_POWER_CONTROL)
80
+      delay(100); // Wait for power to settle
81
+      restore_stepper_drivers();
87
     #endif
82
     #endif
88
 
83
 
89
     #if ENABLED(ULTIPANEL)
84
     #if ENABLED(ULTIPANEL)

+ 0
- 25
Marlin/src/module/stepper.cpp Целия файл

921
     microstep_init();
921
     microstep_init();
922
   #endif
922
   #endif
923
 
923
 
924
-  // Init TMC Steppers
925
-  #if ENABLED(HAVE_TMC26X)
926
-    tmc26x_init();
927
-  #endif
928
-
929
-  // Init TMC2130 Steppers
930
-  #if ENABLED(HAVE_TMC2130)
931
-    tmc2130_init();
932
-  #endif
933
-
934
-  // Init TMC2208 Steppers
935
-  #if ENABLED(HAVE_TMC2208)
936
-    tmc2208_init();
937
-  #endif
938
-
939
-  // TRAMS, TMC2130 and TMC2208 advanced settings
940
-  #if HAS_TRINAMIC
941
-    TMC_ADV()
942
-  #endif
943
-
944
-  // Init L6470 Steppers
945
-  #if ENABLED(HAVE_L6470DRIVER)
946
-    L6470_init();
947
-  #endif
948
-
949
   // Init Dir Pins
924
   // Init Dir Pins
950
   #if HAS_X_DIR
925
   #if HAS_X_DIR
951
     X_DIR_INIT;
926
     X_DIR_INIT;

+ 125
- 76
Marlin/src/module/stepper_indirection.cpp Целия файл

47
     #include <TMC26XStepper.h>
47
     #include <TMC26XStepper.h>
48
   #endif
48
   #endif
49
 
49
 
50
-  #define _TMC_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_ENABLE_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR)
50
+  #define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_ENABLE_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR)
51
 
51
 
52
   #if ENABLED(X_IS_TMC26X)
52
   #if ENABLED(X_IS_TMC26X)
53
-    _TMC_DEFINE(X);
53
+    _TMC26X_DEFINE(X);
54
   #endif
54
   #endif
55
   #if ENABLED(X2_IS_TMC26X)
55
   #if ENABLED(X2_IS_TMC26X)
56
-    _TMC_DEFINE(X2);
56
+    _TMC26X_DEFINE(X2);
57
   #endif
57
   #endif
58
   #if ENABLED(Y_IS_TMC26X)
58
   #if ENABLED(Y_IS_TMC26X)
59
-    _TMC_DEFINE(Y);
59
+    _TMC26X_DEFINE(Y);
60
   #endif
60
   #endif
61
   #if ENABLED(Y2_IS_TMC26X)
61
   #if ENABLED(Y2_IS_TMC26X)
62
-    _TMC_DEFINE(Y2);
62
+    _TMC26X_DEFINE(Y2);
63
   #endif
63
   #endif
64
   #if ENABLED(Z_IS_TMC26X)
64
   #if ENABLED(Z_IS_TMC26X)
65
-    _TMC_DEFINE(Z);
65
+    _TMC26X_DEFINE(Z);
66
   #endif
66
   #endif
67
   #if ENABLED(Z2_IS_TMC26X)
67
   #if ENABLED(Z2_IS_TMC26X)
68
-    _TMC_DEFINE(Z2);
68
+    _TMC26X_DEFINE(Z2);
69
   #endif
69
   #endif
70
   #if ENABLED(E0_IS_TMC26X)
70
   #if ENABLED(E0_IS_TMC26X)
71
-    _TMC_DEFINE(E0);
71
+    _TMC26X_DEFINE(E0);
72
   #endif
72
   #endif
73
   #if ENABLED(E1_IS_TMC26X)
73
   #if ENABLED(E1_IS_TMC26X)
74
-    _TMC_DEFINE(E1);
74
+    _TMC26X_DEFINE(E1);
75
   #endif
75
   #endif
76
   #if ENABLED(E2_IS_TMC26X)
76
   #if ENABLED(E2_IS_TMC26X)
77
-    _TMC_DEFINE(E2);
77
+    _TMC26X_DEFINE(E2);
78
   #endif
78
   #endif
79
   #if ENABLED(E3_IS_TMC26X)
79
   #if ENABLED(E3_IS_TMC26X)
80
-    _TMC_DEFINE(E3);
80
+    _TMC26X_DEFINE(E3);
81
   #endif
81
   #endif
82
   #if ENABLED(E4_IS_TMC26X)
82
   #if ENABLED(E4_IS_TMC26X)
83
-    _TMC_DEFINE(E4);
83
+    _TMC26X_DEFINE(E4);
84
   #endif
84
   #endif
85
 
85
 
86
-  #define _TMC_INIT(A) do{ \
86
+  #define _TMC26X_INIT(A) do{ \
87
     stepper##A.setMicrosteps(A##_MICROSTEPS); \
87
     stepper##A.setMicrosteps(A##_MICROSTEPS); \
88
     stepper##A.start(); \
88
     stepper##A.start(); \
89
   }while(0)
89
   }while(0)
90
 
90
 
91
-  void tmc26x_init() {
91
+  void tmc26x_init_to_defaults() {
92
     #if ENABLED(X_IS_TMC26X)
92
     #if ENABLED(X_IS_TMC26X)
93
-      _TMC_INIT(X);
93
+      _TMC26X_INIT(X);
94
     #endif
94
     #endif
95
     #if ENABLED(X2_IS_TMC26X)
95
     #if ENABLED(X2_IS_TMC26X)
96
-      _TMC_INIT(X2);
96
+      _TMC26X_INIT(X2);
97
     #endif
97
     #endif
98
     #if ENABLED(Y_IS_TMC26X)
98
     #if ENABLED(Y_IS_TMC26X)
99
-      _TMC_INIT(Y);
99
+      _TMC26X_INIT(Y);
100
     #endif
100
     #endif
101
     #if ENABLED(Y2_IS_TMC26X)
101
     #if ENABLED(Y2_IS_TMC26X)
102
-      _TMC_INIT(Y2);
102
+      _TMC26X_INIT(Y2);
103
     #endif
103
     #endif
104
     #if ENABLED(Z_IS_TMC26X)
104
     #if ENABLED(Z_IS_TMC26X)
105
-      _TMC_INIT(Z);
105
+      _TMC26X_INIT(Z);
106
     #endif
106
     #endif
107
     #if ENABLED(Z2_IS_TMC26X)
107
     #if ENABLED(Z2_IS_TMC26X)
108
-      _TMC_INIT(Z2);
108
+      _TMC26X_INIT(Z2);
109
     #endif
109
     #endif
110
     #if ENABLED(E0_IS_TMC26X)
110
     #if ENABLED(E0_IS_TMC26X)
111
-      _TMC_INIT(E0);
111
+      _TMC26X_INIT(E0);
112
     #endif
112
     #endif
113
     #if ENABLED(E1_IS_TMC26X)
113
     #if ENABLED(E1_IS_TMC26X)
114
-      _TMC_INIT(E1);
114
+      _TMC26X_INIT(E1);
115
     #endif
115
     #endif
116
     #if ENABLED(E2_IS_TMC26X)
116
     #if ENABLED(E2_IS_TMC26X)
117
-      _TMC_INIT(E2);
117
+      _TMC26X_INIT(E2);
118
     #endif
118
     #endif
119
     #if ENABLED(E3_IS_TMC26X)
119
     #if ENABLED(E3_IS_TMC26X)
120
-      _TMC_INIT(E3);
120
+      _TMC26X_INIT(E3);
121
     #endif
121
     #endif
122
     #if ENABLED(E4_IS_TMC26X)
122
     #if ENABLED(E4_IS_TMC26X)
123
-      _TMC_INIT(E4);
123
+      _TMC26X_INIT(E4);
124
     #endif
124
     #endif
125
   }
125
   }
126
-
127
 #endif // HAVE_TMC26X
126
 #endif // HAVE_TMC26X
128
 
127
 
129
 //
128
 //
180
   // Use internal reference voltage for current calculations. This is the default.
179
   // Use internal reference voltage for current calculations. This is the default.
181
   // Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609)
180
   // Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609)
182
   // https://www.trinamic.com/products/integrated-circuits/details/tmc2130/
181
   // https://www.trinamic.com/products/integrated-circuits/details/tmc2130/
183
-  void tmc2130_init(TMC2130Stepper &st, const uint16_t microsteps, const uint32_t thrs, const float spmm) {
182
+  void tmc2130_init(TMC2130Stepper &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const float spmm) {
184
     st.begin();
183
     st.begin();
185
-    st.setCurrent(st.getCurrent(), R_SENSE, HOLD_MULTIPLIER);
184
+    st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
186
     st.microsteps(microsteps);
185
     st.microsteps(microsteps);
187
     st.blank_time(24);
186
     st.blank_time(24);
188
     st.off_time(5); // Only enables the driver if used with stealthChop
187
     st.off_time(5); // Only enables the driver if used with stealthChop
209
     st.GSTAT(); // Clear GSTAT
208
     st.GSTAT(); // Clear GSTAT
210
   }
209
   }
211
 
210
 
212
-  #define _TMC2130_INIT(ST, SPMM) tmc2130_init(stepper##ST, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM)
211
+  #define _TMC2130_INIT(ST, SPMM) tmc2130_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM)
213
 
212
 
214
-  void tmc2130_init() {
213
+  void tmc2130_init_to_defaults() {
215
     #if ENABLED(X_IS_TMC2130)
214
     #if ENABLED(X_IS_TMC2130)
216
       _TMC2130_INIT( X, planner.axis_steps_per_mm[X_AXIS]);
215
       _TMC2130_INIT( X, planner.axis_steps_per_mm[X_AXIS]);
217
     #endif
216
     #endif
234
       _TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
233
       _TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
235
     #endif
234
     #endif
236
     #if ENABLED(E1_IS_TMC2130)
235
     #if ENABLED(E1_IS_TMC2130)
237
-      _TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS
238
-        #if ENABLED(DISTINCT_E_FACTORS)
239
-          + 1
240
-        #endif
241
-      ]);
236
+      { constexpr int extruder = 1; _TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); }
242
     #endif
237
     #endif
243
     #if ENABLED(E2_IS_TMC2130)
238
     #if ENABLED(E2_IS_TMC2130)
244
-      _TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS
245
-        #if ENABLED(DISTINCT_E_FACTORS)
246
-          + 2
247
-        #endif
248
-      ]);
239
+      { constexpr int extruder = 2; _TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); }
249
     #endif
240
     #endif
250
     #if ENABLED(E3_IS_TMC2130)
241
     #if ENABLED(E3_IS_TMC2130)
251
-      _TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS
252
-        #if ENABLED(DISTINCT_E_FACTORS)
253
-          + 3
254
-        #endif
255
-      ]);
242
+      { constexpr int extruder = 3; _TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); }
256
     #endif
243
     #endif
257
     #if ENABLED(E4_IS_TMC2130)
244
     #if ENABLED(E4_IS_TMC2130)
258
-      _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS
259
-        #if ENABLED(DISTINCT_E_FACTORS)
260
-          + 4
261
-        #endif
262
-      ]);
245
+      { constexpr int extruder = 4; _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
263
     #endif
246
     #endif
264
 
247
 
248
+    #if ENABLED(SENSORLESS_HOMING)
249
+      #define TMC_INIT_SGT(P,Q) stepper##Q.sgt(P##_HOMING_SENSITIVITY);
250
+      #ifdef X_HOMING_SENSITIVITY
251
+        #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
252
+          stepperX.sgt(X_HOMING_SENSITIVITY);
253
+        #endif
254
+        #if ENABLED(X2_IS_TMC2130)
255
+          stepperX2.sgt(X_HOMING_SENSITIVITY);
256
+        #endif
257
+      #endif
258
+      #ifdef Y_HOMING_SENSITIVITY
259
+        #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
260
+          stepperY.sgt(Y_HOMING_SENSITIVITY);
261
+        #endif
262
+        #if ENABLED(Y2_IS_TMC2130)
263
+          stepperY2.sgt(Y_HOMING_SENSITIVITY);
264
+        #endif
265
+      #endif
266
+      #ifdef Z_HOMING_SENSITIVITY
267
+        #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
268
+          stepperZ.sgt(Z_HOMING_SENSITIVITY);
269
+        #endif
270
+        #if ENABLED(Z2_IS_TMC2130)
271
+          stepperZ2.sgt(Z_HOMING_SENSITIVITY);
272
+        #endif
273
+      #endif
274
+    #endif
265
   }
275
   }
266
 #endif // HAVE_TMC2130
276
 #endif // HAVE_TMC2130
267
 
277
 
396
 
406
 
397
   // Use internal reference voltage for current calculations. This is the default.
407
   // Use internal reference voltage for current calculations. This is the default.
398
   // Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609)
408
   // Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609)
399
-  void tmc2208_init(TMC2208Stepper &st, const uint16_t microsteps, const uint32_t thrs, const float spmm) {
409
+  void tmc2208_init(TMC2208Stepper &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const float spmm) {
400
     st.pdn_disable(true); // Use UART
410
     st.pdn_disable(true); // Use UART
401
     st.mstep_reg_select(true); // Select microsteps with UART
411
     st.mstep_reg_select(true); // Select microsteps with UART
402
     st.I_scale_analog(false);
412
     st.I_scale_analog(false);
403
-    st.rms_current(st.getCurrent(), HOLD_MULTIPLIER, R_SENSE);
413
+    st.rms_current(mA, HOLD_MULTIPLIER, R_SENSE);
404
     st.microsteps(microsteps);
414
     st.microsteps(microsteps);
405
     st.blank_time(24);
415
     st.blank_time(24);
406
     st.toff(5);
416
     st.toff(5);
430
     delay(200);
440
     delay(200);
431
   }
441
   }
432
 
442
 
433
-  #define _TMC2208_INIT(ST, SPMM) tmc2208_init(stepper##ST, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM)
443
+  #define _TMC2208_INIT(ST, SPMM) tmc2208_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM)
434
 
444
 
435
-  void tmc2208_init() {
445
+  void tmc2208_init_to_defaults() {
436
     #if ENABLED(X_IS_TMC2208)
446
     #if ENABLED(X_IS_TMC2208)
437
       _TMC2208_INIT(X, planner.axis_steps_per_mm[X_AXIS]);
447
       _TMC2208_INIT(X, planner.axis_steps_per_mm[X_AXIS]);
438
     #endif
448
     #endif
455
       _TMC2208_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
465
       _TMC2208_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
456
     #endif
466
     #endif
457
     #if ENABLED(E1_IS_TMC2208)
467
     #if ENABLED(E1_IS_TMC2208)
458
-      _TMC2208_INIT(E1, planner.axis_steps_per_mm[E_AXIS
459
-        #if ENABLED(DISTINCT_E_FACTORS)
460
-          + 1
461
-        #endif
462
-      ]);
468
+      { constexpr int extruder = 1; _TMC2208_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); }
463
     #endif
469
     #endif
464
     #if ENABLED(E2_IS_TMC2208)
470
     #if ENABLED(E2_IS_TMC2208)
465
-      _TMC2208_INIT(E2, planner.axis_steps_per_mm[E_AXIS
466
-        #if ENABLED(DISTINCT_E_FACTORS)
467
-          + 2
468
-        #endif
469
-      ]);
471
+      { constexpr int extruder = 2; _TMC2208_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); }
470
     #endif
472
     #endif
471
     #if ENABLED(E3_IS_TMC2208)
473
     #if ENABLED(E3_IS_TMC2208)
472
-      _TMC2208_INIT(E3, planner.axis_steps_per_mm[E_AXIS
473
-        #if ENABLED(DISTINCT_E_FACTORS)
474
-          + 3
475
-        #endif
476
-      ]);
474
+      { constexpr int extruder = 3; _TMC2208_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); }
477
     #endif
475
     #endif
478
     #if ENABLED(E4_IS_TMC2208)
476
     #if ENABLED(E4_IS_TMC2208)
479
-      _TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS
480
-        #if ENABLED(DISTINCT_E_FACTORS)
481
-          + 4
482
-        #endif
483
-      ]);
477
+      { constexpr int extruder = 4; _TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
484
     #endif
478
     #endif
485
   }
479
   }
486
 #endif // HAVE_TMC2208
480
 #endif // HAVE_TMC2208
487
 
481
 
482
+void restore_stepper_drivers() {
483
+  #if X_IS_TRINAMIC
484
+    stepperX.push();
485
+  #endif
486
+  #if X2_IS_TRINAMIC
487
+    stepperX2.push();
488
+  #endif
489
+  #if Y_IS_TRINAMIC
490
+    stepperY.push();
491
+  #endif
492
+  #if Y2_IS_TRINAMIC
493
+    stepperY2.push();
494
+  #endif
495
+  #if Z_IS_TRINAMIC
496
+    stepperZ.push();
497
+  #endif
498
+  #if Z2_IS_TRINAMIC
499
+    stepperZ2.push();
500
+  #endif
501
+  #if E0_IS_TRINAMIC
502
+    stepperE0.push();
503
+  #endif
504
+  #if E1_IS_TRINAMIC
505
+    stepperE1.push();
506
+  #endif
507
+  #if E2_IS_TRINAMIC
508
+    stepperE2.push();
509
+  #endif
510
+  #if E3_IS_TRINAMIC
511
+    stepperE3.push();
512
+  #endif
513
+  #if E4_IS_TRINAMIC
514
+    stepperE4.push();
515
+  #endif
516
+}
517
+
518
+void reset_stepper_drivers() {
519
+  #if ENABLED(HAVE_TMC26X)
520
+    tmc26x_init_to_defaults();
521
+  #endif
522
+  #if ENABLED(HAVE_TMC2130)
523
+    delay(100);
524
+    tmc2130_init_to_defaults();
525
+  #endif
526
+  #if ENABLED(HAVE_TMC2208)
527
+    delay(100);
528
+    tmc2208_init_to_defaults();
529
+  #endif
530
+  #ifdef TMC_ADV
531
+    TMC_ADV()
532
+  #endif
533
+  #if ENABLED(HAVE_L6470DRIVER)
534
+    L6470_init_to_defaults();
535
+  #endif
536
+}
537
+
488
 //
538
 //
489
 // L6470 Driver objects and inits
539
 // L6470 Driver objects and inits
490
 //
540
 //
538
     stepper##A.setStallCurrent(A##_STALLCURRENT); \
588
     stepper##A.setStallCurrent(A##_STALLCURRENT); \
539
   }while(0)
589
   }while(0)
540
 
590
 
541
-  void L6470_init() {
591
+  void L6470_init_to_defaults() {
542
     #if ENABLED(X_IS_L6470)
592
     #if ENABLED(X_IS_L6470)
543
       _L6470_INIT(X);
593
       _L6470_INIT(X);
544
     #endif
594
     #endif
575
   }
625
   }
576
 
626
 
577
 #endif // HAVE_L6470DRIVER
627
 #endif // HAVE_L6470DRIVER
578
-

+ 40
- 37
Marlin/src/module/stepper_indirection.h Целия файл

54
   #else
54
   #else
55
     #include <TMC26XStepper.h>
55
     #include <TMC26XStepper.h>
56
   #endif
56
   #endif
57
-  void tmc26x_init();
57
+  void tmc26x_init_to_defaults();
58
 #endif
58
 #endif
59
 
59
 
60
 #if ENABLED(HAVE_TMC2130)
60
 #if ENABLED(HAVE_TMC2130)
61
   #include <TMC2130Stepper.h>
61
   #include <TMC2130Stepper.h>
62
-  void tmc2130_init();
62
+  void tmc2130_init_to_defaults();
63
 #endif
63
 #endif
64
 
64
 
65
 #if ENABLED(HAVE_TMC2208)
65
 #if ENABLED(HAVE_TMC2208)
66
   #include <TMC2208Stepper.h>
66
   #include <TMC2208Stepper.h>
67
   void tmc2208_serial_begin();
67
   void tmc2208_serial_begin();
68
-  void tmc2208_init();
68
+  void tmc2208_init_to_defaults();
69
 #endif
69
 #endif
70
 
70
 
71
 // L6470 has STEP on normal pins, but DIR/ENABLE via SPI
71
 // L6470 has STEP on normal pins, but DIR/ENABLE via SPI
72
 #if ENABLED(HAVE_L6470DRIVER)
72
 #if ENABLED(HAVE_L6470DRIVER)
73
   #include <SPI.h>
73
   #include <SPI.h>
74
   #include <L6470.h>
74
   #include <L6470.h>
75
-  void L6470_init();
75
+  void L6470_init_to_defaults();
76
 #endif
76
 #endif
77
 
77
 
78
+void restore_stepper_drivers();  // Called by PSU_ON
79
+void reset_stepper_drivers();    // Called by settings.load / settings.reset
80
+
78
 // X Stepper
81
 // X Stepper
79
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(X_IS_L6470)
82
+#if ENABLED(X_IS_L6470)
80
   extern L6470 stepperX;
83
   extern L6470 stepperX;
81
   #define X_ENABLE_INIT NOOP
84
   #define X_ENABLE_INIT NOOP
82
   #define X_ENABLE_WRITE(STATE) do{ if (STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree(); }while(0)
85
   #define X_ENABLE_WRITE(STATE) do{ if (STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree(); }while(0)
91
     #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE)
94
     #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE)
92
     #define X_ENABLE_READ stepperX.isEnabled()
95
     #define X_ENABLE_READ stepperX.isEnabled()
93
   #else
96
   #else
94
-    #if ENABLED(HAVE_TMC2130) && ENABLED(X_IS_TMC2130)
97
+    #if ENABLED(X_IS_TMC2130)
95
       extern TMC2130Stepper stepperX;
98
       extern TMC2130Stepper stepperX;
96
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(X_IS_TMC2208)
99
+    #elif ENABLED(X_IS_TMC2208)
97
       extern TMC2208Stepper stepperX;
100
       extern TMC2208Stepper stepperX;
98
     #endif
101
     #endif
99
     #define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
102
     #define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
109
 #define X_STEP_READ READ(X_STEP_PIN)
112
 #define X_STEP_READ READ(X_STEP_PIN)
110
 
113
 
111
 // Y Stepper
114
 // Y Stepper
112
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(Y_IS_L6470)
115
+#if ENABLED(Y_IS_L6470)
113
   extern L6470 stepperY;
116
   extern L6470 stepperY;
114
   #define Y_ENABLE_INIT NOOP
117
   #define Y_ENABLE_INIT NOOP
115
   #define Y_ENABLE_WRITE(STATE) do{ if (STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree(); }while(0)
118
   #define Y_ENABLE_WRITE(STATE) do{ if (STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree(); }while(0)
124
     #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE)
127
     #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE)
125
     #define Y_ENABLE_READ stepperY.isEnabled()
128
     #define Y_ENABLE_READ stepperY.isEnabled()
126
   #else
129
   #else
127
-    #if ENABLED(HAVE_TMC2130) && ENABLED(Y_IS_TMC2130)
130
+    #if ENABLED(Y_IS_TMC2130)
128
       extern TMC2130Stepper stepperY;
131
       extern TMC2130Stepper stepperY;
129
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(Y_IS_TMC2208)
132
+    #elif ENABLED(Y_IS_TMC2208)
130
       extern TMC2208Stepper stepperY;
133
       extern TMC2208Stepper stepperY;
131
     #endif
134
     #endif
132
     #define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
135
     #define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
142
 #define Y_STEP_READ READ(Y_STEP_PIN)
145
 #define Y_STEP_READ READ(Y_STEP_PIN)
143
 
146
 
144
 // Z Stepper
147
 // Z Stepper
145
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(Z_IS_L6470)
148
+#if ENABLED(Z_IS_L6470)
146
   extern L6470 stepperZ;
149
   extern L6470 stepperZ;
147
   #define Z_ENABLE_INIT NOOP
150
   #define Z_ENABLE_INIT NOOP
148
   #define Z_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree(); }while(0)
151
   #define Z_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree(); }while(0)
157
     #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE)
160
     #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE)
158
     #define Z_ENABLE_READ stepperZ.isEnabled()
161
     #define Z_ENABLE_READ stepperZ.isEnabled()
159
   #else
162
   #else
160
-    #if ENABLED(HAVE_TMC2130) && ENABLED(Z_IS_TMC2130)
163
+    #if ENABLED(Z_IS_TMC2130)
161
       extern TMC2130Stepper stepperZ;
164
       extern TMC2130Stepper stepperZ;
162
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(Z_IS_TMC2208)
165
+    #elif ENABLED(Z_IS_TMC2208)
163
       extern TMC2208Stepper stepperZ;
166
       extern TMC2208Stepper stepperZ;
164
     #endif
167
     #endif
165
     #define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
168
     #define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
176
 
179
 
177
 // X2 Stepper
180
 // X2 Stepper
178
 #if HAS_X2_ENABLE
181
 #if HAS_X2_ENABLE
179
-  #if ENABLED(HAVE_L6470DRIVER) && ENABLED(X2_IS_L6470)
182
+  #if ENABLED(X2_IS_L6470)
180
     extern L6470 stepperX2;
183
     extern L6470 stepperX2;
181
     #define X2_ENABLE_INIT NOOP
184
     #define X2_ENABLE_INIT NOOP
182
     #define X2_ENABLE_WRITE(STATE) do{ if (STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree(); }while(0)
185
     #define X2_ENABLE_WRITE(STATE) do{ if (STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree(); }while(0)
191
       #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE)
194
       #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE)
192
       #define X2_ENABLE_READ stepperX2.isEnabled()
195
       #define X2_ENABLE_READ stepperX2.isEnabled()
193
     #else
196
     #else
194
-      #if ENABLED(HAVE_TMC2130) && ENABLED(X2_IS_TMC2130)
197
+      #if ENABLED(X2_IS_TMC2130)
195
         extern TMC2130Stepper stepperX2;
198
         extern TMC2130Stepper stepperX2;
196
-      #elif ENABLED(HAVE_TMC2208) && ENABLED(X2_IS_TMC2208)
199
+      #elif ENABLED(X2_IS_TMC2208)
197
         extern TMC2208Stepper stepperX2;
200
         extern TMC2208Stepper stepperX2;
198
       #endif
201
       #endif
199
       #define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
202
       #define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
211
 
214
 
212
 // Y2 Stepper
215
 // Y2 Stepper
213
 #if HAS_Y2_ENABLE
216
 #if HAS_Y2_ENABLE
214
-  #if ENABLED(HAVE_L6470DRIVER) && ENABLED(Y2_IS_L6470)
217
+  #if ENABLED(Y2_IS_L6470)
215
     extern L6470 stepperY2;
218
     extern L6470 stepperY2;
216
     #define Y2_ENABLE_INIT NOOP
219
     #define Y2_ENABLE_INIT NOOP
217
     #define Y2_ENABLE_WRITE(STATE) do{ if (STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree(); }while(0)
220
     #define Y2_ENABLE_WRITE(STATE) do{ if (STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree(); }while(0)
226
       #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE)
229
       #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE)
227
       #define Y2_ENABLE_READ stepperY2.isEnabled()
230
       #define Y2_ENABLE_READ stepperY2.isEnabled()
228
     #else
231
     #else
229
-      #if ENABLED(HAVE_TMC2130) && ENABLED(Y2_IS_TMC2130)
232
+      #if ENABLED(Y2_IS_TMC2130)
230
         extern TMC2130Stepper stepperY2;
233
         extern TMC2130Stepper stepperY2;
231
-      #elif ENABLED(HAVE_TMC2208) && ENABLED(Y2_IS_TMC2208)
234
+      #elif ENABLED(Y2_IS_TMC2208)
232
         extern TMC2208Stepper stepperY2;
235
         extern TMC2208Stepper stepperY2;
233
       #endif
236
       #endif
234
       #define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
237
       #define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
246
 
249
 
247
 // Z2 Stepper
250
 // Z2 Stepper
248
 #if HAS_Z2_ENABLE
251
 #if HAS_Z2_ENABLE
249
-  #if ENABLED(HAVE_L6470DRIVER) && ENABLED(Z2_IS_L6470)
252
+  #if ENABLED(Z2_IS_L6470)
250
     extern L6470 stepperZ2;
253
     extern L6470 stepperZ2;
251
     #define Z2_ENABLE_INIT NOOP
254
     #define Z2_ENABLE_INIT NOOP
252
     #define Z2_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree(); }while(0)
255
     #define Z2_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree(); }while(0)
261
       #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE)
264
       #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE)
262
       #define Z2_ENABLE_READ stepperZ2.isEnabled()
265
       #define Z2_ENABLE_READ stepperZ2.isEnabled()
263
     #else
266
     #else
264
-      #if ENABLED(HAVE_TMC2130) && ENABLED(Z2_IS_TMC2130)
267
+      #if ENABLED(Z2_IS_TMC2130)
265
         extern TMC2130Stepper stepperZ2;
268
         extern TMC2130Stepper stepperZ2;
266
-      #elif ENABLED(HAVE_TMC2208) && ENABLED(Z2_IS_TMC2208)
269
+      #elif ENABLED(Z2_IS_TMC2208)
267
         extern TMC2208Stepper stepperZ2;
270
         extern TMC2208Stepper stepperZ2;
268
       #endif
271
       #endif
269
       #define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
272
       #define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
280
 #endif
283
 #endif
281
 
284
 
282
 // E0 Stepper
285
 // E0 Stepper
283
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E0_IS_L6470)
286
+#if ENABLED(E0_IS_L6470)
284
   extern L6470 stepperE0;
287
   extern L6470 stepperE0;
285
   #define E0_ENABLE_INIT NOOP
288
   #define E0_ENABLE_INIT NOOP
286
   #define E0_ENABLE_WRITE(STATE) do{ if (STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree(); }while(0)
289
   #define E0_ENABLE_WRITE(STATE) do{ if (STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree(); }while(0)
295
     #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE)
298
     #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE)
296
     #define E0_ENABLE_READ stepperE0.isEnabled()
299
     #define E0_ENABLE_READ stepperE0.isEnabled()
297
   #else
300
   #else
298
-    #if ENABLED(HAVE_TMC2130) && ENABLED(E0_IS_TMC2130)
301
+    #if ENABLED(E0_IS_TMC2130)
299
       extern TMC2130Stepper stepperE0;
302
       extern TMC2130Stepper stepperE0;
300
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(E0_IS_TMC2208)
303
+    #elif ENABLED(E0_IS_TMC2208)
301
       extern TMC2208Stepper stepperE0;
304
       extern TMC2208Stepper stepperE0;
302
     #endif
305
     #endif
303
     #define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
306
     #define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
313
 #define E0_STEP_READ READ(E0_STEP_PIN)
316
 #define E0_STEP_READ READ(E0_STEP_PIN)
314
 
317
 
315
 // E1 Stepper
318
 // E1 Stepper
316
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E1_IS_L6470)
319
+#if ENABLED(E1_IS_L6470)
317
   extern L6470 stepperE1;
320
   extern L6470 stepperE1;
318
   #define E1_ENABLE_INIT NOOP
321
   #define E1_ENABLE_INIT NOOP
319
   #define E1_ENABLE_WRITE(STATE) do{ if (STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree(); }while(0)
322
   #define E1_ENABLE_WRITE(STATE) do{ if (STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree(); }while(0)
328
     #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE)
331
     #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE)
329
     #define E1_ENABLE_READ stepperE1.isEnabled()
332
     #define E1_ENABLE_READ stepperE1.isEnabled()
330
   #else
333
   #else
331
-    #if ENABLED(HAVE_TMC2130) && ENABLED(E1_IS_TMC2130)
334
+    #if ENABLED(E1_IS_TMC2130)
332
       extern TMC2130Stepper stepperE1;
335
       extern TMC2130Stepper stepperE1;
333
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(E1_IS_TMC2208)
336
+    #elif ENABLED(E1_IS_TMC2208)
334
       extern TMC2208Stepper stepperE1;
337
       extern TMC2208Stepper stepperE1;
335
     #endif
338
     #endif
336
     #define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
339
     #define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
346
 #define E1_STEP_READ READ(E1_STEP_PIN)
349
 #define E1_STEP_READ READ(E1_STEP_PIN)
347
 
350
 
348
 // E2 Stepper
351
 // E2 Stepper
349
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E2_IS_L6470)
352
+#if ENABLED(E2_IS_L6470)
350
   extern L6470 stepperE2;
353
   extern L6470 stepperE2;
351
   #define E2_ENABLE_INIT NOOP
354
   #define E2_ENABLE_INIT NOOP
352
   #define E2_ENABLE_WRITE(STATE) do{ if (STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree(); }while(0)
355
   #define E2_ENABLE_WRITE(STATE) do{ if (STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree(); }while(0)
361
     #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE)
364
     #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE)
362
     #define E2_ENABLE_READ stepperE2.isEnabled()
365
     #define E2_ENABLE_READ stepperE2.isEnabled()
363
   #else
366
   #else
364
-    #if ENABLED(HAVE_TMC2130) && ENABLED(E2_IS_TMC2130)
367
+    #if ENABLED(E2_IS_TMC2130)
365
       extern TMC2130Stepper stepperE2;
368
       extern TMC2130Stepper stepperE2;
366
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(E2_IS_TMC2208)
369
+    #elif ENABLED(E2_IS_TMC2208)
367
       extern TMC2208Stepper stepperE2;
370
       extern TMC2208Stepper stepperE2;
368
     #endif
371
     #endif
369
     #define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
372
     #define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
379
 #define E2_STEP_READ READ(E2_STEP_PIN)
382
 #define E2_STEP_READ READ(E2_STEP_PIN)
380
 
383
 
381
 // E3 Stepper
384
 // E3 Stepper
382
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E3_IS_L6470)
385
+#if ENABLED(E3_IS_L6470)
383
   extern L6470 stepperE3;
386
   extern L6470 stepperE3;
384
   #define E3_ENABLE_INIT NOOP
387
   #define E3_ENABLE_INIT NOOP
385
   #define E3_ENABLE_WRITE(STATE) do{ if (STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree(); }while(0)
388
   #define E3_ENABLE_WRITE(STATE) do{ if (STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree(); }while(0)
394
     #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE)
397
     #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE)
395
     #define E3_ENABLE_READ stepperE3.isEnabled()
398
     #define E3_ENABLE_READ stepperE3.isEnabled()
396
   #else
399
   #else
397
-    #if ENABLED(HAVE_TMC2130) && ENABLED(E3_IS_TMC2130)
400
+    #if ENABLED(E3_IS_TMC2130)
398
       extern TMC2130Stepper stepperE3;
401
       extern TMC2130Stepper stepperE3;
399
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(E3_IS_TMC2208)
402
+    #elif ENABLED(E3_IS_TMC2208)
400
       extern TMC2208Stepper stepperE3;
403
       extern TMC2208Stepper stepperE3;
401
     #endif
404
     #endif
402
     #define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
405
     #define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
412
 #define E3_STEP_READ READ(E3_STEP_PIN)
415
 #define E3_STEP_READ READ(E3_STEP_PIN)
413
 
416
 
414
 // E4 Stepper
417
 // E4 Stepper
415
-#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E4_IS_L6470)
418
+#if ENABLED(E4_IS_L6470)
416
   extern L6470 stepperE4;
419
   extern L6470 stepperE4;
417
   #define E4_ENABLE_INIT NOOP
420
   #define E4_ENABLE_INIT NOOP
418
   #define E4_ENABLE_WRITE(STATE) do{ if (STATE) stepperE4.Step_Clock(stepperE4.getStatus() & STATUS_HIZ); else stepperE4.softFree(); }while(0)
421
   #define E4_ENABLE_WRITE(STATE) do{ if (STATE) stepperE4.Step_Clock(stepperE4.getStatus() & STATUS_HIZ); else stepperE4.softFree(); }while(0)
427
     #define E4_ENABLE_WRITE(STATE) stepperE4.setEnabled(STATE)
430
     #define E4_ENABLE_WRITE(STATE) stepperE4.setEnabled(STATE)
428
     #define E4_ENABLE_READ stepperE4.isEnabled()
431
     #define E4_ENABLE_READ stepperE4.isEnabled()
429
   #else
432
   #else
430
-    #if ENABLED(HAVE_TMC2130) && ENABLED(E4_IS_TMC2130)
433
+    #if ENABLED(E4_IS_TMC2130)
431
       extern TMC2130Stepper stepperE4;
434
       extern TMC2130Stepper stepperE4;
432
-    #elif ENABLED(HAVE_TMC2208) && ENABLED(E4_IS_TMC2208)
435
+    #elif ENABLED(E4_IS_TMC2208)
433
       extern TMC2208Stepper stepperE4;
436
       extern TMC2208Stepper stepperE4;
434
     #endif
437
     #endif
435
     #define E4_ENABLE_INIT SET_OUTPUT(E4_ENABLE_PIN)
438
     #define E4_ENABLE_INIT SET_OUTPUT(E4_ENABLE_PIN)

Loading…
Отказ
Запис