TMC5160 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
tmc5160_registers.hpp File Reference

TMC5160 register map: addresses, access rules, reserved bits and reset values. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include "tmc5160_detail.hpp"

Go to the source code of this file.

Classes

struct  tmc5160::reg::RegInfo
 What the driver knows about one register. More...
 

Namespaces

namespace  tmc5160
 The TMC5160 driver: everything it declares lives here; internals in detail.
 
namespace  tmc5160::reg
 The TMC5160 register map.
 

Typedefs

Field helpers
using tmc5160::reg::Toff = detail::Field< uint32_t, 0, 4 >
 CHOPCONF TOFF.
 
using tmc5160::reg::Hstrt = detail::Field< uint32_t, 4, 3 >
 CHOPCONF HSTRT / TFD[2:0].
 
using tmc5160::reg::Hend = detail::Field< uint32_t, 7, 4 >
 CHOPCONF HEND / OFFSET.
 
using tmc5160::reg::Fd3 = detail::Field< uint32_t, 11, 1 >
 CHOPCONF fd3.
 
using tmc5160::reg::Disfdcc = detail::Field< uint32_t, 12, 1 >
 CHOPCONF disfdcc.
 
using tmc5160::reg::Chm = detail::Field< uint32_t, 14, 1 >
 CHOPCONF chm.
 
using tmc5160::reg::Tbl = detail::Field< uint32_t, 15, 2 >
 CHOPCONF TBL.
 
using tmc5160::reg::Vhighfs = detail::Field< uint32_t, 18, 1 >
 CHOPCONF vhighfs.
 
using tmc5160::reg::Vhighchm = detail::Field< uint32_t, 19, 1 >
 CHOPCONF vhighchm.
 
using tmc5160::reg::Tpfd = detail::Field< uint32_t, 20, 4 >
 CHOPCONF TPFD.
 
using tmc5160::reg::Mres = detail::Field< uint32_t, 24, 4 >
 CHOPCONF MRES.
 
using tmc5160::reg::Intpol = detail::Field< uint32_t, 28, 1 >
 CHOPCONF intpol.
 
using tmc5160::reg::Dedge = detail::Field< uint32_t, 29, 1 >
 CHOPCONF dedge.
 
using tmc5160::reg::Diss2g = detail::Field< uint32_t, 30, 1 >
 CHOPCONF diss2g.
 
using tmc5160::reg::Diss2vs = detail::Field< uint32_t, 31, 1 >
 CHOPCONF diss2vs.
 
using tmc5160::reg::Ihold = detail::Field< uint32_t, 0, 5 >
 IHOLD_IRUN IHOLD.
 
using tmc5160::reg::Irun = detail::Field< uint32_t, 8, 5 >
 IHOLD_IRUN IRUN.
 
using tmc5160::reg::IholdDelay = detail::Field< uint32_t, 16, 4 >
 IHOLD_IRUN IHOLDDELAY.
 
using tmc5160::reg::PwmOfs = detail::Field< uint32_t, 0, 8 >
 PWMCONF PWM_OFS.
 
using tmc5160::reg::PwmGrad = detail::Field< uint32_t, 8, 8 >
 PWMCONF PWM_GRAD.
 
using tmc5160::reg::PwmFreq = detail::Field< uint32_t, 16, 2 >
 PWMCONF pwm_freq.
 
using tmc5160::reg::Freewheel = detail::Field< uint32_t, 20, 2 >
 PWMCONF freewheel.
 
using tmc5160::reg::PwmReg = detail::Field< uint32_t, 24, 4 >
 PWMCONF PWM_REG.
 
using tmc5160::reg::PwmLim = detail::Field< uint32_t, 28, 4 >
 PWMCONF PWM_LIM.
 
using tmc5160::reg::Semin = detail::Field< uint32_t, 0, 4 >
 COOLCONF SEMIN.
 
using tmc5160::reg::Seup = detail::Field< uint32_t, 5, 2 >
 COOLCONF SEUP.
 
using tmc5160::reg::Semax = detail::Field< uint32_t, 8, 4 >
 COOLCONF SEMAX.
 
using tmc5160::reg::Sedn = detail::Field< uint32_t, 13, 2 >
 COOLCONF SEDN.
 
using tmc5160::reg::Seimin = detail::Field< uint32_t, 15, 1 >
 COOLCONF SEIMIN.
 
using tmc5160::reg::Sgt = detail::Field< uint32_t, 16, 7 >
 COOLCONF SGT.
 
using tmc5160::reg::Sfilt = detail::Field< uint32_t, 24, 1 >
 COOLCONF SFILT.
 
using tmc5160::reg::S2vsLevel = detail::Field< uint32_t, 0, 4 >
 SHORT_CONF S2VS_LEVEL.
 
using tmc5160::reg::S2gLevel = detail::Field< uint32_t, 8, 4 >
 SHORT_CONF S2G_LEVEL.
 
using tmc5160::reg::ShortFilter = detail::Field< uint32_t, 16, 2 >
 SHORT_CONF SHORTFILTER.
 
using tmc5160::reg::ShortDelay = detail::Field< uint32_t, 18, 1 >
 SHORT_CONF shortdelay.
 
using tmc5160::reg::Bbmtime = detail::Field< uint32_t, 0, 5 >
 DRV_CONF BBMTIME.
 
using tmc5160::reg::Bbmclks = detail::Field< uint32_t, 8, 4 >
 DRV_CONF BBMCLKS.
 
using tmc5160::reg::Otselect = detail::Field< uint32_t, 16, 2 >
 DRV_CONF OTSELECT.
 
using tmc5160::reg::Drvstrength = detail::Field< uint32_t, 18, 2 >
 DRV_CONF DRVSTRENGTH.
 
using tmc5160::reg::FiltIsense = detail::Field< uint32_t, 20, 2 >
 DRV_CONF FILT_ISENSE.
 
using tmc5160::reg::NodeAddr = detail::Field< uint32_t, 0, 8 >
 NODECONF NODEADDR.
 
using tmc5160::reg::SendDelay = detail::Field< uint32_t, 8, 4 >
 NODECONF SENDDELAY.
 
using tmc5160::reg::DcTime = detail::Field< uint32_t, 0, 10 >
 DCCTRL DC_TIME.
 
using tmc5160::reg::DcSg = detail::Field< uint32_t, 16, 8 >
 DCCTRL DC_SG.
 
using tmc5160::reg::StartSin = detail::Field< uint32_t, 0, 8 >
 MSLUTSTART START_SIN.
 
using tmc5160::reg::StartSin90 = detail::Field< uint32_t, 16, 8 >
 MSLUTSTART START_SIN90.
 

Enumerations

enum class  tmc5160::reg::Access : uint8_t {
  tmc5160::reg::Access::ReadOnly = 0 , tmc5160::reg::Access::WriteOnly = 1 , tmc5160::reg::Access::ReadWrite = 2 , tmc5160::reg::Access::Clear = 3 ,
  tmc5160::reg::Access::Forbidden = 4
}
 How the driver may touch an address. More...
 

Functions

constexpr const RegInfo * tmc5160::reg::FindReadable (uint8_t address) noexcept
 The row that lets the driver read address.
 
constexpr const RegInfo * tmc5160::reg::FindWritable (uint8_t address) noexcept
 The row that lets the driver write address.
 
constexpr uint32_t tmc5160::reg::ResetValue (uint8_t address) noexcept
 The reset value of a register.
 

Variables

constexpr uint8_t tmc5160::reg::kGconf = 0x00
 GCONF (RW, 18 bits), page 32.
 
constexpr uint8_t tmc5160::reg::kGstat = 0x01
 GSTAT (R, write 1 to clear, 3 bits), page 33.
 
constexpr uint8_t tmc5160::reg::kIfcnt = 0x02
 IFCNT (R, 8 bits): UART write counter, page 33.
 
constexpr uint8_t tmc5160::reg::kNodeconf = 0x03
 NODECONF (W, 12 bits): UART node, page 34.
 
constexpr uint8_t tmc5160::reg::kIoin = 0x04
 IOIN (R): input pins and VERSION, page 34.
 
constexpr uint8_t tmc5160::reg::kOutput = 0x04
 OUTPUT (W, 1 bit): NAO level in UART mode, page 34.
 
constexpr uint8_t tmc5160::reg::kXCompare = 0x05
 X_COMPARE (W, 32 bits), page 34.
 
constexpr uint8_t tmc5160::reg::kOtpProg = 0x06
 OTP_PROG (W): never written by the driver.
 
constexpr uint8_t tmc5160::reg::kOtpRead = 0x07
 OTP_READ (R, 8 bits), page 35.
 
constexpr uint8_t tmc5160::reg::kFactoryConf = 0x08
 FACTORY_CONF (RW): never written by the driver.
 
constexpr uint8_t tmc5160::reg::kShortConf = 0x09
 SHORT_CONF (W, 19 bits), page 35.
 
constexpr uint8_t tmc5160::reg::kDrvConf = 0x0A
 DRV_CONF (W, 22 bits), page 35.
 
constexpr uint8_t tmc5160::reg::kGlobalScaler = 0x0B
 GLOBALSCALER (W, 8 bits), page 36.
 
constexpr uint8_t tmc5160::reg::kOffsetRead = 0x0C
 OFFSET_READ (R, 16 bits), page 36.
 
constexpr uint8_t tmc5160::reg::kIholdIrun = 0x10
 IHOLD_IRUN (W, 20 bits), page 38.
 
constexpr uint8_t tmc5160::reg::kTpowerdown = 0x11
 TPOWERDOWN (W, 8 bits), page 38.
 
constexpr uint8_t tmc5160::reg::kTstep = 0x12
 TSTEP (R, 20 bits), page 38.
 
constexpr uint8_t tmc5160::reg::kTpwmthrs = 0x13
 TPWMTHRS (W, 20 bits), page 39.
 
constexpr uint8_t tmc5160::reg::kTcoolthrs = 0x14
 TCOOLTHRS (W, 20 bits), page 39.
 
constexpr uint8_t tmc5160::reg::kThigh = 0x15
 THIGH (W, 20 bits), page 39.
 
constexpr uint8_t tmc5160::reg::kRampmode = 0x20
 RAMPMODE (RW, 2 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kXactual = 0x21
 XACTUAL (RW, 32 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kVactual = 0x22
 VACTUAL (R, 24 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kVstart = 0x23
 VSTART (W, 18 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kA1 = 0x24
 A1 (W, 16 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kV1 = 0x25
 V1 (W, 20 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kAmax = 0x26
 AMAX (W, 16 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kVmax = 0x27
 VMAX (W, 23 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kDmax = 0x28
 DMAX (W, 16 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kD1 = 0x2A
 D1 (W, 16 bits), page 40.
 
constexpr uint8_t tmc5160::reg::kVstop = 0x2B
 VSTOP (W, 18 bits), page 41.
 
constexpr uint8_t tmc5160::reg::kTzerowait = 0x2C
 TZEROWAIT (W, 16 bits), page 41.
 
constexpr uint8_t tmc5160::reg::kXtarget = 0x2D
 XTARGET (RW, 32 bits), page 41.
 
constexpr uint8_t tmc5160::reg::kVdcmin = 0x33
 VDCMIN (W, 23 bits), page 42.
 
constexpr uint8_t tmc5160::reg::kSwMode = 0x34
 SW_MODE (RW, 12 bits), page 42.
 
constexpr uint8_t tmc5160::reg::kRampStat = 0x35
 RAMP_STAT (R, write 1 to clear some, 14 bits).
 
constexpr uint8_t tmc5160::reg::kXlatch = 0x36
 XLATCH (R, 32 bits), page 42.
 
constexpr uint8_t tmc5160::reg::kEncmode = 0x38
 ENCMODE (RW, 11 bits), page 45.
 
constexpr uint8_t tmc5160::reg::kXEnc = 0x39
 X_ENC (RW, 32 bits), page 45.
 
constexpr uint8_t tmc5160::reg::kEncConst = 0x3A
 ENC_CONST (W, 32 bits), page 45.
 
constexpr uint8_t tmc5160::reg::kEncStatus = 0x3B
 ENC_STATUS (R, write 1 to clear, 2 bits).
 
constexpr uint8_t tmc5160::reg::kEncLatch = 0x3C
 ENC_LATCH (R, 32 bits), page 45.
 
constexpr uint8_t tmc5160::reg::kEncDeviation = 0x3D
 ENC_DEVIATION (W, 20 bits), page 45.
 
constexpr uint8_t tmc5160::reg::kMslut0 = 0x60
 MSLUT[0] (W); MSLUT[n] is at kMslut0 + n, n < 8.
 
constexpr uint8_t tmc5160::reg::kMslutsel = 0x68
 MSLUTSEL (W, 32 bits), page 47.
 
constexpr uint8_t tmc5160::reg::kMslutstart = 0x69
 MSLUTSTART (W, 24 bits), page 47.
 
constexpr uint8_t tmc5160::reg::kMscnt = 0x6A
 MSCNT (R, 10 bits), page 47.
 
constexpr uint8_t tmc5160::reg::kMscuract = 0x6B
 MSCURACT (R, 25 bits), page 47.
 
constexpr uint8_t tmc5160::reg::kChopconf = 0x6C
 CHOPCONF (RW, 32 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kCoolconf = 0x6D
 COOLCONF (W, 25 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kDcctrl = 0x6E
 DCCTRL (W, 24 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kDrvStatus = 0x6F
 DRV_STATUS (R, 32 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kPwmconf = 0x70
 PWMCONF (W, 32 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kPwmScale = 0x71
 PWM_SCALE (R, 17 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kPwmAuto = 0x72
 PWM_AUTO (R, 16 bits), page 48.
 
constexpr uint8_t tmc5160::reg::kLostSteps = 0x73
 LOST_STEPS (R, 20 bits), page 49.
 
constexpr uint8_t tmc5160::reg::kLastRegister = 0x73
 Highest implemented address.
 
constexpr uint8_t tmc5160::reg::kWriteFlag = 0x80
 Write flag of the first byte of an SPI datagram (section 4.1, page 23).
 
constexpr std::array< uint32_t, 8 > tmc5160::reg::kDefaultMslut
 Default sine table words, MSLUT[0] to MSLUT[7] (page 106).
 
constexpr uint32_t tmc5160::reg::kDefaultMslutsel = 0xFFFF8056U
 Reset value of MSLUTSEL (page 47).
 
constexpr uint32_t tmc5160::reg::kDefaultMslutstart = 0x00F70000U
 Reset value of MSLUTSTART: START_SIN 0, START_SIN90 247 (page 47).
 
constexpr uint32_t tmc5160::reg::kChopconfReset = 0x10410150U
 Reset value of CHOPCONF (page 48).
 
constexpr uint32_t tmc5160::reg::kPwmconfReset = 0xC40C001EU
 Reset value of PWMCONF (page 48).
 
constexpr uint32_t tmc5160::reg::kEncConstReset = 0x00010000U
 Reset value of ENC_CONST, 1.0 in 16.16 (page 45).
 
constexpr uint32_t tmc5160::reg::kVersion = 0x30U
 The chip version IOIN reports in bits 31 to 24 (page 34).
 
constexpr std::array< RegInfo, 63 > tmc5160::reg::kTable
 The table: one row per address and direction, in address order.
 
GCONF bits (page 32)
constexpr uint32_t tmc5160::reg::kGconfRecalibrate = 1U << 0
 Recalibrate zero crossing.
 
constexpr uint32_t tmc5160::reg::kGconfFastStandstill = 1U << 1
 Standstill after 2^18 clocks.
 
constexpr uint32_t tmc5160::reg::kGconfEnPwmMode = 1U << 2
 StealthChop enable.
 
constexpr uint32_t tmc5160::reg::kGconfMultistepFilt = 1U << 3
 Step pulse filtering.
 
constexpr uint32_t tmc5160::reg::kGconfShaft = 1U << 4
 Invert direction.
 
constexpr uint32_t tmc5160::reg::kGconfDiag0Error = 1U << 5
 DIAG0 on driver error.
 
constexpr uint32_t tmc5160::reg::kGconfDiag0Otpw = 1U << 6
 DIAG0 on pre-warning.
 
constexpr uint32_t tmc5160::reg::kGconfDiag0Stall = 1U << 7
 DIAG0 on stall (or STEP output).
 
constexpr uint32_t tmc5160::reg::kGconfDiag1Stall = 1U << 8
 DIAG1 on stall (or DIR output).
 
constexpr uint32_t tmc5160::reg::kGconfDiag1Index = 1U << 9
 DIAG1 on microstep index 0.
 
constexpr uint32_t tmc5160::reg::kGconfDiag1OnState = 1U << 10
 DIAG1 on chopper on-state.
 
constexpr uint32_t tmc5160::reg::kGconfDiag1StepsSkipped = 1U << 11
 DIAG1 toggles on skipped steps.
 
constexpr uint32_t tmc5160::reg::kGconfDiag0PushPull = 1U << 12
 DIAG0 push-pull.
 
constexpr uint32_t tmc5160::reg::kGconfDiag1PushPull = 1U << 13
 DIAG1 push-pull.
 
constexpr uint32_t tmc5160::reg::kGconfSmallHysteresis = 1U << 14
 1/32 hysteresis.
 
constexpr uint32_t tmc5160::reg::kGconfStopEnable = 1U << 15
 ENCA_DCIN stops the sequencer.
 
constexpr uint32_t tmc5160::reg::kGconfDirectMode = 1U << 16
 Coil currents from XTARGET.
 
constexpr uint32_t tmc5160::reg::kGconfTestMode = 1U << 17
 Test mode: never set.
 
GSTAT bits (page 33)
constexpr uint32_t tmc5160::reg::kGstatReset = 1U << 0
 The chip was reset.
 
constexpr uint32_t tmc5160::reg::kGstatDrvErr = 1U << 1
 The driver shut down.
 
constexpr uint32_t tmc5160::reg::kGstatUvCp = 1U << 2
 Charge pump undervoltage.
 
IOIN bits (page 34)
constexpr uint32_t tmc5160::reg::kIoinSdMode = 1U << 6
 Level of the SD_MODE strap.
 
SW_MODE bits (page 43)
constexpr uint32_t tmc5160::reg::kSwStopLeft = 1U << 0
 Stop at the left switch.
 
constexpr uint32_t tmc5160::reg::kSwStopRight = 1U << 1
 Stop at the right switch.
 
constexpr uint32_t tmc5160::reg::kSwPolLeft = 1U << 2
 Left switch active low.
 
constexpr uint32_t tmc5160::reg::kSwPolRight = 1U << 3
 Right switch active low.
 
constexpr uint32_t tmc5160::reg::kSwSwap = 1U << 4
 Swap left and right.
 
constexpr uint32_t tmc5160::reg::kSwLatchLeftActive = 1U << 5
 Latch on active left edge.
 
constexpr uint32_t tmc5160::reg::kSwLatchLeftInactive = 1U << 6
 Latch on inactive left edge.
 
constexpr uint32_t tmc5160::reg::kSwLatchRightActive = 1U << 7
 Latch on active right edge.
 
constexpr uint32_t tmc5160::reg::kSwLatchRightInactive = 1U << 8
 Latch on inactive right edge.
 
constexpr uint32_t tmc5160::reg::kSwLatchEncoder = 1U << 9
 Latch X_ENC too.
 
constexpr uint32_t tmc5160::reg::kSwStopStall = 1U << 10
 Stop on stall (sg_stop).
 
constexpr uint32_t tmc5160::reg::kSwSoftStop = 1U << 11
 Soft stop (en_softstop).
 
RAMP_STAT bits (page 44)
constexpr uint32_t tmc5160::reg::kRampStopLeftActive = 1U << 0
 Left switch active.
 
constexpr uint32_t tmc5160::reg::kRampStopRightActive = 1U << 1
 Right switch active.
 
constexpr uint32_t tmc5160::reg::kRampLatchLeft = 1U << 2
 Left latch ready (write 1 clears).
 
constexpr uint32_t tmc5160::reg::kRampLatchRight = 1U << 3
 Right latch ready (write 1 clears).
 
constexpr uint32_t tmc5160::reg::kRampEventStopLeft = 1U << 4
 Left stop event.
 
constexpr uint32_t tmc5160::reg::kRampEventStopRight = 1U << 5
 Right stop event.
 
constexpr uint32_t tmc5160::reg::kRampEventStopStall = 1U << 6
 Stall stop event (write 1 clears).
 
constexpr uint32_t tmc5160::reg::kRampEventPosReached
 Target reached event (write 1 clears).
 
constexpr uint32_t tmc5160::reg::kRampVelocityReached = 1U << 8
 VACTUAL equals VMAX.
 
constexpr uint32_t tmc5160::reg::kRampPositionReached = 1U << 9
 XACTUAL equals XTARGET.
 
constexpr uint32_t tmc5160::reg::kRampVzero = 1U << 10
 VACTUAL is 0.
 
constexpr uint32_t tmc5160::reg::kRampZeroWaitActive = 1U << 11
 TZEROWAIT is running.
 
constexpr uint32_t tmc5160::reg::kRampSecondMove = 1U << 12
 Ramp reversed (write 1 clears).
 
constexpr uint32_t tmc5160::reg::kRampStatusSg = 1U << 13
 Stall input active.
 
DRV_STATUS bits (page 56)
constexpr uint32_t tmc5160::reg::kDrvS2vsA = 1U << 12
 Short to supply, phase A.
 
constexpr uint32_t tmc5160::reg::kDrvS2vsB = 1U << 13
 Short to supply, phase B.
 
constexpr uint32_t tmc5160::reg::kDrvStealth = 1U << 14
 StealthChop active.
 
constexpr uint32_t tmc5160::reg::kDrvFsActive = 1U << 15
 Full-step active.
 
constexpr uint32_t tmc5160::reg::kDrvStallGuard = 1U << 24
 Stall detected.
 
constexpr uint32_t tmc5160::reg::kDrvOt = 1U << 25
 Overtemperature shutdown.
 
constexpr uint32_t tmc5160::reg::kDrvOtpw = 1U << 26
 Overtemperature pre-warning.
 
constexpr uint32_t tmc5160::reg::kDrvS2gA = 1U << 27
 Short to ground, phase A.
 
constexpr uint32_t tmc5160::reg::kDrvS2gB = 1U << 28
 Short to ground, phase B.
 
constexpr uint32_t tmc5160::reg::kDrvOlA = 1U << 29
 Open load, phase A.
 
constexpr uint32_t tmc5160::reg::kDrvOlB = 1U << 30
 Open load, phase B.
 
constexpr uint32_t tmc5160::reg::kDrvStst = 1U << 31
 Standstill.
 

Detailed Description

TMC5160 register map: addresses, access rules, reserved bits and reset values.

Datasheet chapter 6 (Rev. 1.18), pages 31 to 56. Addresses are seven bits. Most registers are write-only (the datasheet marks them W, section 1.3 page 7 asks the master to keep a shadow), so the table below records, for every address, whether the chip lets the driver read it, whether the driver may write it, the bits that exist (every other bit is written as 0) and the bits that clear on a write of 1. The driver refuses a read of a write-only address and a write of a read-only one.