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

CRTP SPI communication adapter for TLE92466ED using BaseSpi and BaseGpio. More...

#include <Tle92466edHandler.h>

Inheritance diagram for HalSpiTle92466edComm:

Public Member Functions

 HalSpiTle92466edComm (BaseSpi &spi, BaseGpio &resn, BaseGpio &en, BaseGpio *faultn=nullptr) noexcept
 Construct the SPI adapter.
 
CRTP-Required Methods
tle92466ed::CommResult< void > Init () noexcept
 Reset pulse, assert EN, then SPI identity / fault clear.
 
tle92466ed::CommResult< void > Deinit () noexcept
 Mark adapter deinitialized; does not change GPIO or SPI state.
 
tle92466ed::CommResult< uint32_t > Transfer32 (uint32_t tx_data) noexcept
 Single 32-bit SPI frame (Mode 1, MSB first).
 
tle92466ed::CommResult< void > TransferMulti (std::span< const uint32_t > tx_data, std::span< uint32_t > rx_data) noexcept
 Pipelined multi-frame SPI transfer under one SPI2 bus lock.
 
tle92466ed::CommResult< void > TransferMulti (std::span< const uint32_t > tx_data, std::span< uint32_t > rx_data, uint32_t gap_us) noexcept
 TransferMulti with an explicit inter-frame CS-high gap.
 
tle92466ed::CommResult< void > Delay (uint32_t microseconds) noexcept
 Busy-wait delay in microseconds (datasheet timing gaps).
 
tle92466ed::CommResult< void > Configure (const tle92466ed::SPIConfig &config) noexcept
 No-op; BaseSpi is pre-configured for Mode 1 / 32-bit frames.
 
bool IsReady () const noexcept
 True after Init succeeded (GPIO polarity parked, SPI ready).
 
tle92466ed::CommError GetLastError () const noexcept
 Last comm-layer error from Transfer32 or GPIO helpers.
 
tle92466ed::CommResult< void > ClearErrors () noexcept
 Clear last_error_; does not clear chip fault registers.
 
tle92466ed::CommResult< void > GpioSet (tle92466ed::CtrlPin pin, tle92466ed::GpioSignal signal) noexcept
 Drive RESN, EN, or FAULTN via configured BaseGpio active levels.
 
tle92466ed::CommResult< tle92466ed::GpioSignal > GpioRead (tle92466ed::CtrlPin pin) noexcept
 Read RESN, EN, or FAULTN logical state.
 
void Log (tle92466ed::LogLevel level, const char *tag, const char *format, va_list args) noexcept
 Route driver log lines to the HAL Logger.
 
uint32_t LastRxWord () const noexcept
 Last 32-bit SPI RX word (bring-up / WrongDeviceID diagnostics).
 
uint32_t LastRxWordFirst () const noexcept
 RX word from the FIRST frame of the last TransferMulti chain.
 

Private Attributes

BaseSpi & spi_
 
BaseGpio & resn_
 
BaseGpio & en_
 
BaseGpio * faultn_
 
bool initialized_ {false}
 
tle92466ed::CommError last_error_ {tle92466ed::CommError::None}
 
uint32_t last_rx_ {0}
 
uint32_t last_rx_first_ {0}
 

Detailed Description

CRTP SPI communication adapter for TLE92466ED using BaseSpi and BaseGpio.

Implements all methods required by tle92466ed::SpiInterface<HalSpiTle92466edComm>.

Note
Bring-up order: Init holds EN LOW only for the RESN pulse, then asserts EN HIGH before the SPI identity read. Channel outputs remain gated by CH_CTRL after POR — EN high is not “outputs energized”. When EN/RESN are expander-backed, claim ownership of those pins before constructing this adapter.

Constructor & Destructor Documentation

◆ HalSpiTle92466edComm()

HalSpiTle92466edComm::HalSpiTle92466edComm ( BaseSpi &  spi,
BaseGpio &  resn,
BaseGpio &  en,
BaseGpio *  faultn = nullptr 
)
noexcept

Construct the SPI adapter.

Parameters
spiReference to pre-configured BaseSpi (Mode 1, 32-bit frames).
resnBaseGpio connected to RESN (reset, active LOW).
enBaseGpio connected to EN (enable, active HIGH).
faultnOptional BaseGpio connected to FAULTN (active LOW input).

Member Function Documentation

◆ ClearErrors()

tle92466ed::CommResult< void > HalSpiTle92466edComm::ClearErrors ( )
noexcept

Clear last_error_; does not clear chip fault registers.

◆ Configure()

tle92466ed::CommResult< void > HalSpiTle92466edComm::Configure ( const tle92466ed::SPIConfig &  config)
noexcept

No-op; BaseSpi is pre-configured for Mode 1 / 32-bit frames.

◆ Deinit()

tle92466ed::CommResult< void > HalSpiTle92466edComm::Deinit ( )
noexcept

Mark adapter deinitialized; does not change GPIO or SPI state.

◆ Delay()

tle92466ed::CommResult< void > HalSpiTle92466edComm::Delay ( uint32_t  microseconds)
noexcept

Busy-wait delay in microseconds (datasheet timing gaps).

◆ GetLastError()

tle92466ed::CommError HalSpiTle92466edComm::GetLastError ( ) const
noexcept

Last comm-layer error from Transfer32 or GPIO helpers.

◆ GpioRead()

tle92466ed::CommResult< tle92466ed::GpioSignal > HalSpiTle92466edComm::GpioRead ( tle92466ed::CtrlPin  pin)
noexcept

Read RESN, EN, or FAULTN logical state.

Returns
ACTIVE when the pin reads as asserted per BaseGpio polarity.

◆ GpioSet()

tle92466ed::CommResult< void > HalSpiTle92466edComm::GpioSet ( tle92466ed::CtrlPin  pin,
tle92466ed::GpioSignal  signal 
)
noexcept

Drive RESN, EN, or FAULTN via configured BaseGpio active levels.

Parameters
pinRESN (active LOW), EN (active HIGH), or FAULTN input.
signalACTIVE / INACTIVE in driver semantics, not raw pin voltage.

◆ Init()

tle92466ed::CommResult< void > HalSpiTle92466edComm::Init ( )
noexcept

Reset pulse, assert EN, then SPI identity / fault clear.

Returns
Failure leaves last RX in LastRxWord for CDC diag.

◆ IsReady()

bool HalSpiTle92466edComm::IsReady ( ) const
noexcept

True after Init succeeded (GPIO polarity parked, SPI ready).

◆ LastRxWord()

uint32_t HalSpiTle92466edComm::LastRxWord ( ) const
inlinenoexcept

Last 32-bit SPI RX word (bring-up / WrongDeviceID diagnostics).

◆ LastRxWordFirst()

uint32_t HalSpiTle92466edComm::LastRxWordFirst ( ) const
inlinenoexcept

RX word from the FIRST frame of the last TransferMulti chain.

A register read is two CS windows and the reply is expected on the second. Keeping the first word lets bring-up tools prove which slot actually carried the reply instead of inferring it from a register that read back as zero.

◆ Log()

void HalSpiTle92466edComm::Log ( tle92466ed::LogLevel  level,
const char *  tag,
const char *  format,
va_list  args 
)
noexcept

Route driver log lines to the HAL Logger.

◆ Transfer32()

tle92466ed::CommResult< uint32_t > HalSpiTle92466edComm::Transfer32 ( uint32_t  tx_data)
noexcept

Single 32-bit SPI frame (Mode 1, MSB first).

Parameters
tx_dataCommand or data word to shift out.
Returns
RX word from this CS window (pipelined reply from the prior frame).
Note
Inserts 20 µs between CS cycles; prefer TransferMulti for reads.

◆ TransferMulti() [1/2]

tle92466ed::CommResult< void > HalSpiTle92466edComm::TransferMulti ( std::span< const uint32_t >  tx_data,
std::span< uint32_t >  rx_data 
)
noexcept

Pipelined multi-frame SPI transfer under one SPI2 bus lock.

Parameters
tx_dataTX words (command frame followed by dummy frame(s) for reads).
rx_dataRX buffer, same length as tx_data.
Returns
CommError::TransferError if BaseSpi::TransferChain fails.
Warning
tx_data and rx_data must be equal length and non-empty. Releasing the bus between frames lets a peer consume this device's pipeline slot (sticky-zero reads).

◆ TransferMulti() [2/2]

tle92466ed::CommResult< void > HalSpiTle92466edComm::TransferMulti ( std::span< const uint32_t >  tx_data,
std::span< uint32_t >  rx_data,
uint32_t  gap_us 
)
noexcept

TransferMulti with an explicit inter-frame CS-high gap.

Parameters
gap_usCS-high time between chained frames in microseconds; 0 selects the production default (5 µs, ≥ datasheet tCSN_TD).

Member Data Documentation

◆ en_

BaseGpio& HalSpiTle92466edComm::en_
private

◆ faultn_

BaseGpio* HalSpiTle92466edComm::faultn_
private

◆ initialized_

bool HalSpiTle92466edComm::initialized_ {false}
private

◆ last_error_

tle92466ed::CommError HalSpiTle92466edComm::last_error_ {tle92466ed::CommError::None}
private

◆ last_rx_

uint32_t HalSpiTle92466edComm::last_rx_ {0}
private

◆ last_rx_first_

uint32_t HalSpiTle92466edComm::last_rx_first_ {0}
private

◆ resn_

BaseGpio& HalSpiTle92466edComm::resn_
private

◆ spi_

BaseSpi& HalSpiTle92466edComm::spi_
private

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