TLE92466ED Driver 0.1.0-dev
Modern C++20 driver for Infineon TLE92466ED Six-Channel Low-Side Solenoid Driver
Loading...
Searching...
No Matches
Esp32Tle92466edSpiBus Class Reference

ESP32 implementation of the TLE92466ED CommInterface. More...

#include <esp32_tle92466ed_bus.hpp>

Inheritance diagram for Esp32Tle92466edSpiBus:
[legend]
Collaboration diagram for Esp32Tle92466edSpiBus:
[legend]

Classes

struct  SPIConfig
 SPI configuration structure for ESP32. More...
 

Public Member Functions

 Esp32Tle92466edSpiBus ()
 Constructor with default SPI configuration.
 
 Esp32Tle92466edSpiBus (const SPIConfig &config) noexcept
 Constructor with custom SPI configuration.
 
 ~Esp32Tle92466edSpiBus () noexcept
 Destructor - cleans up SPI resources.
 
auto Init () noexcept -> CommResult< void >
 Initialize the CommInterface (must be called before use)
 
auto Deinit () noexcept -> CommResult< void >
 Deinitialize the CommInterface.
 
auto Transfer32 (uint32_t tx_data) noexcept -> CommResult< uint32_t >
 Transfer 32-bit data via SPI (full-duplex)
 
auto TransferMulti (std::span< const uint32_t > tx_data, std::span< uint32_t > rx_data) noexcept -> CommResult< void >
 Transfer multiple 32-bit words via SPI.
 
auto Delay (uint32_t microseconds) noexcept -> CommResult< void >
 Delay for specified duration.
 
auto Configure (const tle92466ed::SPIConfig &config) noexcept -> CommResult< void >
 Configure SPI parameters.
 
bool IsReady () const noexcept
 Check if hardware is ready for communication.
 
CommError GetLastError () const noexcept
 Get the last error that occurred.
 
auto ClearErrors () noexcept -> CommResult< void >
 Clear any pending errors.
 
auto getConfig () const noexcept -> const SPIConfig &
 Get the current SPI configuration.
 
auto GpioSet (CtrlPin pin, GpioSignal signal) noexcept -> CommResult< void >
 Set GPIO control pin signal.
 
auto GpioRead (CtrlPin pin) noexcept -> CommResult< GpioSignal >
 Read GPIO control pin signal.
 
void Log (LogLevel level, const char *tag, const char *format, va_list args) noexcept
 Log a message with specified severity level and tag (ESP_LOG implementation)
 
auto isInitialized () const noexcept -> bool
 Check if CommInterface is initialized.
 

Private Member Functions

auto initializeGPIO () noexcept -> CommResult< void >
 Initialize GPIO pins (RESN, EN, FAULTN)
 
auto initializeSPI () noexcept -> CommResult< void >
 Initialize SPI bus.
 
auto addSPIDevice () noexcept -> CommResult< void >
 Add SPI device to the bus.
 

Private Attributes

SPIConfig config_
 SPI configuration.
 
spi_device_handle_t spi_device_ = nullptr
 SPI device handle.
 
bool initialized_ = false
 Initialization state.
 
CommError last_error_ = CommError::None
 Last error that occurred.
 

Static Private Attributes

static constexpr const char * TAG = "Esp32TleComm"
 Logging tag.
 

Detailed Description

ESP32 implementation of the TLE92466ED CommInterface.

This class provides the platform-specific implementation for ESP32, handling SPI communication with proper timing and error handling.

Constructor & Destructor Documentation

◆ Esp32Tle92466edSpiBus() [1/2]

Esp32Tle92466edSpiBus::Esp32Tle92466edSpiBus ( )
inline

Constructor with default SPI configuration.

◆ Esp32Tle92466edSpiBus() [2/2]

Esp32Tle92466edSpiBus::Esp32Tle92466edSpiBus ( const SPIConfig & config)
inlineexplicitnoexcept

Constructor with custom SPI configuration.

Parameters
configSPI configuration parameters

◆ ~Esp32Tle92466edSpiBus()

Esp32Tle92466edSpiBus::~Esp32Tle92466edSpiBus ( )
inlinenoexcept

Destructor - cleans up SPI resources.

Defined inline to avoid incomplete type issues with std::unique_ptr

Member Function Documentation

◆ addSPIDevice()

auto Esp32Tle92466edSpiBus::addSPIDevice ( ) -> CommResult<void>
inlineprivatenoexcept

Add SPI device to the bus.

Returns
CommResult<void> Success or error

◆ ClearErrors()

auto Esp32Tle92466edSpiBus::ClearErrors ( ) -> CommResult<void>
inlinenoexcept

Clear any pending errors.

Returns
CommResult<void> Success or error

◆ Configure()

auto Esp32Tle92466edSpiBus::Configure ( const tle92466ed::SPIConfig & config) -> CommResult<void>
inlinenoexcept

Configure SPI parameters.

Parameters
configNew SPI configuration
Returns
CommResult<void> Success or error

◆ Deinit()

auto Esp32Tle92466edSpiBus::Deinit ( ) -> CommResult<void>
inlinenoexcept

Deinitialize the CommInterface.

Returns
CommResult<void> Success or error

◆ Delay()

auto Esp32Tle92466edSpiBus::Delay ( uint32_t microseconds) -> CommResult<void>
inlinenoexcept

Delay for specified duration.

Parameters
microsecondsDuration to delay in microseconds
Returns
CommResult<void> Success or error

◆ getConfig()

auto Esp32Tle92466edSpiBus::getConfig ( ) const -> const SPIConfig&
inlinenoexcept

Get the current SPI configuration.

Returns
Current SPI configuration

◆ GetLastError()

CommError Esp32Tle92466edSpiBus::GetLastError ( ) const
inlinenoexcept

Get the last error that occurred.

Returns
CommError The last error code

◆ GpioRead()

auto Esp32Tle92466edSpiBus::GpioRead ( CtrlPin pin) -> CommResult<GpioSignal>
inlinenoexcept

Read GPIO control pin signal.

Parameters
pinControl pin to read (FAULTN)
Returns
CommResult<GpioSignal> Pin signal level or error
Note
The mapping from physical GPIO level to GpioSignal is the responsibility of this bus implementation. FAULTN is active-low: physical 0 = ACTIVE.

◆ GpioSet()

auto Esp32Tle92466edSpiBus::GpioSet ( CtrlPin pin,
GpioSignal signal ) -> CommResult<void>
inlinenoexcept

Set GPIO control pin signal.

Parameters
pinControl pin to set (RESN or EN)
signalGPIO signal level (ACTIVE or INACTIVE)
Returns
CommResult<void> Success or error
Note
The mapping from GpioSignal to physical GPIO level is the responsibility of this bus implementation based on the board's active-level design. For TLE92466ED: RESN is active-low, EN is active-high.

◆ Init()

auto Esp32Tle92466edSpiBus::Init ( ) -> CommResult<void>
inlinenoexcept

Initialize the CommInterface (must be called before use)

Returns
CommResult<void> Success or error

◆ initializeGPIO()

auto Esp32Tle92466edSpiBus::initializeGPIO ( ) -> CommResult<void>
inlineprivatenoexcept

Initialize GPIO pins (RESN, EN, FAULTN)

Returns
CommResult<void> Success or error

◆ initializeSPI()

auto Esp32Tle92466edSpiBus::initializeSPI ( ) -> CommResult<void>
inlineprivatenoexcept

Initialize SPI bus.

Returns
CommResult<void> Success or error

◆ isInitialized()

auto Esp32Tle92466edSpiBus::isInitialized ( ) const -> bool
inlinenoexcept

Check if CommInterface is initialized.

Returns
true if initialized, false otherwise

◆ IsReady()

bool Esp32Tle92466edSpiBus::IsReady ( ) const
inlinenoexcept

Check if hardware is ready for communication.

Returns
true if ready, false otherwise

◆ Log()

void Esp32Tle92466edSpiBus::Log ( LogLevel level,
const char * tag,
const char * format,
va_list args )
inlinenoexcept

Log a message with specified severity level and tag (ESP_LOG implementation)

Parameters
levelLog severity level
tagTag/component name for the log message
formatFormat string (printf-style)
argsva_list of arguments

◆ Transfer32()

auto Esp32Tle92466edSpiBus::Transfer32 ( uint32_t tx_data) -> CommResult<uint32_t>
inlinenoexcept

Transfer 32-bit data via SPI (full-duplex)

Parameters
tx_dataThe 32-bit data to transmit
Returns
CommResult<uint32_t> Received 32-bit data or error

◆ TransferMulti()

auto Esp32Tle92466edSpiBus::TransferMulti ( std::span< const uint32_t > tx_data,
std::span< uint32_t > rx_data ) -> CommResult<void>
inlinenoexcept

Transfer multiple 32-bit words via SPI.

Parameters
tx_dataSpan of transmit data (32-bit words)
rx_dataSpan to store received data (32-bit words)
Returns
CommResult<void> Success or error

Member Data Documentation

◆ config_

SPIConfig Esp32Tle92466edSpiBus::config_
private

SPI configuration.

◆ initialized_

bool Esp32Tle92466edSpiBus::initialized_ = false
private

Initialization state.

◆ last_error_

CommError Esp32Tle92466edSpiBus::last_error_ = CommError::None
private

Last error that occurred.

◆ spi_device_

spi_device_handle_t Esp32Tle92466edSpiBus::spi_device_ = nullptr
private

SPI device handle.

◆ TAG

constexpr const char* Esp32Tle92466edSpiBus::TAG = "Esp32TleComm"
staticconstexprprivate

Logging tag.


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