From f491072614a3cd0a6c2d3dcb527f9a62986c02bd Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 4 Jul 2021 23:14:09 +0200 Subject: [PATCH] TMC2130: Make stepping methods static To keep these methods efficient no member should be accessed away. That's the reason MotorParams is passed explicitly for each. Mark all stepping methods as static. --- src/hal/tmc2130.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hal/tmc2130.h b/src/hal/tmc2130.h index 1763a2d..1ebd344 100644 --- a/src/hal/tmc2130.h +++ b/src/hal/tmc2130.h @@ -51,29 +51,29 @@ public: const MotorCurrents& Currents() { return currents; } const void SetCurrents(const MotorCurrents& currents); - /// Return enabled state - bool Enabled() const; + /// Return enabled state (TODO) + static bool Enabled(const MotorParams& params); /// Enable/Disable the motor - void SetEnabled(const MotorParams& params, bool enabled) + static void SetEnabled(const MotorParams& params, bool enabled) { hal::shr16::shr16.SetTMCDir(params.idx, enabled); } /// Set direction - void SetDir(const MotorParams& params, bool dir) + static inline void SetDir(const MotorParams& params, bool dir) { hal::shr16::shr16.SetTMCDir(params.idx, dir ^ params.dirOn); } /// Step the motor - inline void Step(const MotorParams& params) + static inline void Step(const MotorParams& params) { gpio::TogglePin(params.stepPin); // assumes DEDGE } /// Return SG state - inline bool Stall(const MotorParams& params) + static inline bool Stall(const MotorParams& params) { return gpio::ReadPin(params.sgPin) == gpio::Level::high; }