TLE92466ED Driver 0.1.0-preview
Modern C++23 driver for Infineon TLE92466ED Six-Channel Low-Side Solenoid Driver
Loading...
Searching...
No Matches
TLE92466ED::HAL Class Referenceabstract

Abstract Hardware Abstraction Layer (HAL) base class. More...

#include <TLE92466ED_HAL.hpp>

Inheritance diagram for TLE92466ED::HAL:
[legend]

Public Member Functions

virtual ~HAL ()=default
 Virtual destructor for polymorphic behavior.
 
virtual HALResult< void > init () noexcept=0
 Initialize the hardware interface.
 
virtual HALResult< void > deinit () noexcept=0
 Deinitialize the hardware interface.
 
virtual HALResult< uint32_t > transfer32 (uint32_t tx_data) noexcept=0
 Transfer 32-bit data via SPI (full-duplex)
 
virtual HALResult< void > transfer_multi (std::span< const uint32_t > tx_data, std::span< uint32_t > rx_data) noexcept=0
 Transfer multiple 32-bit words via SPI.
 
virtual HALResult< void > chip_select () noexcept=0
 Assert (activate) chip select.
 
virtual HALResult< void > chip_deselect () noexcept=0
 Deassert (deactivate) chip select.
 
virtual HALResult< void > delay (uint32_t microseconds) noexcept=0
 Delay for specified duration.
 
virtual HALResult< void > configure (const SPIConfig &config) noexcept=0
 Configure SPI parameters.
 
virtual bool is_ready () const noexcept=0
 Check if hardware is ready for communication.
 
virtual HALError get_last_error () const noexcept=0
 Get the last error that occurred.
 
virtual HALResult< void > clear_errors () noexcept=0
 Clear any pending errors.
 

Protected Member Functions

 HAL ()=default
 Protected constructor to prevent direct instantiation.
 
 HAL (const HAL &)=delete
 Prevent copying.
 
HALoperator= (const HAL &)=delete
 
 HAL (HAL &&) noexcept=default
 Allow moving.
 
HALoperator= (HAL &&) noexcept=default
 

Detailed Description

Abstract Hardware Abstraction Layer (HAL) base class.

This pure virtual base class defines the interface that must be implemented for hardware-specific SPI communication. Users must derive from this class and implement the virtual functions for their specific hardware platform (e.g., STM32, ESP32, Arduino, Linux, etc.).

The HAL uses modern C++20/23 features including:

  • Concepts for compile-time constraints
  • std::span for safe array access
  • std::expected for error handling
  • uint32_t for time management (microseconds)
32-Bit SPI Communication:
The TLE92466ED requires 32-bit SPI frames. Implementations must:
  • Transfer 4 bytes (32 bits) per transaction
  • Maintain MSB-first byte order
  • Support full-duplex operation
  • Calculate and verify CRC-8 (SAE J1850)
Example Implementation:
class MyPlatformHAL : public TLE92466ED::HAL {
public:
HALResult<uint32_t> transfer32(uint32_t data) noexcept override {
uint32_t result = spi_transfer_32bit(data);
if (spi_error()) {
return std::unexpected(HALError::TransferError);
}
return result;
}
// ... implement other virtual functions
};
Abstract Hardware Abstraction Layer (HAL) base class.
Definition TLE92466ED_HAL.hpp:124
std::expected< T, HALError > HALResult
Result type for HAL operations using std::expected (C++23)
Definition TLE92466ED_HAL.hpp:62
Thread Safety:
Implementations must ensure thread-safety for multi-threaded environments.
Hardware Requirements:
  • SPI peripheral capable of 32-bit transfers (or 4x 8-bit)
  • Minimum frequency: 100 kHz
  • Maximum frequency: 10 MHz
  • Support for SPI Mode 0 (CPOL=0, CPHA=0)
  • CRC calculation capability (hardware or software)

Constructor & Destructor Documentation

◆ ~HAL()

virtual TLE92466ED::HAL::~HAL ( )
virtualdefault

Virtual destructor for polymorphic behavior.

◆ HAL() [1/3]

TLE92466ED::HAL::HAL ( )
protecteddefault

Protected constructor to prevent direct instantiation.

This class can only be instantiated through derived classes.

◆ HAL() [2/3]

TLE92466ED::HAL::HAL ( const HAL & )
protecteddelete

Prevent copying.

◆ HAL() [3/3]

TLE92466ED::HAL::HAL ( HAL && )
protecteddefaultnoexcept

Allow moving.

Member Function Documentation

◆ chip_deselect()

virtual HALResult< void > TLE92466ED::HAL::chip_deselect ( )
pure virtualnoexcept

Deassert (deactivate) chip select.

Pulls the CS line high to deselect the TLE92466ED after communication. Must be called after SPI transfers in manual CS mode.

Returns
HALResult<void> Success or error code
Return values
HALError::ChipselectErrorCS control failed

Implemented in TLE92466ED::ExampleHAL.

◆ chip_select()

virtual HALResult< void > TLE92466ED::HAL::chip_select ( )
pure virtualnoexcept

Assert (activate) chip select.

Pulls the CS line low to select the TLE92466ED for communication. Must be called before SPI transfers in manual CS mode.

Returns
HALResult<void> Success or error code
Return values
HALError::ChipselectErrorCS control failed
Note
Some implementations may handle CS automatically in transfer32()

Implemented in TLE92466ED::ExampleHAL.

◆ clear_errors()

virtual HALResult< void > TLE92466ED::HAL::clear_errors ( )
pure virtualnoexcept

Clear any pending errors.

Resets the error state. Should be called after handling an error condition and before retrying operations.

Returns
HALResult<void> Success or error code

Implemented in TLE92466ED::ExampleHAL.

◆ configure()

virtual HALResult< void > TLE92466ED::HAL::configure ( const SPIConfig & config)
pure virtualnoexcept

Configure SPI parameters.

Updates the SPI configuration. Can be called at runtime to adjust communication parameters.

Parameters
[in]configNew SPI configuration
Returns
HALResult<void> Success or error code
Return values
HALError::InvalidParameterInvalid configuration
TLE92466ED SPI Requirements:
  • Frequency: 100 kHz - 10 MHz
  • Mode: 0 (CPOL=0, CPHA=0)
  • Bit order: MSB first
  • Frame size: 32 bits (4 bytes)

Implemented in TLE92466ED::ExampleHAL.

◆ deinit()

virtual HALResult< void > TLE92466ED::HAL::deinit ( )
pure virtualnoexcept

Deinitialize the hardware interface.

Releases hardware resources and disables the SPI peripheral. Should be called when the driver is no longer needed.

Returns
HALResult<void> Success or error code

Implemented in TLE92466ED::ExampleHAL.

◆ delay()

virtual HALResult< void > TLE92466ED::HAL::delay ( uint32_t microseconds)
pure virtualnoexcept

Delay for specified duration.

Provides a hardware-specific delay implementation. Required for timing constraints such as reset pulse width and power-up delays.

Parameters
[in]microsecondsDuration to delay in microseconds
Returns
HALResult<void> Success or error code
Timing Requirements:
  • Reset pulse width: minimum 1µs
  • Power-up delay: minimum 1ms

Implemented in TLE92466ED::ExampleHAL.

◆ get_last_error()

virtual HALError TLE92466ED::HAL::get_last_error ( ) const
pure virtualnoexcept

Get the last error that occurred.

Retrieves the most recent error code. Useful for debugging and error recovery.

Returns
HALError The last error code

Implemented in TLE92466ED::ExampleHAL.

◆ init()

virtual HALResult< void > TLE92466ED::HAL::init ( )
pure virtualnoexcept

Initialize the hardware interface.

This function should initialize the SPI peripheral, configure GPIO pins, and prepare the hardware for communication. It should be called before any other HAL functions.

Returns
HALResult<void> Success or error code
Return values
HALError::NoneInitialization successful
HALError::HardwareNotReadyHardware initialization failed
HALError::InvalidParameterInvalid configuration

Implemented in TLE92466ED::ExampleHAL.

◆ is_ready()

virtual bool TLE92466ED::HAL::is_ready ( ) const
pure virtualnoexcept

Check if hardware is ready for communication.

Verifies that the hardware interface is initialized and ready for SPI transactions.

Returns
true if ready, false otherwise

Implemented in TLE92466ED::ExampleHAL.

◆ operator=() [1/2]

HAL & TLE92466ED::HAL::operator= ( const HAL & )
protecteddelete

◆ operator=() [2/2]

HAL & TLE92466ED::HAL::operator= ( HAL && )
protecteddefaultnoexcept

◆ transfer32()

virtual HALResult< uint32_t > TLE92466ED::HAL::transfer32 ( uint32_t tx_data)
pure virtualnoexcept

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

Performs a full-duplex SPI transaction, simultaneously sending and receiving 32 bits of data. This is the primary communication method for the TLE92466ED.

The TLE92466ED requires 32-bit SPI frames with the following format:

  • Bits [31:24]: CRC-8 (SAE J1850)
  • Bits [23:17]: Register address (7 bits of 10-bit address)
  • Bit [16]: R/W (1=Write, 0=Read)
  • Bits [15:0]: Data (16 bits)
Parameters
[in]tx_dataThe 32-bit data to transmit
Returns
HALResult<uint32_t> Received 32-bit data or error
Return values
HALError::TransferErrorSPI transfer failed
HALError::TimeoutTransfer timeout
Timing Requirements:
  • CS must be held low during entire 32-bit transfer
  • Minimum CS inactive time between transfers: 100ns
  • Data sampled on rising edge (CPHA=0)
Note
CRC calculation is handled by the driver layer, not HAL

Implemented in TLE92466ED::ExampleHAL.

◆ transfer_multi()

virtual HALResult< void > TLE92466ED::HAL::transfer_multi ( std::span< const uint32_t > tx_data,
std::span< uint32_t > rx_data )
pure virtualnoexcept

Transfer multiple 32-bit words via SPI.

Performs multiple consecutive SPI transfers efficiently. Useful for reading or writing multiple registers in sequence.

Parameters
[in]tx_dataSpan of transmit data (32-bit words)
[out]rx_dataSpan to store received data (32-bit words)
Returns
HALResult<void> Success or error code
Return values
HALError::InvalidParameterBuffer size mismatch
HALError::TransferErrorTransfer failed
Precondition
tx_data.size() == rx_data.size()
Both spans must be valid for the duration of the transfer

Implemented in TLE92466ED::ExampleHAL.


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