|
TMC5160 Driver 0.1.0
API reference
|
Public types of the TMC5160 driver: errors, Result<T>, configuration, validation and advice.
More...
#include <array>#include <cstdint>#include "tmc5160_detail.hpp"#include "tmc5160_registers.hpp"#include "tmc5160_version.h"Go to the source code of this file.
Classes | |
| struct | tmc5160::Result< T > |
| The value of a call, or why there is none. More... | |
| struct | tmc5160::Result< void > |
| The result of a call that returns no value. More... | |
| struct | tmc5160::AckSet |
| A set of acknowledgements. More... | |
| struct | tmc5160::Motor |
| The motor as its data sheet declares it; the current ceiling comes from here. More... | |
| struct | tmc5160::Board |
| The power stage as built: the sense resistor and the supply. More... | |
| struct | tmc5160::Clock |
| The clock: internal 12 MHz or an external clock on CLK (page 119). More... | |
| struct | tmc5160::Current |
Run and hold current requests, RMS in mA; PlanCurrent() turns them into registers. More... | |
| struct | tmc5160::Standstill |
| Standstill behaviour (IHOLD_IRUN.IHOLDDELAY, TPOWERDOWN, GCONF.faststandstill). More... | |
| struct | tmc5160::Chopper |
| Chopper configuration (CHOPCONF, section 6.5.2 page 51). More... | |
| struct | tmc5160::StealthChop |
| StealthChop settings (PWMCONF, GCONF.en_pwm_mode, section 6.5.2 page 54). More... | |
| struct | tmc5160::Thresholds |
| Velocity thresholds as TSTEP values (page 39); 0 disables. More... | |
| struct | tmc5160::CoolStep |
| CoolStep (COOLCONF, section 13, page 87). More... | |
| struct | tmc5160::StallGuard |
| StallGuard2 (COOLCONF, section 13, page 87). More... | |
| struct | tmc5160::DcStep |
| DcStep (VDCMIN, DCCTRL, section 17, page 100). More... | |
| struct | tmc5160::Bridge |
Gate driver settings (DRV_CONF, section 6.1 page 35); written only when declared. More... | |
| struct | tmc5160::Protection |
Short protection (SHORT_CONF, section 11.2 page 78); written only when declared. More... | |
| struct | tmc5160::Flags |
| General flags (GCONF). More... | |
| struct | tmc5160::Diag |
| DIAG0 and DIAG1 outputs (GCONF bits 5 to 13, section 6.1 page 32). More... | |
| struct | tmc5160::RampProfile |
| The six-point ramp (page 40). Defaults are the datasheet's quick-start values (page 116). More... | |
| struct | tmc5160::Switches |
| Reference switches and stop behaviour (SW_MODE, page 43). More... | |
| struct | tmc5160::NEvent |
| Encoder N-channel event conditions (ENCMODE, page 46). More... | |
| struct | tmc5160::EncoderScale |
| The ENC_CONST accumulation factor (page 45, 107). More... | |
| struct | tmc5160::Encoder |
Incremental encoder (ABN), written only when declared. More... | |
| struct | tmc5160::MicrostepTable |
| A microstep table (MSLUT, MSLUTSEL, MSLUTSTART, section 6.5 page 47). More... | |
| struct | tmc5160::UartOptions |
| The UART options (used by a UART port only). More... | |
| struct | tmc5160::SpiOptions |
| The SPI options (used by an SPI port only). More... | |
| struct | tmc5160::Config |
Everything EnsureInitialized() writes to the chip. See docs/configuration.md. More... | |
| class | tmc5160::CheckedConfig |
| A configuration proven valid at build time. More... | |
Namespaces | |
| namespace | tmc5160 |
The TMC5160 driver: everything it declares lives here; internals in detail. | |
Functions | |
| constexpr const char * | tmc5160::ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr Error | tmc5160::CheckTable (const MicrostepTable &table) noexcept |
| Whether a table is acceptable: segment starts ordered, every entry within -248 to 247 (the peak may reach 248), and START_SIN90 equal to the last decoded entry (page 47, 105, A6). | |
| constexpr Error | tmc5160::CheckAcks (const Config &c) noexcept |
The guards that an acknowledgement can lift (section 2.5 of the design): each returns Refused when the configuration needs an Ack it does not carry. | |
| constexpr Error | tmc5160::Validate (const Config &config) noexcept |
| Check a configuration without touching the chip. | |
| constexpr uint32_t | tmc5160::Advise (const Config &config) noexcept |
Soft guidance for a configuration: bits of Advice, never an error. | |
| void | tmc5160::ConfigIsInvalid () noexcept |
Reached only when a CheckedConfig is built from an invalid configuration: it is never defined, so the build fails and names it (KB-CPP20-013). | |
| constexpr Config | tmc5160::MakeConfig (const Motor &motor, const Board &board) noexcept |
| A valid configuration for a declared motor and power stage: run current 90 percent of the rated current less the tolerance reserve, hold current 30 percent of run (page 38), the datasheet's quick-start ramp, SpreadCycle with TOFF 3. | |
| constexpr const char * | tmc5160::GetDriverVersion () noexcept |
| constexpr uint32_t | tmc5160::GetDriverVersionMajor () noexcept |
| constexpr uint32_t | tmc5160::GetDriverVersionMinor () noexcept |
| constexpr uint32_t | tmc5160::GetDriverVersionPatch () noexcept |
Variables | |
Constants | |
| constexpr uint32_t | tmc5160::kInternalClockHz = 12'000'000 |
| Internal oscillator (page 119). | |
| constexpr uint32_t | tmc5160::kExternalClockMinHz = 4'000'000 |
| Lowest external clock (page 122). | |
| constexpr uint32_t | tmc5160::kExternalClockMaxHz = 18'000'000 |
| Highest external clock (page 122). | |
| constexpr uint32_t | tmc5160::kVfsMv = 325 |
| Sense threshold, typical (page 123). | |
| constexpr uint32_t | tmc5160::kCurrentTolerancePercent = 5 |
| Full-scale current tolerance. | |
| constexpr uint32_t | tmc5160::kVsMinMv = 10'000 |
| Lowest VS (page 120). | |
| constexpr uint32_t | tmc5160::kVsMaxMv = 55'000 |
| Highest VS (page 120). | |
| constexpr uint32_t | tmc5160::kUartMinBaud = 9000 |
| Lowest UART baud rate (page 26). | |
| constexpr uint32_t | tmc5160::kUartRecoveryBits = 12 |
| Idle bit times after a UART error. | |
| constexpr uint32_t | tmc5160::kUartReadRetries = 2 |
| Extra attempts of a failed UART read. | |
| constexpr uint32_t | tmc5160::kMaxChain = 8 |
| Longest SPI daisy chain the driver frames. | |
| constexpr uint32_t | tmc5160::kVmaxLimit = (1U << 23) - 512U |
| Highest VMAX (page 41). | |
| constexpr uint32_t | tmc5160::kMaxSckInternalHz |
| SPI clock with the internal clock (page 25). | |
Public types of the TMC5160 driver: errors, Result<T>, configuration, validation and advice.
Everything here is plain data with no platform dependency, so handlers, tests and tools can include it without the driver template. The configuration defaults are the chip's reset values (TMC5160 datasheet, chapter 6). Config{} is deliberately not valid: the motor and the power stage must be declared, because the coil current follows from the sense resistor and the declared motor limits.