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

TMC5160 SPI command structure with union-based frame representation. More...

#include <tmc51x0_comm_interface.hpp>

Collaboration diagram for tmc51x0::SpiCommand:
[legend]

Classes

union  Frame
 Union for accessing the 40-bit SPI frame in different ways. More...
 

Public Member Functions

uint8_t GetAddress () const noexcept
 Get register address (bits 6-0 of address byte)
 
bool IsWrite () const noexcept
 Check if this is a write command.
 
uint32_t GetValue () const noexcept
 Get 32-bit data value (for writes) or dummy data (for reads)
 
void SetFrame (const uint8_t *bytes) noexcept
 Set the 5-byte frame from raw bytes.
 
void GetFrame (uint8_t *bytes) const noexcept
 Get the 5-byte frame as raw bytes.
 

Static Public Member Functions

static SpiCommand Read (uint8_t addr) noexcept
 Construct a read command.
 
static SpiCommand Write (uint8_t addr, uint32_t val) noexcept
 Construct a write command.
 

Public Attributes

union tmc51x0::SpiCommand::Frame frame
 The 40-bit SPI frame.
 

Detailed Description

TMC5160 SPI command structure with union-based frame representation.

Represents a standard TMC5160 SPI command (40 bits: 8-bit address + 32-bit data). Used for both single-chip and multi-chip (daisy-chain) communication. In daisy-chain mode, multiple commands are sent in one SPI transfer.

The frame is structured as:

  • Byte 0: Address byte (bit 7 = write bit, bits 6-0 = register address)
  • Bytes 1-4: 32-bit data value (MSB-first, big-endian)

Member Function Documentation

◆ GetAddress()

uint8_t tmc51x0::SpiCommand::GetAddress ( ) const
inlinenoexcept

Get register address (bits 6-0 of address byte)

Returns
Register address (0x00-0x73)

◆ GetFrame()

void tmc51x0::SpiCommand::GetFrame ( uint8_t * bytes) const
inlinenoexcept

Get the 5-byte frame as raw bytes.

Parameters
bytesOutput buffer (must be at least 5 bytes)
Here is the caller graph for this function:

◆ GetValue()

uint32_t tmc51x0::SpiCommand::GetValue ( ) const
inlinenoexcept

Get 32-bit data value (for writes) or dummy data (for reads)

Returns
32-bit value (MSB-first from bytes 1-4)

◆ IsWrite()

bool tmc51x0::SpiCommand::IsWrite ( ) const
inlinenoexcept

Check if this is a write command.

Returns
true if write command (bit 7 of address byte is set)

◆ Read()

static SpiCommand tmc51x0::SpiCommand::Read ( uint8_t addr)
inlinestaticnoexcept

Construct a read command.

Parameters
addrRegister address to read (0x00-0x73)
Here is the caller graph for this function:

◆ SetFrame()

void tmc51x0::SpiCommand::SetFrame ( const uint8_t * bytes)
inlinenoexcept

Set the 5-byte frame from raw bytes.

Parameters
bytesPointer to 5 bytes (MSB-first)

◆ Write()

static SpiCommand tmc51x0::SpiCommand::Write ( uint8_t addr,
uint32_t val )
inlinestaticnoexcept

Construct a write command.

Parameters
addrRegister address to write (0x00-0x73)
val32-bit value to write
Here is the caller graph for this function:

Member Data Documentation

◆ frame

union tmc51x0::SpiCommand::Frame tmc51x0::SpiCommand::frame

The 40-bit SPI frame.


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