Communication subsystem.
More...
#include <tmc51x0.hpp>
template<typename CommType>
struct tmc51x0::TMC51x0< CommType >::Communication
Communication subsystem.
Provides methods for configuring UART node addressing and multi-chip setups.
◆ Communication()
template<typename CommType >
Construct communication subsystem.
- Parameters
-
| driver | Reference to parent TMC51x0 driver instance |
◆ 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_address | UART node address (0-254), same as NODECONF.NODEADDR NODECONF |
| send_delay | Number 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 >
Set clock frequency from ExternalClockConfig (high-level method)
- Parameters
-
| config | External 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 >
Set clock frequency on CLK pin.
- Parameters
-
| frequency_hz | Clock 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
-
| position | Position 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
-
| address | UART 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.
◆ driver_
template<typename CommType >
Reference to parent driver instance.
The documentation for this struct was generated from the following file: