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 >::Io Struct Reference

Chip IO / mode pins / IOIN helpers. More...

#include <tmc51x0.hpp>

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

Public Member Functions

 Io (TMC51x0 &driver) noexcept
 
Result< void > SetOperatingMode (ChipCommMode mode) noexcept
 Set the chip operating mode via SPI_MODE and SD_MODE pins.
 
Result< ChipCommModeGetOperatingMode () const noexcept
 Read the current mode-pin state (SPI_MODE/SD_MODE)
 
Result< InputStatusReadInputStatus () noexcept
 Read GPIO input pins (parsed) from IOIN.
 
Result< uint8_t > ReadIcVersion () noexcept
 Read IC version from IOIN.
 
Result< uint32_t > ReadGpioPins () noexcept
 Read GPIO input pins (raw) from IOIN.
 
Result< void > SetSdoCfg0Polarity (bool polarity) noexcept
 Set SDO_CFG0 pin polarity (UART/Single Wire mode)
 

Private Attributes

TMC51x0driver_
 

Detailed Description

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

Chip IO / mode pins / IOIN helpers.

Groups "pin-state / IOIN / mode pins" operations so they don't get mixed into status monitoring or communication addressing.

Constructor & Destructor Documentation

◆ Io()

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

Member Function Documentation

◆ GetOperatingMode()

template<typename CommType >
Result< ChipCommMode > tmc51x0::TMC51x0< CommType >::Io::GetOperatingMode ( ) const
noexcept

Read the current mode-pin state (SPI_MODE/SD_MODE)

Returns
Result<ChipCommMode> containing the value or error

This method reads the current state of SPI_MODE (pin 22) and SD_MODE (pin 21) pins if they are connected to GPIO inputs/outputs.

Note
This reads the current pin state, which may not reflect the actual chip mode if the chip hasn't been reset since the pins were changed.

◆ ReadGpioPins()

template<typename CommType >
Result< uint32_t > tmc51x0::TMC51x0< CommType >::Io::ReadGpioPins ( )
noexcept

Read GPIO input pins (raw) from IOIN.

Returns
Result<uint32_t> containing the value or error

◆ ReadIcVersion()

template<typename CommType >
Result< uint8_t > tmc51x0::TMC51x0< CommType >::Io::ReadIcVersion ( )
noexcept

Read IC version from IOIN.

Returns
Result<uint8_t> containing the value or error

◆ ReadInputStatus()

template<typename CommType >
Result< InputStatus > tmc51x0::TMC51x0< CommType >::Io::ReadInputStatus ( )
noexcept

Read GPIO input pins (parsed) from IOIN.

Returns
Result<InputStatus> containing the value or error

◆ SetOperatingMode()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Io::SetOperatingMode ( ChipCommMode mode)
noexcept

Set the chip operating mode via SPI_MODE and SD_MODE pins.

Parameters
modeOperating mode (SPI_INTERNAL_RAMP, SPI_EXTERNAL_STEPDIR, UART_INTERNAL_RAMP, STANDALONE_EXTERNAL_STEPDIR)
Returns
Result<void> indicating success or error

This method controls the SPI_MODE (pin 22) and SD_MODE (pin 21) pins if they are connected to GPIO outputs. These pins determine both the communication interface (SPI/UART/Standalone) and the motion control method (Internal ramp generator vs External step/dir).

CRITICAL WARNINGS:

  • These pins are typically hardwired and read at startup
  • Only use this method if SPI_MODE and SD_MODE pins are connected to GPIO outputs
  • Changing the mode requires a chip reset (power cycle) to take effect
  • The mode pins are read at startup, so changes won't be effective until reset
  • Ensure pins are configured in TMC51x0PinConfig (spi_mode_pin and sd_mode_pin)
Note
After calling this method, you must reset the chip for the new mode to take effect. The driver does not automatically reset the chip - you must handle this externally.
Operating mode pin mapping:
  • SPI_INTERNAL_RAMP: SPI_MODE=HIGH, SD_MODE=LOW (SPI interface + internal ramp generator)
  • SPI_EXTERNAL_STEPDIR: SPI_MODE=HIGH, SD_MODE=HIGH (SPI interface + external step/dir inputs)
  • UART_INTERNAL_RAMP: SPI_MODE=LOW, SD_MODE=LOW (UART interface + internal ramp generator)
  • STANDALONE_EXTERNAL_STEPDIR: SPI_MODE=LOW, SD_MODE=HIGH (Standalone + external step/dir, CFG pins configure driver)

◆ SetSdoCfg0Polarity()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Io::SetSdoCfg0Polarity ( bool polarity)
noexcept

Set SDO_CFG0 pin polarity (UART/Single Wire mode)

Parameters
polarityOutput pin polarity (false=normal/active high, true=inverted/active low)
Returns
Result<void> indicating success or error

Member Data Documentation

◆ driver_

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

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