Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
Public Types | Public Member Functions | Static Public Member Functions | List of all members
hal::tmc2130::TMC2130 Class Reference

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 &params, const MotorCurrents &currents, MotorMode mode)
 
void SetMode (const MotorParams &params, MotorMode mode)
 Set the current motor mode. More...
 
void SetBridgeOutput (const MotorParams &params, bool on)
 Disables the output by setting or clearing CHOPCONF's TOFF.
 
void SetCurrents (const MotorParams &params, const MotorCurrents &currents)
 Set the current motor currents.
 
void SetSGTHRS (const MotorParams &params)
 
const bool Enabled () const
 Return enabled state.
 
void SetEnabled (const MotorParams &params, bool enabled)
 Enable/Disable the motor.
 
bool Stalled () const
 
void ClearStallguard ()
 
bool CheckForErrors (const MotorParams &params)
 Should be called periodically. Maybe not all the time. Once every 10 ms is probably enough.
 
ErrorFlags GetErrorFlags () const
 
uint32_t ReadRegister (const MotorParams &params, Registers reg)
 Reads a driver register and updates the status flags.
 
void WriteRegister (const MotorParams &params, Registers reg, uint32_t data)
 Writes a driver register and updates the status flags.
 
void Isr (const MotorParams &params)
 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 &params, bool dir)
 Set direction.
 
static void SetRawDir (const MotorParams &params, bool dir)
 Set direction, raw value (i.e. ignore Params).
 
static void Step (const MotorParams &params)
 Step the motor.
 
static void SetStep (const MotorParams &params, bool state)
 Set step to an explicit state.
 
static bool SampleDiag (const MotorParams &params)
 Return SG state.
 

Detailed Description

TMC2130 interface - instances of this class are hidden in modules::motion::Motion::AxisData.

Member Enumeration Documentation

◆ Registers

enum hal::tmc2130::TMC2130::Registers : uint8_t
strong

TMC2130 register addresses.

Enumerator
GCONF 

General Configuration Registers.

IHOLD_IRUN 

Velocity Dependent Driver Feature Control Register Set.

MSCNT 

Motor Driver Registers.

Member Function Documentation

◆ Init()

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.

Returns
true if the TMC2130 was inited correctly

◆ SetMode()

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.

◆ SetSGTHRS()

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.


The documentation for this class was generated from the following files: