Browse Source

Bring SPI_SENSORLESS code up to date (#15560)

Markus Towara 5 years ago
parent
commit
437978d349
2 changed files with 11 additions and 29 deletions
  1. 5
    23
      Marlin/src/feature/tmc_util.h
  2. 6
    6
      Marlin/src/module/endstops.cpp

+ 5
- 23
Marlin/src/feature/tmc_util.h View File

@@ -393,34 +393,16 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
393 393
 
394 394
     template<class TMC, char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
395 395
     bool TMCMarlin<TMC, AXIS_LETTER, DRIVER_ID, AXIS_ID>::test_stall_status() {
396
-      uint16_t sg_result = 0;
397
-
398 396
       this->switchCSpin(LOW);
399 397
 
400
-      if (this->TMC_SW_SPI != nullptr) {
401
-        this->TMC_SW_SPI->transfer(TMC2130_n::DRV_STATUS_t::address);
402
-        this->TMC_SW_SPI->transfer16(0);
403
-        // We only care about the last 10 bits
404
-        sg_result = this->TMC_SW_SPI->transfer(0);
405
-        sg_result <<= 8;
406
-        sg_result |= this->TMC_SW_SPI->transfer(0);
407
-      }
408
-      else {
409
-        SPI.beginTransaction(SPISettings(16000000/8, MSBFIRST, SPI_MODE3));
410
-        // Read DRV_STATUS
411
-        SPI.transfer(TMC2130_n::DRV_STATUS_t::address);
412
-        SPI.transfer16(0);
413
-        // We only care about the last 10 bits
414
-        sg_result = SPI.transfer(0);
415
-        sg_result <<= 8;
416
-        sg_result |= SPI.transfer(0);
417
-        SPI.endTransaction();
418
-      }
398
+      // read stallGuard flag from TMC library, will handle HW and SW SPI
399
+      TMC2130_n::DRV_STATUS_t drv_status{0};
400
+      drv_status.sr = this->DRV_STATUS();
401
+
419 402
       this->switchCSpin(HIGH);
420 403
 
421
-      return (sg_result & 0x3FF) == 0;
404
+      return drv_status.stallGuard;
422 405
     }
423
-
424 406
   #endif // SPI_ENDSTOPS
425 407
 
426 408
 #endif // USE_SENSORLESS

+ 6
- 6
Marlin/src/module/endstops.cpp View File

@@ -537,7 +537,7 @@ void Endstops::update() {
537 537
   /**
538 538
    * Check and update endstops
539 539
    */
540
-  #if HAS_X_MIN
540
+  #if HAS_X_MIN && !X_SPI_SENSORLESS
541 541
     #if ENABLED(X_DUAL_ENDSTOPS)
542 542
       UPDATE_ENDSTOP_BIT(X, MIN);
543 543
       #if HAS_X2_MIN
@@ -550,7 +550,7 @@ void Endstops::update() {
550 550
     #endif
551 551
   #endif
552 552
 
553
-  #if HAS_X_MAX
553
+  #if HAS_X_MAX && !X_SPI_SENSORLESS
554 554
     #if ENABLED(X_DUAL_ENDSTOPS)
555 555
       UPDATE_ENDSTOP_BIT(X, MAX);
556 556
       #if HAS_X2_MAX
@@ -563,7 +563,7 @@ void Endstops::update() {
563 563
     #endif
564 564
   #endif
565 565
 
566
-  #if HAS_Y_MIN
566
+  #if HAS_Y_MIN && !Y_SPI_SENSORLESS
567 567
     #if ENABLED(Y_DUAL_ENDSTOPS)
568 568
       UPDATE_ENDSTOP_BIT(Y, MIN);
569 569
       #if HAS_Y2_MIN
@@ -576,7 +576,7 @@ void Endstops::update() {
576 576
     #endif
577 577
   #endif
578 578
 
579
-  #if HAS_Y_MAX
579
+  #if HAS_Y_MAX && !Y_SPI_SENSORLESS
580 580
     #if ENABLED(Y_DUAL_ENDSTOPS)
581 581
       UPDATE_ENDSTOP_BIT(Y, MAX);
582 582
       #if HAS_Y2_MAX
@@ -589,7 +589,7 @@ void Endstops::update() {
589 589
     #endif
590 590
   #endif
591 591
 
592
-  #if HAS_Z_MIN
592
+  #if HAS_Z_MIN && !Z_SPI_SENSORLESS
593 593
     #if Z_MULTI_ENDSTOPS
594 594
       UPDATE_ENDSTOP_BIT(Z, MIN);
595 595
       #if HAS_Z2_MIN
@@ -616,7 +616,7 @@ void Endstops::update() {
616 616
     UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
617 617
   #endif
618 618
 
619
-  #if HAS_Z_MAX
619
+  #if HAS_Z_MAX && !Z_SPI_SENSORLESS
620 620
     // Check both Z dual endstops
621 621
     #if Z_MULTI_ENDSTOPS
622 622
       UPDATE_ENDSTOP_BIT(Z, MAX);

Loading…
Cancel
Save