TMC2130: Reformat
parent
f491072614
commit
e9627ad0d4
|
|
@ -35,7 +35,7 @@ class TMC2130 {
|
||||||
MotorCurrents currents;
|
MotorCurrents currents;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// Constructor
|
||||||
TMC2130(const MotorParams ¶ms,
|
TMC2130(const MotorParams ¶ms,
|
||||||
const MotorCurrents ¤ts,
|
const MotorCurrents ¤ts,
|
||||||
MotorMode mode);
|
MotorMode mode);
|
||||||
|
|
@ -43,38 +43,42 @@ public:
|
||||||
/// (re)initialization of the chip
|
/// (re)initialization of the chip
|
||||||
void Init(const MotorParams ¶ms);
|
void Init(const MotorParams ¶ms);
|
||||||
|
|
||||||
/// Get/Change the current motor mode
|
/// Get the current motor mode
|
||||||
MotorMode Mode() { return mode; } const
|
MotorMode Mode() const {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the current motor mode
|
||||||
void SetMode(MotorMode mode);
|
void SetMode(MotorMode mode);
|
||||||
|
|
||||||
/// Get/Change the current motor currents
|
/// Get the current motor currents
|
||||||
const MotorCurrents& Currents() { return currents; } const
|
const MotorCurrents &Currents() const {
|
||||||
|
return currents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the current motor currents
|
||||||
void SetCurrents(const MotorCurrents ¤ts);
|
void SetCurrents(const MotorCurrents ¤ts);
|
||||||
|
|
||||||
/// Return enabled state (TODO)
|
/// Return enabled state (TODO)
|
||||||
static bool Enabled(const MotorParams ¶ms);
|
static bool Enabled(const MotorParams ¶ms);
|
||||||
|
|
||||||
/// Enable/Disable the motor
|
/// Enable/Disable the motor
|
||||||
static void SetEnabled(const MotorParams& params, bool enabled)
|
static void SetEnabled(const MotorParams ¶ms, bool enabled) {
|
||||||
{
|
|
||||||
hal::shr16::shr16.SetTMCDir(params.idx, enabled);
|
hal::shr16::shr16.SetTMCDir(params.idx, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set direction
|
/// Set direction
|
||||||
static inline void SetDir(const MotorParams& params, bool dir)
|
static inline void SetDir(const MotorParams ¶ms, 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
|
||||||
static inline void Step(const MotorParams& params)
|
static inline void Step(const MotorParams ¶ms) {
|
||||||
{
|
|
||||||
gpio::TogglePin(params.stepPin); // assumes DEDGE
|
gpio::TogglePin(params.stepPin); // assumes DEDGE
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return SG state
|
/// Return SG state
|
||||||
static inline bool Stall(const MotorParams& params)
|
static inline bool Stall(const MotorParams ¶ms) {
|
||||||
{
|
|
||||||
return gpio::ReadPin(params.sgPin) == gpio::Level::high;
|
return gpio::ReadPin(params.sgPin) == gpio::Level::high;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue