Przeglądaj źródła

TMC SPI Endstops and Improved Sensorless Homing (#14044)

teemuatlut 4 lat temu
rodzic
commit
d4974ea719

+ 17
- 7
Marlin/Configuration_adv.h Wyświetl plik

1851
   #define E5_HYBRID_THRESHOLD     30
1851
   #define E5_HYBRID_THRESHOLD     30
1852
 
1852
 
1853
   /**
1853
   /**
1854
+   * Use StallGuard2 to home / probe X, Y, Z.
1855
+   *
1854
    * TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
1856
    * TMC2130, TMC2160, TMC2209, TMC2660, TMC5130, and TMC5160 only
1855
-   * Use StallGuard2 to sense an obstacle and trigger an endstop.
1856
    * Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
1857
    * Connect the stepper driver's DIAG1 pin to the X/Y endstop pin.
1857
    * X, Y, and Z homing will always be done in spreadCycle mode.
1858
    * X, Y, and Z homing will always be done in spreadCycle mode.
1858
    *
1859
    *
1859
-   * X/Y/Z_STALL_SENSITIVITY is used for tuning the trigger sensitivity.
1860
-   * Higher values make the system LESS sensitive.
1861
-   * Lower value make the system MORE sensitive.
1862
-   * Too low values can lead to false positives, while too high values will collide the axis without triggering.
1863
-   * It is advised to set X/Y/Z_HOME_BUMP_MM to 0.
1864
-   * M914 X/Y/Z to live tune the setting
1860
+   * X/Y/Z_STALL_SENSITIVITY is used to tune the trigger sensitivity.
1861
+   * Use M914 X Y Z to live-adjust the sensitivity.
1862
+   *  Higher: LESS sensitive. (Too high => failure to trigger)
1863
+   *   Lower: MORE sensitive. (Too low  => false positives)
1864
+   *
1865
+   * It is recommended to set [XYZ]_HOME_BUMP_MM to 0.
1866
+   *
1867
+   * SPI_ENDSTOPS  *** Beta feature! *** TMC2130 Only ***
1868
+   * Poll the driver through SPI to determine load when homing.
1869
+   * Removes the need for a wire from DIAG1 to an endstop pin.
1870
+   *
1871
+   * IMPROVE_HOMING_RELIABILITY tunes acceleration and jerk when
1872
+   * homing and adds a guard period for endstop triggering.
1865
    */
1873
    */
1866
   //#define SENSORLESS_HOMING // StallGuard capable drivers only
1874
   //#define SENSORLESS_HOMING // StallGuard capable drivers only
1867
 
1875
 
1878
     #define X_STALL_SENSITIVITY  8
1886
     #define X_STALL_SENSITIVITY  8
1879
     #define Y_STALL_SENSITIVITY  8
1887
     #define Y_STALL_SENSITIVITY  8
1880
     //#define Z_STALL_SENSITIVITY  8
1888
     //#define Z_STALL_SENSITIVITY  8
1889
+    //#define SPI_ENDSTOPS              // TMC2130 only
1890
+    //#define IMPROVE_HOMING_RELIABILITY
1881
   #endif
1891
   #endif
1882
 
1892
 
1883
   /**
1893
   /**

+ 7
- 0
Marlin/src/Marlin.cpp Wyświetl plik

659
     bool no_stepper_sleep/*=false*/
659
     bool no_stepper_sleep/*=false*/
660
   #endif
660
   #endif
661
 ) {
661
 ) {
662
+
663
+  #if ENABLED(SPI_ENDSTOPS)
664
+    if (endstops.tmc_spi_homing.any && ELAPSED(millis(), sg_guard_period))
665
+      for (uint8_t i = 4; i--;) // Read SGT 4 times per idle loop
666
+        if (endstops.tmc_spi_homing_check()) break;
667
+  #endif
668
+
662
   #if ENABLED(MAX7219_DEBUG)
669
   #if ENABLED(MAX7219_DEBUG)
663
     max7219.idle_tasks();
670
     max7219.idle_tasks();
664
   #endif
671
   #endif

+ 52
- 1
Marlin/src/feature/tmc_util.h Wyświetl plik

140
           this->stored.homing_thrs = sgt_val;
140
           this->stored.homing_thrs = sgt_val;
141
         #endif
141
         #endif
142
       }
142
       }
143
+      #if ENABLED(SPI_ENDSTOPS)
144
+        bool test_stall_status();
145
+      #endif
143
     #endif
146
     #endif
144
 
147
 
145
     #if HAS_LCD_MENU
148
     #if HAS_LCD_MENU
355
  * Defined here because of limitations with templates and headers.
358
  * Defined here because of limitations with templates and headers.
356
  */
359
  */
357
 #if USE_SENSORLESS
360
 #if USE_SENSORLESS
361
+
358
   // Track enabled status of stealthChop and only re-enable where applicable
362
   // Track enabled status of stealthChop and only re-enable where applicable
359
   struct sensorless_t { bool x, y, z, x2, y2, z2, z3; };
363
   struct sensorless_t { bool x, y, z, x2, y2, z2, z3; };
360
 
364
 
365
+  #if ENABLED(IMPROVE_HOMING_RELIABILITY)
366
+    extern millis_t sg_guard_period;
367
+    constexpr uint16_t default_sg_guard_duration = 400;
368
+
369
+    struct slow_homing_t {
370
+      struct { uint32_t x, y; } acceleration;
371
+      #if HAS_CLASSIC_JERK
372
+        struct { float x, y; } jerk;
373
+      #endif
374
+    };
375
+  #endif
376
+
361
   bool tmc_enable_stallguard(TMC2130Stepper &st);
377
   bool tmc_enable_stallguard(TMC2130Stepper &st);
362
   void tmc_disable_stallguard(TMC2130Stepper &st, const bool restore_stealth);
378
   void tmc_disable_stallguard(TMC2130Stepper &st, const bool restore_stealth);
363
 
379
 
366
 
382
 
367
   bool tmc_enable_stallguard(TMC2660Stepper);
383
   bool tmc_enable_stallguard(TMC2660Stepper);
368
   void tmc_disable_stallguard(TMC2660Stepper, const bool);
384
   void tmc_disable_stallguard(TMC2660Stepper, const bool);
369
-#endif
385
+
386
+  #if ENABLED(SPI_ENDSTOPS)
387
+
388
+    template<class TMC, char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
389
+    bool TMCMarlin<TMC, AXIS_LETTER, DRIVER_ID, AXIS_ID>::test_stall_status() {
390
+      uint16_t sg_result = 0;
391
+
392
+      this->switchCSpin(LOW);
393
+
394
+      if (this->TMC_SW_SPI != nullptr) {
395
+        this->TMC_SW_SPI->transfer(TMC2130_n::DRV_STATUS_t::address);
396
+        this->TMC_SW_SPI->transfer16(0);
397
+        // We only care about the last 10 bits
398
+        sg_result = this->TMC_SW_SPI->transfer(0);
399
+        sg_result <<= 8;
400
+        sg_result |= this->TMC_SW_SPI->transfer(0);
401
+      }
402
+      else {
403
+        SPI.beginTransaction(SPISettings(16000000/8, MSBFIRST, SPI_MODE3));
404
+        // Read DRV_STATUS
405
+        SPI.transfer(TMC2130_n::DRV_STATUS_t::address);
406
+        SPI.transfer16(0);
407
+        // We only care about the last 10 bits
408
+        sg_result = SPI.transfer(0);
409
+        sg_result <<= 8;
410
+        sg_result |= SPI.transfer(0);
411
+        SPI.endTransaction();
412
+      }
413
+      this->switchCSpin(HIGH);
414
+
415
+      return (sg_result & 0x3FF) == 0;
416
+    }
417
+
418
+  #endif // SPI_ENDSTOPS
419
+
420
+#endif // USE_SENSORLESS
370
 
421
 
371
 #if TMC_HAS_SPI
422
 #if TMC_HAS_SPI
372
   void tmc_init_cs_pins();
423
   void tmc_init_cs_pins();

+ 45
- 9
Marlin/src/gcode/calibrate/G28.cpp Wyświetl plik

78
                 fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
78
                 fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0);
79
 
79
 
80
     #if ENABLED(SENSORLESS_HOMING)
80
     #if ENABLED(SENSORLESS_HOMING)
81
-      sensorless_t stealth_states { false };
82
-      stealth_states.x = tmc_enable_stallguard(stepperX);
83
-      stealth_states.y = tmc_enable_stallguard(stepperY);
84
-      #if AXIS_HAS_STALLGUARD(X2)
85
-        stealth_states.x2 = tmc_enable_stallguard(stepperX2);
86
-      #endif
87
-      #if AXIS_HAS_STALLGUARD(Y2)
88
-        stealth_states.y2 = tmc_enable_stallguard(stepperY2);
89
-      #endif
81
+      sensorless_t stealth_states {
82
+          tmc_enable_stallguard(stepperX)
83
+        , tmc_enable_stallguard(stepperY)
84
+        , false
85
+        , false
86
+          #if AXIS_HAS_STALLGUARD(X2)
87
+            || tmc_enable_stallguard(stepperX2)
88
+          #endif
89
+        , false
90
+          #if AXIS_HAS_STALLGUARD(Y2)
91
+            || tmc_enable_stallguard(stepperY2)
92
+          #endif
93
+      };
90
     #endif
94
     #endif
91
 
95
 
92
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
96
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
229
     workspace_plane = PLANE_XY;
233
     workspace_plane = PLANE_XY;
230
   #endif
234
   #endif
231
 
235
 
236
+  #if ENABLED(IMPROVE_HOMING_RELIABILITY)
237
+    slow_homing_t slow_homing { 0 };
238
+    slow_homing.acceleration.x = planner.settings.max_acceleration_mm_per_s2[X_AXIS];
239
+    slow_homing.acceleration.y = planner.settings.max_acceleration_mm_per_s2[Y_AXIS];
240
+    planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
241
+    planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
242
+    #if HAS_CLASSIC_JERK
243
+      slow_homing.jerk.x = planner.max_jerk[X_AXIS];
244
+      slow_homing.jerk.y = planner.max_jerk[Y_AXIS];
245
+      planner.max_jerk[X_AXIS] = 0;
246
+      planner.max_jerk[Y_AXIS] = 0;
247
+    #endif
248
+
249
+    planner.reset_acceleration_rates();
250
+  #endif
251
+
232
   // Always home with tool 0 active
252
   // Always home with tool 0 active
233
   #if HOTENDS > 1
253
   #if HOTENDS > 1
234
     #if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
254
     #if DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE)
393
 
413
 
394
   endstops.not_homing();
414
   endstops.not_homing();
395
 
415
 
416
+  // Clear endstop state for polled stallGuard endstops
417
+  #if ENABLED(SPI_ENDSTOPS)
418
+    endstops.clear_endstop_state();
419
+  #endif
420
+
396
   #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
421
   #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
397
     // move to a height where we can use the full xy-area
422
     // move to a height where we can use the full xy-area
398
     do_blocking_move_to_z(delta_clip_start_height);
423
     do_blocking_move_to_z(delta_clip_start_height);
414
     tool_change(old_tool_index, NO_FETCH);
439
     tool_change(old_tool_index, NO_FETCH);
415
   #endif
440
   #endif
416
 
441
 
442
+  #if ENABLED(IMPROVE_HOMING_RELIABILITY)
443
+    planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
444
+    planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
445
+    #if HAS_CLASSIC_JERK
446
+      planner.max_jerk[X_AXIS] = slow_homing.jerk.x;
447
+      planner.max_jerk[Y_AXIS] = slow_homing.jerk.y;
448
+    #endif
449
+
450
+    planner.reset_acceleration_rates();
451
+  #endif
452
+
417
   ui.refresh();
453
   ui.refresh();
418
 
454
 
419
   report_current_position();
455
   report_current_position();

+ 5
- 0
Marlin/src/inc/Conditionals_post.h Wyświetl plik

920
   #define X_SENSORLESS (AXIS_HAS_STALLGUARD(X) && defined(X_STALL_SENSITIVITY))
920
   #define X_SENSORLESS (AXIS_HAS_STALLGUARD(X) && defined(X_STALL_SENSITIVITY))
921
   #define Y_SENSORLESS (AXIS_HAS_STALLGUARD(Y) && defined(Y_STALL_SENSITIVITY))
921
   #define Y_SENSORLESS (AXIS_HAS_STALLGUARD(Y) && defined(Y_STALL_SENSITIVITY))
922
   #define Z_SENSORLESS (AXIS_HAS_STALLGUARD(Z) && defined(Z_STALL_SENSITIVITY))
922
   #define Z_SENSORLESS (AXIS_HAS_STALLGUARD(Z) && defined(Z_STALL_SENSITIVITY))
923
+  #if ENABLED(SPI_ENDSTOPS)
924
+    #define X_SPI_SENSORLESS X_SENSORLESS
925
+    #define Y_SPI_SENSORLESS Y_SENSORLESS
926
+    #define Z_SPI_SENSORLESS Z_SENSORLESS
927
+  #endif
923
 #endif
928
 #endif
924
 
929
 
925
 // Endstops and bed probe
930
 // Endstops and bed probe

+ 5
- 4
Marlin/src/module/delta.cpp Wyświetl plik

227
 
227
 
228
   // Disable stealthChop if used. Enable diag1 pin on driver.
228
   // Disable stealthChop if used. Enable diag1 pin on driver.
229
   #if ENABLED(SENSORLESS_HOMING)
229
   #if ENABLED(SENSORLESS_HOMING)
230
-    sensorless_t stealth_states { false };
231
-    stealth_states.x = tmc_enable_stallguard(stepperX);
232
-    stealth_states.y = tmc_enable_stallguard(stepperY);
233
-    stealth_states.z = tmc_enable_stallguard(stepperZ);
230
+    sensorless_t stealth_states {
231
+      tmc_enable_stallguard(stepperX),
232
+      tmc_enable_stallguard(stepperY),
233
+      tmc_enable_stallguard(stepperZ)
234
+    };
234
   #endif
235
   #endif
235
 
236
 
236
   // Move all carriages together linearly until an endstop is hit.
237
   // Move all carriages together linearly until an endstop is hit.

+ 56
- 6
Marlin/src/module/endstops.cpp Wyświetl plik

76
   float Endstops::z3_endstop_adj;
76
   float Endstops::z3_endstop_adj;
77
 #endif
77
 #endif
78
 
78
 
79
+#if ENABLED(SPI_ENDSTOPS)
80
+  Endstops::tmc_spi_homing_t Endstops::tmc_spi_homing; // = 0
81
+#endif
82
+#if ENABLED(IMPROVE_HOMING_RELIABILITY)
83
+  millis_t sg_guard_period; // = 0
84
+#endif
85
+
79
 /**
86
 /**
80
  * Class and Instance Methods
87
  * Class and Instance Methods
81
  */
88
  */
699
   // Now, we must signal, after validation, if an endstop limit is pressed or not
706
   // Now, we must signal, after validation, if an endstop limit is pressed or not
700
   if (stepper.axis_is_moving(X_AXIS)) {
707
   if (stepper.axis_is_moving(X_AXIS)) {
701
     if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
708
     if (stepper.motor_direction(X_AXIS_HEAD)) { // -direction
702
-      #if HAS_X_MIN
709
+      #if HAS_X_MIN || (X_SPI_SENSORLESS && X_HOME_DIR < 0)
703
         #if ENABLED(X_DUAL_ENDSTOPS)
710
         #if ENABLED(X_DUAL_ENDSTOPS)
704
           PROCESS_DUAL_ENDSTOP(X, X2, MIN);
711
           PROCESS_DUAL_ENDSTOP(X, X2, MIN);
705
         #else
712
         #else
708
       #endif
715
       #endif
709
     }
716
     }
710
     else { // +direction
717
     else { // +direction
711
-      #if HAS_X_MAX
718
+      #if HAS_X_MAX || (X_SPI_SENSORLESS && X_HOME_DIR > 0)
712
         #if ENABLED(X_DUAL_ENDSTOPS)
719
         #if ENABLED(X_DUAL_ENDSTOPS)
713
           PROCESS_DUAL_ENDSTOP(X, X2, MAX);
720
           PROCESS_DUAL_ENDSTOP(X, X2, MAX);
714
         #else
721
         #else
720
 
727
 
721
   if (stepper.axis_is_moving(Y_AXIS)) {
728
   if (stepper.axis_is_moving(Y_AXIS)) {
722
     if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
729
     if (stepper.motor_direction(Y_AXIS_HEAD)) { // -direction
723
-      #if HAS_Y_MIN
730
+      #if HAS_Y_MIN || (Y_SPI_SENSORLESS && Y_HOME_DIR < 0)
724
         #if ENABLED(Y_DUAL_ENDSTOPS)
731
         #if ENABLED(Y_DUAL_ENDSTOPS)
725
           PROCESS_DUAL_ENDSTOP(Y, Y2, MIN);
732
           PROCESS_DUAL_ENDSTOP(Y, Y2, MIN);
726
         #else
733
         #else
729
       #endif
736
       #endif
730
     }
737
     }
731
     else { // +direction
738
     else { // +direction
732
-      #if HAS_Y_MAX
739
+      #if HAS_Y_MAX || (Y_SPI_SENSORLESS && Y_HOME_DIR > 0)
733
         #if ENABLED(Y_DUAL_ENDSTOPS)
740
         #if ENABLED(Y_DUAL_ENDSTOPS)
734
           PROCESS_DUAL_ENDSTOP(Y, Y2, MAX);
741
           PROCESS_DUAL_ENDSTOP(Y, Y2, MAX);
735
         #else
742
         #else
741
 
748
 
742
   if (stepper.axis_is_moving(Z_AXIS)) {
749
   if (stepper.axis_is_moving(Z_AXIS)) {
743
     if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
750
     if (stepper.motor_direction(Z_AXIS_HEAD)) { // Z -direction. Gantry down, bed up.
744
-      #if HAS_Z_MIN
751
+      #if HAS_Z_MIN || (Z_SPI_SENSORLESS && Z_HOME_DIR < 0)
745
         #if ENABLED(Z_TRIPLE_ENDSTOPS)
752
         #if ENABLED(Z_TRIPLE_ENDSTOPS)
746
           PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MIN);
753
           PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MIN);
747
         #elif ENABLED(Z_DUAL_ENDSTOPS)
754
         #elif ENABLED(Z_DUAL_ENDSTOPS)
763
       #endif
770
       #endif
764
     }
771
     }
765
     else { // Z +direction. Gantry up, bed down.
772
     else { // Z +direction. Gantry up, bed down.
766
-      #if HAS_Z_MAX
773
+      #if HAS_Z_MAX || (Z_SPI_SENSORLESS && Z_HOME_DIR > 0)
767
         #if ENABLED(Z_TRIPLE_ENDSTOPS)
774
         #if ENABLED(Z_TRIPLE_ENDSTOPS)
768
           PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MAX);
775
           PROCESS_TRIPLE_ENDSTOP(Z, Z2, Z3, MAX);
769
         #elif ENABLED(Z_DUAL_ENDSTOPS)
776
         #elif ENABLED(Z_DUAL_ENDSTOPS)
778
   }
785
   }
779
 } // Endstops::update()
786
 } // Endstops::update()
780
 
787
 
788
+#if ENABLED(SPI_ENDSTOPS)
789
+
790
+  #define X_STOP (X_HOME_DIR < 0 ? X_MIN : X_MAX)
791
+  #define Y_STOP (Y_HOME_DIR < 0 ? Y_MIN : Y_MAX)
792
+  #define Z_STOP (Z_HOME_DIR < 0 ? Z_MIN : Z_MAX)
793
+
794
+  bool Endstops::tmc_spi_homing_check() {
795
+    bool hit = false;
796
+    #if X_SPI_SENSORLESS
797
+      if (tmc_spi_homing.x && stepperX.test_stall_status()) {
798
+        SBI(live_state, X_STOP);
799
+        hit = true;
800
+      }
801
+    #endif
802
+    #if Y_SPI_SENSORLESS
803
+      if (tmc_spi_homing.y && stepperY.test_stall_status()) {
804
+        SBI(live_state, Y_STOP);
805
+        hit = true;
806
+      }
807
+    #endif
808
+    #if Z_SPI_SENSORLESS
809
+      if (tmc_spi_homing.z && stepperZ.test_stall_status()) {
810
+        SBI(live_state, Z_STOP);
811
+        hit = true;
812
+      }
813
+    #endif
814
+    return hit;
815
+  }
816
+
817
+  void Endstops::clear_endstop_state() {
818
+    #if X_SPI_SENSORLESS
819
+      CBI(live_state, X_STOP);
820
+    #endif
821
+    #if Y_SPI_SENSORLESS
822
+      CBI(live_state, Y_STOP);
823
+    #endif
824
+    #if Z_SPI_SENSORLESS
825
+      CBI(live_state, Z_STOP);
826
+    #endif
827
+  }
828
+
829
+#endif // SPI_ENDSTOPS
830
+
781
 #if ENABLED(PINS_DEBUGGING)
831
 #if ENABLED(PINS_DEBUGGING)
782
 
832
 
783
   bool Endstops::monitor_flag = false;
833
   bool Endstops::monitor_flag = false;

+ 12
- 0
Marlin/src/module/endstops.h Wyświetl plik

161
       static void monitor();
161
       static void monitor();
162
       static void run_monitor();
162
       static void run_monitor();
163
     #endif
163
     #endif
164
+
165
+    #if ENABLED(SPI_ENDSTOPS)
166
+      typedef struct {
167
+        union {
168
+          bool any;
169
+          struct { bool x:1, y:1, z:1; };
170
+        };
171
+      } tmc_spi_homing_t;
172
+      static tmc_spi_homing_t tmc_spi_homing;
173
+      static void clear_endstop_state();
174
+      static bool tmc_spi_homing_check();
175
+    #endif
164
 };
176
 };
165
 
177
 
166
 extern Endstops endstops;
178
 extern Endstops endstops;

+ 52
- 2
Marlin/src/module/motion.cpp Wyświetl plik

1121
           break;
1121
           break;
1122
       #endif
1122
       #endif
1123
     }
1123
     }
1124
+
1125
+    #if ENABLED(SPI_ENDSTOPS)
1126
+      switch (axis) {
1127
+        #if X_SPI_SENSORLESS
1128
+          case X_AXIS: endstops.tmc_spi_homing.x = true; break;
1129
+        #endif
1130
+        #if Y_SPI_SENSORLESS
1131
+          case Y_AXIS: endstops.tmc_spi_homing.y = true; break;
1132
+        #endif
1133
+        #if Z_SPI_SENSORLESS
1134
+          case Z_AXIS: endstops.tmc_spi_homing.z = true; break;
1135
+        #endif
1136
+        default: break;
1137
+      }
1138
+    #endif
1139
+
1140
+    #if ENABLED(IMPROVE_HOMING_RELIABILITY)
1141
+      sg_guard_period = millis() + default_sg_guard_duration;
1142
+    #endif
1143
+
1124
     return stealth_states;
1144
     return stealth_states;
1125
   }
1145
   }
1126
 
1146
 
1170
           break;
1190
           break;
1171
       #endif
1191
       #endif
1172
     }
1192
     }
1193
+
1194
+    #if ENABLED(SPI_ENDSTOPS)
1195
+      switch (axis) {
1196
+        #if X_SPI_SENSORLESS
1197
+          case X_AXIS: endstops.tmc_spi_homing.x = false; break;
1198
+        #endif
1199
+        #if Y_SPI_SENSORLESS
1200
+          case Y_AXIS: endstops.tmc_spi_homing.y = false; break;
1201
+        #endif
1202
+        #if Z_SPI_SENSORLESS
1203
+          case Z_AXIS: endstops.tmc_spi_homing.z = false; break;
1204
+        #endif
1205
+        default: break;
1206
+      }
1207
+    #endif
1173
   }
1208
   }
1174
 
1209
 
1175
 #endif // SENSORLESS_HOMING
1210
 #endif // SENSORLESS_HOMING
1383
     // Only Z homing (with probe) is permitted
1418
     // Only Z homing (with probe) is permitted
1384
     if (axis != Z_AXIS) { BUZZ(100, 880); return; }
1419
     if (axis != Z_AXIS) { BUZZ(100, 880); return; }
1385
   #else
1420
   #else
1386
-    #define CAN_HOME(A) \
1421
+    #define _CAN_HOME(A) \
1387
       (axis == _AXIS(A) && ((A##_MIN_PIN > -1 && A##_HOME_DIR < 0) || (A##_MAX_PIN > -1 && A##_HOME_DIR > 0)))
1422
       (axis == _AXIS(A) && ((A##_MIN_PIN > -1 && A##_HOME_DIR < 0) || (A##_MAX_PIN > -1 && A##_HOME_DIR > 0)))
1388
-    if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
1423
+    #if X_SPI_SENSORLESS
1424
+      #define CAN_HOME_X true
1425
+    #else
1426
+      #define CAN_HOME_X _CAN_HOME(X)
1427
+    #endif
1428
+    #if Y_SPI_SENSORLESS
1429
+      #define CAN_HOME_Y true
1430
+    #else
1431
+      #define CAN_HOME_Y _CAN_HOME(Y)
1432
+    #endif
1433
+    #if Z_SPI_SENSORLESS
1434
+      #define CAN_HOME_Z true
1435
+    #else
1436
+      #define CAN_HOME_Z _CAN_HOME(Z)
1437
+    #endif
1438
+    if (!CAN_HOME_X && !CAN_HOME_Y && !CAN_HOME_Z) return;
1389
   #endif
1439
   #endif
1390
 
1440
 
1391
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")");
1441
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")");

Ładowanie…
Anuluj
Zapisz