HardFOC Core
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
HalSpiTmc5160Comm Class Reference

Concrete SPI communication adapter for TMC5160 using BaseSpi and BaseGpio. More...

#include <Tmc5160Handler.h>

Inheritance diagram for HalSpiTmc5160Comm:

Public Member Functions

 HalSpiTmc5160Comm (BaseSpi &spi, BaseGpio &enable, BaseGpio *diag0=nullptr, BaseGpio *diag1=nullptr, const tmc51x0::PinActiveLevels &active_levels={}) noexcept
 Construct the SPI communication adapter.
 
CRTP-Required Methods
tmc51x0::Result< void > SpiTransfer (const uint8_t *tx, uint8_t *rx, size_t length) noexcept
 Low-level SPI transfer (5 bytes per TMC5160 datagram).
 
tmc51x0::Result< void > GpioSet (tmc51x0::TMC51x0CtrlPin pin, tmc51x0::GpioSignal signal) noexcept
 Set a TMC5160 control pin to a given logical signal state.
 
tmc51x0::Result< tmc51x0::GpioSignal > GpioRead (tmc51x0::TMC51x0CtrlPin pin) noexcept
 Read a TMC5160 control pin's current logical signal state.
 
void DebugLog (int level, const char *tag, const char *format, va_list args) noexcept
 Debug logging — routes to HardFOC Logger.
 
void DelayMs (uint32_t ms) noexcept
 Delay in milliseconds.
 
void DelayUs (uint32_t us) noexcept
 Delay in microseconds.
 
tmc51x0::CommMode GetMode () const noexcept
 Get communication mode (always SPI).
 

Private Attributes

BaseSpi & spi_
 
Tmc5160CtrlPins ctrl_pins_
 
tmc51x0::PinActiveLevels active_levels_
 

Detailed Description

Concrete SPI communication adapter for TMC5160 using BaseSpi and BaseGpio.

Implements all methods required by tmc51x0::SpiCommInterface<HalSpiTmc5160Comm> through the CRTP pattern. This class bridges BaseSpi to the TMC5160 driver's SPI protocol (40-bit datagrams, Mode 3).

Constructor & Destructor Documentation

◆ HalSpiTmc5160Comm()

HalSpiTmc5160Comm::HalSpiTmc5160Comm ( BaseSpi &  spi,
BaseGpio &  enable,
BaseGpio *  diag0 = nullptr,
BaseGpio *  diag1 = nullptr,
const tmc51x0::PinActiveLevels &  active_levels = {} 
)
noexcept

Construct the SPI communication adapter.

Parameters
spiReference to a pre-configured BaseSpi implementation.
enableBaseGpio connected to TMC5160 DRV_ENN (pin 28, active LOW).
diag0Optional BaseGpio connected to DIAG0 (pin 26).
diag1Optional BaseGpio connected to DIAG1 (pin 27).
active_levelsPin active level configuration.

Member Function Documentation

◆ DebugLog()

void HalSpiTmc5160Comm::DebugLog ( int  level,
const char *  tag,
const char *  format,
va_list  args 
)
noexcept

Debug logging — routes to HardFOC Logger.

◆ DelayMs()

void HalSpiTmc5160Comm::DelayMs ( uint32_t  ms)
noexcept

Delay in milliseconds.

◆ DelayUs()

void HalSpiTmc5160Comm::DelayUs ( uint32_t  us)
noexcept

Delay in microseconds.

◆ GetMode()

tmc51x0::CommMode HalSpiTmc5160Comm::GetMode ( ) const
inlinenoexcept

Get communication mode (always SPI).

◆ GpioRead()

tmc51x0::Result< tmc51x0::GpioSignal > HalSpiTmc5160Comm::GpioRead ( tmc51x0::TMC51x0CtrlPin  pin)
noexcept

Read a TMC5160 control pin's current logical signal state.

◆ GpioSet()

tmc51x0::Result< void > HalSpiTmc5160Comm::GpioSet ( tmc51x0::TMC51x0CtrlPin  pin,
tmc51x0::GpioSignal  signal 
)
noexcept

Set a TMC5160 control pin to a given logical signal state.

◆ SpiTransfer()

tmc51x0::Result< void > HalSpiTmc5160Comm::SpiTransfer ( const uint8_t *  tx,
uint8_t *  rx,
size_t  length 
)
noexcept

Low-level SPI transfer (5 bytes per TMC5160 datagram).

Member Data Documentation

◆ active_levels_

tmc51x0::PinActiveLevels HalSpiTmc5160Comm::active_levels_
private

◆ ctrl_pins_

Tmc5160CtrlPins HalSpiTmc5160Comm::ctrl_pins_
private

◆ spi_

BaseSpi& HalSpiTmc5160Comm::spi_
private

The documentation for this class was generated from the following files: