From a61c741a663bb7ba1699e60a13c4ed53ca95b0c6 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 9 Oct 2022 22:13:00 +0200 Subject: [PATCH] Make sure the error flags are turned into bools --- src/hal/tmc2130.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hal/tmc2130.cpp b/src/hal/tmc2130.cpp index 597b512..eb00727 100644 --- a/src/hal/tmc2130.cpp +++ b/src/hal/tmc2130.cpp @@ -104,11 +104,11 @@ void TMC2130::SetEnabled(const MotorParams ¶ms, bool enabled) { bool TMC2130::CheckForErrors(const MotorParams ¶ms) { uint32_t GSTAT = ReadRegister(params, Registers::GSTAT); uint32_t DRV_STATUS = ReadRegister(params, Registers::DRV_STATUS); - errorFlags.reset_flag |= GSTAT & (1U << 0U); - errorFlags.uv_cp = GSTAT & (1U << 2U); - errorFlags.s2g = DRV_STATUS & (3UL << 27U); - errorFlags.otpw = DRV_STATUS & (1UL << 26U); - errorFlags.ot = DRV_STATUS & (1UL << 25U); + errorFlags.reset_flag |= !!(GSTAT & (1U << 0U)); + errorFlags.uv_cp = !!(GSTAT & (1U << 2U)); + errorFlags.s2g = !!(DRV_STATUS & (3UL << 27U)); + errorFlags.otpw = !!(DRV_STATUS & (1UL << 26U)); + errorFlags.ot = !!(DRV_STATUS & (1UL << 25U)); return GSTAT || errorFlags.reset_flag; //any bit in gstat is an error }