|
TLE92466ED Driver 0.1.0-preview
Modern C++23 driver for Infineon TLE92466ED Six-Channel Low-Side Solenoid Driver
|
Abstract Hardware Abstraction Layer (HAL) base class. More...
#include <TLE92466ED_HAL.hpp>
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. | |
| HAL & | operator= (const HAL &)=delete |
| HAL (HAL &&) noexcept=default | |
| Allow moving. | |
| HAL & | operator= (HAL &&) noexcept=default |
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:
|
virtualdefault |
Virtual destructor for polymorphic behavior.
|
protecteddefault |
Protected constructor to prevent direct instantiation.
This class can only be instantiated through derived classes.
|
protecteddelete |
Prevent copying.
|
protecteddefaultnoexcept |
Allow moving.
|
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.
| HALError::ChipselectError | CS control failed |
Implemented in TLE92466ED::ExampleHAL.
|
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.
| HALError::ChipselectError | CS control failed |
Implemented in TLE92466ED::ExampleHAL.
|
pure virtualnoexcept |
Clear any pending errors.
Resets the error state. Should be called after handling an error condition and before retrying operations.
Implemented in TLE92466ED::ExampleHAL.
|
pure virtualnoexcept |
Configure SPI parameters.
Updates the SPI configuration. Can be called at runtime to adjust communication parameters.
| [in] | config | New SPI configuration |
| HALError::InvalidParameter | Invalid configuration |
Implemented in TLE92466ED::ExampleHAL.
|
pure virtualnoexcept |
Deinitialize the hardware interface.
Releases hardware resources and disables the SPI peripheral. Should be called when the driver is no longer needed.
Implemented in TLE92466ED::ExampleHAL.
|
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.
| [in] | microseconds | Duration to delay in microseconds |
Implemented in TLE92466ED::ExampleHAL.
|
pure virtualnoexcept |
Get the last error that occurred.
Retrieves the most recent error code. Useful for debugging and error recovery.
Implemented in TLE92466ED::ExampleHAL.
|
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.
| HALError::None | Initialization successful |
| HALError::HardwareNotReady | Hardware initialization failed |
| HALError::InvalidParameter | Invalid configuration |
Implemented in TLE92466ED::ExampleHAL.
|
pure virtualnoexcept |
Check if hardware is ready for communication.
Verifies that the hardware interface is initialized and ready for SPI transactions.
Implemented in TLE92466ED::ExampleHAL.
|
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:
| [in] | tx_data | The 32-bit data to transmit |
| HALError::TransferError | SPI transfer failed |
| HALError::Timeout | Transfer timeout |
Implemented in TLE92466ED::ExampleHAL.
|
pure virtualnoexcept |
Transfer multiple 32-bit words via SPI.
Performs multiple consecutive SPI transfers efficiently. Useful for reading or writing multiple registers in sequence.
| [in] | tx_data | Span of transmit data (32-bit words) |
| [out] | rx_data | Span to store received data (32-bit words) |
| HALError::InvalidParameter | Buffer size mismatch |
| HALError::TransferError | Transfer failed |
Implemented in TLE92466ED::ExampleHAL.