diff --git a/src/hal/avr/tmc2130.cpp b/src/hal/avr/tmc2130.cpp index 2a9af4b..22a140a 100644 --- a/src/hal/avr/tmc2130.cpp +++ b/src/hal/avr/tmc2130.cpp @@ -20,8 +20,8 @@ bool TMC2130::Init(const MotorParams ¶ms) { if (((IOIN >> 24) != 0x11) | !(IOIN & (1 << 6))) ///if the version is incorrect or an always 1 bit is 0 (the supposed SD_MODE pin that doesn't exist on this driver variant) return true; // @todo return some kind of failure - ///clear reset flag as we are (re)initializing - errorFlags.reset = false; + ///clear reset_flag as we are (re)initializing + errorFlags.reset_flag = false; ///apply chopper parameters uint32_t chopconf = 0; @@ -110,25 +110,8 @@ void TMC2130::_spi_tx_rx(const MotorParams ¶ms, uint8_t (&pData)[5]) { } void TMC2130::_handle_spi_status(const MotorParams ¶ms, uint8_t status) { - status &= 0x03; - if (status) { - uint32_t GSTAT = ReadRegister(params, Registers::GSTAT); - if (GSTAT & (1 << 0)) - errorFlags.reset |= true; - if (GSTAT & (1 << 1)) { - uint32_t DRV_STATUS = ReadRegister(params, Registers::DRV_STATUS); - if (DRV_STATUS & (1ul << 25)) - errorFlags.ot |= true; - if (DRV_STATUS & (1ul << 26)) - errorFlags.otpw |= true; - if (DRV_STATUS & (1ul << 27)) - errorFlags.s2ga |= true; - if (DRV_STATUS & (1ul << 28)) - errorFlags.s2gb |= true; - } - if (GSTAT & (1 << 2)) - errorFlags.uv_cp |= true; - } + errorFlags.reset_flag |= status & (1 << 0); + errorFlags.driver_error |= status & (1 << 1); } } // namespace tmc2130 diff --git a/src/hal/tmc2130.h b/src/hal/tmc2130.h index ca26333..2e845c5 100644 --- a/src/hal/tmc2130.h +++ b/src/hal/tmc2130.h @@ -36,12 +36,8 @@ class TMC2130 { MotorMode mode; MotorCurrents currents; struct __attribute__((packed)) { - uint8_t reset : 1; - uint8_t uv_cp : 1; - uint8_t s2ga : 1; - uint8_t s2gb : 1; - uint8_t otpw : 1; - uint8_t ot : 1; + uint8_t reset_flag : 1; + uint8_t driver_error : 1; } errorFlags; bool enabled = false;