From 5571e77809d0d10dd672f60036351d45dd6e6783 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Fri, 27 Aug 2021 08:42:32 +0200 Subject: [PATCH] Improve/fix some comments --- src/hal/tmc2130.cpp | 7 ++++--- src/hal/tmc2130.h | 2 +- src/logic/command_base.cpp | 2 +- src/logic/error_codes.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hal/tmc2130.cpp b/src/hal/tmc2130.cpp index 73dc1d8..ef6ae33 100644 --- a/src/hal/tmc2130.cpp +++ b/src/hal/tmc2130.cpp @@ -15,7 +15,7 @@ bool TMC2130::Init(const MotorParams ¶ms, const MotorCurrents ¤ts, Mot // if the version is incorrect or a bit always set to 1 is suddenly 0 // (the supposed SD_MODE pin that doesn't exist on this driver variant) if (((IOIN >> 24U) != 0x11) | !(IOIN & (1U << 6U))) - return true; // @todo return some kind of failure + return true; // @@TODO return some kind of failure ///clear reset_flag as we are (re)initializing errorFlags.reset_flag = false; @@ -63,7 +63,7 @@ bool TMC2130::Init(const MotorParams ¶ms, const MotorCurrents ¤ts, Mot void TMC2130::SetMode(const MotorParams ¶ms, MotorMode mode) { ///0xFFF00 is used as a "Normal" mode threshold since stealthchop will be used at standstill. - WriteRegister(params, Registers::TPWMTHRS, (mode == Stealth) ? 70 : 0xFFF00); // @todo should be configurable + WriteRegister(params, Registers::TPWMTHRS, (mode == Stealth) ? 70 : 0xFFF00); // @@TODO should be configurable } void TMC2130::SetCurrents(const MotorParams ¶ms, const MotorCurrents ¤ts) { @@ -81,7 +81,7 @@ void TMC2130::SetEnabled(const MotorParams ¶ms, bool enabled) { } void TMC2130::ClearStallguard(const MotorParams ¶ms) { - // @todo: maximum resolution right now is x256/4 (uint8_t / 4) + // @@TODO maximum resolution right now is x256/4 (uint8_t / 4) sg_counter = 4 * (1 << (8 - params.mRes)) - 1; /// one electrical full step (4 steps when fullstepping) } @@ -132,6 +132,7 @@ void TMC2130::_spi_tx_rx(const MotorParams ¶ms, uint8_t (&pData)[5]) { } void TMC2130::_handle_spi_status(const MotorParams ¶ms, uint8_t status) { + //@@TODO // errorFlags.reset_flag |= status & (1 << 0); // errorFlags.driver_error |= status & (1 << 1); } diff --git a/src/hal/tmc2130.h b/src/hal/tmc2130.h index 2d86214..f78ede8 100644 --- a/src/hal/tmc2130.h +++ b/src/hal/tmc2130.h @@ -140,7 +140,7 @@ private: ErrorFlags errorFlags; bool enabled = false; - uint8_t sg_counter; + uint8_t sg_counter = 0; }; } // namespace tmc2130 diff --git a/src/logic/command_base.cpp b/src/logic/command_base.cpp index a50e2ea..f0abe5b 100644 --- a/src/logic/command_base.cpp +++ b/src/logic/command_base.cpp @@ -63,7 +63,7 @@ bool CommandBase::Step() { // if (ms::selector.State() == ms::Selector::Failed) { // state = ProgressCode::ERRTMCFailed; // error |= TMC2130ToErrorCode(mm::motion.DriverForAxis(mm::Axis::Selector), mm::Axis::Selector); - // return true; // the HW error prevents us from continuing with the with the state machine - the MMU must be restarted/fixed before continuing + // return true; // the HW error prevents us from continuing with the state machine - the MMU must be restarted/fixed before continuing // } // @@TODO not sure how to prevent losing the previously accumulated error ... or do I really need to do it? diff --git a/src/logic/error_codes.h b/src/logic/error_codes.h index 81406c3..11fea30 100644 --- a/src/logic/error_codes.h +++ b/src/logic/error_codes.h @@ -14,7 +14,7 @@ /// TMC_PULLEY_BIT, TMC_SELECTOR_BIT, TMC_IDLER_BIT, /// The resulting error is a bitwise OR over 3 TMC drivers and their status, which should cover most of the situations correctly. enum class ErrorCode : uint_fast16_t { - RUNNING = 0x0000, ///< the operation is still running + RUNNING = 0x0000, ///< the operation is still running - keep this value as ZERO as it is used for initialization of error codes as well OK = 0x0001, ///< the operation finished OK /// Unload Filament related error codes