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/43/head
Yuri D'Elia 2021-07-04 23:14:09 +02:00
parent 3825309305
commit e13a2d0f51
1 changed files with 6 additions and 6 deletions

View File

@ -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;
}