Bring SPI_SENSORLESS code up to date (#15560)

This commit is contained in:
Markus Towara 2019-10-15 18:34:45 +02:00 committed by Scott Lahteine
parent b4f82d1081
commit 437978d349
2 changed files with 11 additions and 29 deletions

View File

@ -393,34 +393,16 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
template<class TMC, char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<class TMC, char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
bool TMCMarlin<TMC, AXIS_LETTER, DRIVER_ID, AXIS_ID>::test_stall_status() { bool TMCMarlin<TMC, AXIS_LETTER, DRIVER_ID, AXIS_ID>::test_stall_status() {
uint16_t sg_result = 0;
this->switchCSpin(LOW); this->switchCSpin(LOW);
if (this->TMC_SW_SPI != nullptr) { // read stallGuard flag from TMC library, will handle HW and SW SPI
this->TMC_SW_SPI->transfer(TMC2130_n::DRV_STATUS_t::address); TMC2130_n::DRV_STATUS_t drv_status{0};
this->TMC_SW_SPI->transfer16(0); drv_status.sr = this->DRV_STATUS();
// We only care about the last 10 bits
sg_result = this->TMC_SW_SPI->transfer(0);
sg_result <<= 8;
sg_result |= this->TMC_SW_SPI->transfer(0);
}
else {
SPI.beginTransaction(SPISettings(16000000/8, MSBFIRST, SPI_MODE3));
// Read DRV_STATUS
SPI.transfer(TMC2130_n::DRV_STATUS_t::address);
SPI.transfer16(0);
// We only care about the last 10 bits
sg_result = SPI.transfer(0);
sg_result <<= 8;
sg_result |= SPI.transfer(0);
SPI.endTransaction();
}
this->switchCSpin(HIGH); this->switchCSpin(HIGH);
return (sg_result & 0x3FF) == 0; return drv_status.stallGuard;
} }
#endif // SPI_ENDSTOPS #endif // SPI_ENDSTOPS
#endif // USE_SENSORLESS #endif // USE_SENSORLESS

View File

@ -537,7 +537,7 @@ void Endstops::update() {
/** /**
* Check and update endstops * Check and update endstops
*/ */
#if HAS_X_MIN #if HAS_X_MIN && !X_SPI_SENSORLESS
#if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(X_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(X, MIN); UPDATE_ENDSTOP_BIT(X, MIN);
#if HAS_X2_MIN #if HAS_X2_MIN
@ -550,7 +550,7 @@ void Endstops::update() {
#endif #endif
#endif #endif
#if HAS_X_MAX #if HAS_X_MAX && !X_SPI_SENSORLESS
#if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(X_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(X, MAX); UPDATE_ENDSTOP_BIT(X, MAX);
#if HAS_X2_MAX #if HAS_X2_MAX
@ -563,7 +563,7 @@ void Endstops::update() {
#endif #endif
#endif #endif
#if HAS_Y_MIN #if HAS_Y_MIN && !Y_SPI_SENSORLESS
#if ENABLED(Y_DUAL_ENDSTOPS) #if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MIN); UPDATE_ENDSTOP_BIT(Y, MIN);
#if HAS_Y2_MIN #if HAS_Y2_MIN
@ -576,7 +576,7 @@ void Endstops::update() {
#endif #endif
#endif #endif
#if HAS_Y_MAX #if HAS_Y_MAX && !Y_SPI_SENSORLESS
#if ENABLED(Y_DUAL_ENDSTOPS) #if ENABLED(Y_DUAL_ENDSTOPS)
UPDATE_ENDSTOP_BIT(Y, MAX); UPDATE_ENDSTOP_BIT(Y, MAX);
#if HAS_Y2_MAX #if HAS_Y2_MAX
@ -589,7 +589,7 @@ void Endstops::update() {
#endif #endif
#endif #endif
#if HAS_Z_MIN #if HAS_Z_MIN && !Z_SPI_SENSORLESS
#if Z_MULTI_ENDSTOPS #if Z_MULTI_ENDSTOPS
UPDATE_ENDSTOP_BIT(Z, MIN); UPDATE_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN #if HAS_Z2_MIN
@ -616,7 +616,7 @@ void Endstops::update() {
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
#endif #endif
#if HAS_Z_MAX #if HAS_Z_MAX && !Z_SPI_SENSORLESS
// Check both Z dual endstops // Check both Z dual endstops
#if Z_MULTI_ENDSTOPS #if Z_MULTI_ENDSTOPS
UPDATE_ENDSTOP_BIT(Z, MAX); UPDATE_ENDSTOP_BIT(Z, MAX);