Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
|
TMC2130 interface - instances of this class are hidden in modules::motion::Motion::AxisData. More...
#include <tmc2130.h>
Public Types | |
enum class | Registers : uint8_t { GCONF = 0x00 , GSTAT = 0x01 , IOIN = 0x04 , IHOLD_IRUN = 0x10 , TPOWERDOWN = 0x11 , TSTEP = 0x12 , TPWMTHRS = 0x13 , TCOOLTHRS = 0x14 , THIGH = 0x15 , MSCNT = 0x6A , CHOPCONF = 0x6C , COOLCONF = 0x6D , DRV_STATUS = 0x6F , PWMCONF = 0x70 } |
TMC2130 register addresses. More... | |
Public Member Functions | |
TMC2130 ()=default | |
Constructor. | |
bool | Init (const MotorParams ¶ms, const MotorCurrents ¤ts, MotorMode mode) |
void | SetMode (const MotorParams ¶ms, MotorMode mode) |
Set the current motor mode. More... | |
void | SetBridgeOutput (const MotorParams ¶ms, bool on) |
Disables the output by setting or clearing CHOPCONF's TOFF. | |
void | SetCurrents (const MotorParams ¶ms, const MotorCurrents ¤ts) |
Set the current motor currents. | |
void | SetSGTHRS (const MotorParams ¶ms) |
const bool | Enabled () const |
Return enabled state. | |
void | SetEnabled (const MotorParams ¶ms, bool enabled) |
Enable/Disable the motor. | |
bool | Stalled () const |
void | ClearStallguard () |
bool | CheckForErrors (const MotorParams ¶ms) |
Should be called periodically. Maybe not all the time. Once every 10 ms is probably enough. | |
ErrorFlags | GetErrorFlags () const |
uint32_t | ReadRegister (const MotorParams ¶ms, Registers reg) |
Reads a driver register and updates the status flags. | |
void | WriteRegister (const MotorParams ¶ms, Registers reg, uint32_t data) |
Writes a driver register and updates the status flags. | |
void | Isr (const MotorParams ¶ms) |
Used for polling the DIAG pin. Should be called from the stepper isr periodically when moving. | |
Static Public Member Functions | |
static void | SetDir (const MotorParams ¶ms, bool dir) |
Set direction. | |
static void | SetRawDir (const MotorParams ¶ms, bool dir) |
Set direction, raw value (i.e. ignore Params). | |
static void | Step (const MotorParams ¶ms) |
Step the motor. | |
static void | SetStep (const MotorParams ¶ms, bool state) |
Set step to an explicit state. | |
static bool | SampleDiag (const MotorParams ¶ms) |
Return SG state. | |
TMC2130 interface - instances of this class are hidden in modules::motion::Motion::AxisData.
|
strong |
TMC2130 register addresses.
Enumerator | |
---|---|
GCONF | General Configuration Registers. |
IHOLD_IRUN | Velocity Dependent Driver Feature Control Register Set. |
MSCNT | Motor Driver Registers. |
bool hal::tmc2130::TMC2130::Init | ( | const MotorParams & | params, |
const MotorCurrents & | currents, | ||
MotorMode | mode | ||
) |
(re)initialization of the chip - please note this is necessary due to some HW flaws in the original MMU boards. And yes, the TMC may not get correctly initialized.
void hal::tmc2130::TMC2130::SetMode | ( | const MotorParams & | params, |
MotorMode | mode | ||
) |
Set the current motor mode.
0xFFFF0 is used as a "Normal" mode threshold since stealthchop will be used at standstill.
void hal::tmc2130::TMC2130::SetSGTHRS | ( | const MotorParams & | params | ) |
Set StallGuard threshold New SGTHRS must be already set in params
Beware - there are no checks, new value is written into the TMC register immediately. It is advised to prefer setting the SGTHRS via the Init() method.