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.
pull/41/head
Yuri D'Elia 2021-07-04 23:14:09 +02:00 committed by DRracer
parent 28c9e55a79
commit f491072614
1 changed files with 6 additions and 6 deletions

View File

@ -51,29 +51,29 @@ public:
const MotorCurrents& Currents() { return currents; } const const MotorCurrents& Currents() { return currents; } const
void SetCurrents(const MotorCurrents& currents); void SetCurrents(const MotorCurrents& currents);
/// Return enabled state /// Return enabled state (TODO)
bool Enabled() const; static bool Enabled(const MotorParams& params);
/// Enable/Disable the motor /// 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); hal::shr16::shr16.SetTMCDir(params.idx, enabled);
} }
/// Set direction /// 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); hal::shr16::shr16.SetTMCDir(params.idx, dir ^ params.dirOn);
} }
/// Step the motor /// Step the motor
inline void Step(const MotorParams& params) static inline void Step(const MotorParams& params)
{ {
gpio::TogglePin(params.stepPin); // assumes DEDGE gpio::TogglePin(params.stepPin); // assumes DEDGE
} }
/// Return SG state /// Return SG state
inline bool Stall(const MotorParams& params) static inline bool Stall(const MotorParams& params)
{ {
return gpio::ReadPin(params.sgPin) == gpio::Level::high; return gpio::ReadPin(params.sgPin) == gpio::Level::high;
} }