HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
Loading...
Searching...
No Matches
tmc51x0::TMC51x0< CommType >::Communication Struct Reference

Communication subsystem. More...

#include <tmc51x0.hpp>

Collaboration diagram for tmc51x0::TMC51x0< CommType >::Communication:
[legend]

Public Member Functions

 Communication (TMC51x0 &driver) noexcept
 Construct communication subsystem.
 
Result< void > SetClkFreq (uint32_t frequency_hz) noexcept
 Set clock frequency on CLK pin.
 
Result< void > SetClkFreq (const ExternalClockConfig &config) noexcept
 Set clock frequency from ExternalClockConfig (high-level method)
 
Result< void > ConfigureUartNodeAddress (uint8_t node_address, uint8_t send_delay=0) noexcept
 Configure UART node address and send delay (writes NODECONF register)
 
void SetDaisyChainPosition (uint8_t position) noexcept
 Set the daisy-chain position for this TMC51x0 instance.
 
uint8_t GetDaisyChainPosition () const noexcept
 Get the current daisy-chain position for this TMC51x0 instance.
 
void SetUartNodeAddress (uint8_t address) noexcept
 Set the UART node address for this TMC51x0 instance.
 
uint8_t GetUartNodeAddress () const noexcept
 Get the current UART node address for this TMC51x0 instance.
 

Private Attributes

TMC51x0driver_
 Reference to parent driver instance.
 

Detailed Description

template<typename CommType>
struct tmc51x0::TMC51x0< CommType >::Communication

Communication subsystem.

Provides methods for configuring UART node addressing and multi-chip setups.

Constructor & Destructor Documentation

◆ Communication()

template<typename CommType >
tmc51x0::TMC51x0< CommType >::Communication::Communication ( TMC51x0 & driver)
inlineexplicitnoexcept

Construct communication subsystem.

Parameters
driverReference to parent TMC51x0 driver instance

Member Function Documentation

◆ ConfigureUartNodeAddress()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Communication::ConfigureUartNodeAddress ( uint8_t node_address,
uint8_t send_delay = 0 )
noexcept

Configure UART node address and send delay (writes NODECONF register)

Parameters
node_addressUART node address (0-254), same as NODECONF.NODEADDR NODECONF
send_delayNumber of bit times before replying to register read (0-15), stored locally
Returns
Result<void> indicating success or error

Writes the NODECONF register to configure the chip's UART node address and send delay. Also updates the local software representation (uart_node_address_ and send_delay_).

Note
This writes to hardware. For sequential programming, use uartConfig.ConfigureUartNodeAddress() instead.
Send delay is stored locally since NODECONF register is write-only.

◆ GetDaisyChainPosition()

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::Communication::GetDaisyChainPosition ( ) const
inlinenoexcept

Get the current daisy-chain position for this TMC51x0 instance.

Returns
Daisy-chain position (0 = first chip/single chip, 1 = second, etc.)

◆ GetUartNodeAddress()

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::Communication::GetUartNodeAddress ( ) const
inlinenoexcept

Get the current UART node address for this TMC51x0 instance.

Returns
UART node address (0-254)

◆ SetClkFreq() [1/2]

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Communication::SetClkFreq ( const ExternalClockConfig & config)
noexcept

Set clock frequency from ExternalClockConfig (high-level method)

Parameters
configExternal clock configuration structure
Returns
Result<void> indicating success or error

Configures the clock source (internal or external) and sets f_clk_ for timing calculations. If config.frequency_hz = 0, uses internal 12 MHz clock. If config.frequency_hz > 0, uses external clock at specified frequency.

This method:

  • Updates the driver's internal clock frequency (f_clk_) for timing calculations
  • Optionally calls the communication interface's SetClkFreq() if supported
  • Updates the driver configuration

Clock Mode:

  • Internal Clock: Set frequency_hz = 0 to use internal oscillator (CLK pin tied to GND).
  • External Clock: Set frequency_hz > 0 to provide external clock signal (e.g., 12000000 for 12MHz).
Note
This is automatically called during Initialize() with the value from DriverConfig.
If SetClkFreq() is not supported (returns false), CLK pin should be tied to GND for internal oscillator.
f_clk is used for all timing calculations regardless of clock source.
Typical frequencies: 12MHz (default internal) or 24MHz (for higher performance external).

◆ SetClkFreq() [2/2]

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Communication::SetClkFreq ( uint32_t frequency_hz)
inlinenoexcept

Set clock frequency on CLK pin.

Parameters
frequency_hzClock frequency in Hz (0 = use internal clock, >0 = external clock frequency)
Returns
Result<void> indicating success or error

This method calls the communication interface's SetClkFreq() method to configure the hardware clock pin. It does NOT update the driver's internal f_clk_ value.

Clock Mode:

  • Internal Clock: Pass frequency_hz = 0 to use internal oscillator (CLK pin set to GND).
  • External Clock: Pass frequency_hz > 0 to provide external clock signal (e.g., 12000000 for 12MHz).
Note
This is a low-level method that only configures the hardware pin. Use the overloaded version with ExternalClockConfig to also update driver configuration.
If not supported (returns false), CLK pin should be tied to GND for internal oscillator.

◆ SetDaisyChainPosition()

template<typename CommType >
void tmc51x0::TMC51x0< CommType >::Communication::SetDaisyChainPosition ( uint8_t position)
inlinenoexcept

Set the daisy-chain position for this TMC51x0 instance.

Parameters
positionPosition in daisy chain (0 = first chip/single chip, 1 = second, etc.)

This method configures the position of this driver in a daisy-chained SPI setup. The position is used when calling ReadRegister() and WriteRegister() to determine the correct padding for daisy-chain communication.

Note
The daisy-chain position determines how many 40-bit dummy datagrams are sent before this chip's command, ensuring the command reaches the correct chip in the chain. Only applicable for SPI communication interfaces.

◆ SetUartNodeAddress()

template<typename CommType >
void tmc51x0::TMC51x0< CommType >::Communication::SetUartNodeAddress ( uint8_t address)
inlinenoexcept

Set the UART node address for this TMC51x0 instance.

Parameters
addressUART node address (0-254)

This method configures the node address of this driver in a UART multi-node setup. The address is used when calling ReadRegister() and WriteRegister() to determine the correct node address for UART communication.

Note
The node address must be programmed into the chip via NODECONF register (using ConfigureUartNodeAddress() or uartConfig.ConfigureUartNodeAddress()). This method only updates the software representation. Only applicable for UART communication interfaces.

Member Data Documentation

◆ driver_

template<typename CommType >
TMC51x0& tmc51x0::TMC51x0< CommType >::Communication::driver_
private

Reference to parent driver instance.


The documentation for this struct was generated from the following file: