Only check for errors if the driver is initialized
parent
5d33c38ba8
commit
48cc5700e6
|
|
@ -9,6 +9,8 @@ namespace tmc2130 {
|
|||
static constexpr uint8_t TOFF_DEFAULT = 3U, TOFF_MASK = 0xFU;
|
||||
|
||||
bool TMC2130::Init(const MotorParams ¶ms, const MotorCurrents ¤ts, MotorMode mode) {
|
||||
initialized = false;
|
||||
|
||||
// sg_filter_threshold = (1 << (8 - params.mRes));
|
||||
sg_filter_threshold = 2;
|
||||
|
||||
|
|
@ -65,6 +67,8 @@ bool TMC2130::Init(const MotorParams ¶ms, const MotorCurrents ¤ts, Mot
|
|||
/// Stallguard is also disabled if the velocity falls below this.
|
||||
/// Should be set as high as possible when homing.
|
||||
SetMode(params, mode);
|
||||
|
||||
initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -102,6 +106,9 @@ void TMC2130::SetEnabled(const MotorParams ¶ms, bool enabled) {
|
|||
}
|
||||
|
||||
bool TMC2130::CheckForErrors(const MotorParams ¶ms) {
|
||||
if (!initialized)
|
||||
return false;
|
||||
|
||||
uint32_t GSTAT = ReadRegister(params, Registers::GSTAT);
|
||||
uint32_t DRV_STATUS = ReadRegister(params, Registers::DRV_STATUS);
|
||||
errorFlags.reset_flag |= !!(GSTAT & (1U << 0U));
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ private:
|
|||
void _handle_spi_status(const MotorParams ¶ms, uint8_t status);
|
||||
|
||||
ErrorFlags errorFlags;
|
||||
bool initialized = false;
|
||||
bool enabled = false;
|
||||
uint8_t sg_filter_threshold;
|
||||
uint8_t sg_filter_counter = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue