|
TLE92466ED Driver 0.1.0-preview
Modern C++23 driver for Infineon TLE92466ED Six-Channel Low-Side Solenoid Driver
|
Main TLE92466ED driver class. More...
#include <TLE92466ED.hpp>
Public Member Functions | |
| Driver (HAL &hal) noexcept | |
| Construct driver with HAL interface. | |
| ~Driver () noexcept | |
| Destructor - ensures clean shutdown. | |
| Driver (const Driver &)=delete | |
| Driver & | operator= (const Driver &)=delete |
| Driver (Driver &&) noexcept=delete | |
| Driver & | operator= (Driver &&) noexcept=delete |
| DriverResult< void > | init () noexcept |
| Initialize the driver and hardware. | |
| DriverResult< void > | enter_mission_mode () noexcept |
| Enter Mission Mode (enables channel control) | |
| DriverResult< void > | enter_config_mode () noexcept |
| Enter Config Mode (allows configuration changes) | |
| bool | is_mission_mode () const noexcept |
| Check if in mission mode. | |
| DriverResult< void > | configure_global (const GlobalConfig &config) noexcept |
| Configure global device settings. | |
| DriverResult< void > | set_crc_enabled (bool enabled) noexcept |
| Enable/disable CRC checking. | |
| DriverResult< void > | set_vbat_thresholds (uint8_t uv_threshold, uint8_t ov_threshold) noexcept |
| Configure VBAT under/overvoltage thresholds. | |
| DriverResult< void > | enable_channel (Channel channel, bool enabled) noexcept |
| Enable or disable a channel. | |
| DriverResult< void > | enable_channels (uint8_t channel_mask) noexcept |
| Enable or disable multiple channels. | |
| DriverResult< void > | enable_all_channels () noexcept |
| Enable all channels. | |
| DriverResult< void > | disable_all_channels () noexcept |
| Disable all channels. | |
| DriverResult< void > | set_channel_mode (Channel channel, ChannelMode mode) noexcept |
| Set channel operation mode. | |
| DriverResult< void > | set_parallel_operation (ParallelPair pair, bool enabled) noexcept |
| Configure channel for parallel operation. | |
| DriverResult< void > | set_current_setpoint (Channel channel, uint16_t current_ma, bool parallel_mode=false) noexcept |
| Set current setpoint for channel. | |
| DriverResult< uint16_t > | get_current_setpoint (Channel channel, bool parallel_mode=false) noexcept |
| Get current setpoint for channel. | |
| DriverResult< void > | configure_pwm_period (Channel channel, uint8_t period_mantissa, uint8_t period_exponent, bool low_freq_range=false) noexcept |
| Configure PWM parameters for ICC. | |
| DriverResult< void > | configure_dither (Channel channel, uint16_t step_size, uint8_t num_steps, uint8_t flat_steps) noexcept |
| Configure dither parameters. | |
| DriverResult< void > | configure_channel (Channel channel, const ChannelConfig &config) noexcept |
| Configure channel slew rate and diagnostics. | |
| DriverResult< DeviceStatus > | get_device_status () noexcept |
| Get global device status. | |
| DriverResult< ChannelDiagnostics > | get_channel_diagnostics (Channel channel) noexcept |
| Get channel diagnostic information. | |
| DriverResult< uint16_t > | get_average_current (Channel channel, bool parallel_mode=false) noexcept |
| Get average current for a channel. | |
| DriverResult< uint16_t > | get_duty_cycle (Channel channel) noexcept |
| Get PWM duty cycle for a channel. | |
| DriverResult< uint16_t > | get_vbat_voltage () noexcept |
| Get VBAT voltage. | |
| DriverResult< uint16_t > | get_vio_voltage () noexcept |
| Get VIO voltage | |
| DriverResult< void > | clear_faults () noexcept |
| Clear all fault flags. | |
| DriverResult< bool > | has_any_fault () noexcept |
| Check if any fault exists. | |
| DriverResult< void > | software_reset () noexcept |
| Software reset of the device. | |
| DriverResult< void > | reload_spi_watchdog (uint16_t reload_value) noexcept |
| Reload SPI watchdog counter. | |
| DriverResult< uint16_t > | get_ic_version () noexcept |
| Read IC version and ID. | |
| DriverResult< std::array< uint16_t, 3 > > | get_chip_id () noexcept |
| Read unique chip ID. | |
| DriverResult< bool > | verify_device () noexcept |
| Verify device ID matches expected value. | |
| bool | is_initialized () const noexcept |
| Check if driver is initialized. | |
| DriverResult< uint16_t > | read_register (uint16_t address, bool verify_crc=true) noexcept |
| Read 16-bit register. | |
| DriverResult< void > | write_register (uint16_t address, uint16_t value, bool verify_crc=true) noexcept |
| Write 16-bit register. | |
| DriverResult< void > | modify_register (uint16_t address, uint16_t mask, uint16_t value) noexcept |
| Modify register bits. | |
Private Member Functions | |
| DriverResult< SPIFrame > | transfer_frame (const SPIFrame &tx_frame, bool verify_crc=true) noexcept |
| Transfer SPI frame with CRC calculation and verification. | |
| constexpr bool | is_valid_channel_internal (Channel channel) const noexcept |
| Validate channel number. | |
| DriverResult< void > | check_initialized () const noexcept |
| Check if driver is initialized. | |
| DriverResult< void > | check_mission_mode () const noexcept |
| Check if in mission mode. | |
| DriverResult< void > | check_config_mode () const noexcept |
| Check if in config mode. | |
| DriverResult< void > | apply_default_config () noexcept |
| Apply default configuration after initialization. | |
| DriverResult< void > | check_spi_status (const SPIFrame &rx_frame) noexcept |
| Parse SPI status from reply frame. | |
| DriverResult< bool > | is_channel_parallel (Channel channel) noexcept |
| Check if channel is currently in parallel mode. | |
Private Attributes | |
| HAL & | hal_ |
| Hardware abstraction layer. | |
| bool | initialized_ |
| Initialization status. | |
| bool | mission_mode_ |
| Mission mode flag (vs config mode) | |
| uint16_t | channel_enable_cache_ |
| Cached channel enable state. | |
| std::array< uint16_t, 6 > | channel_setpoints_ |
| Cached current setpoints. | |
Main TLE92466ED driver class.
This is the primary driver class that provides complete control over the TLE92466ED IC. It manages SPI communication (32-bit with CRC), configuration, current control, monitoring, and diagnostics for all six output channels.
Thread Safety: This class is NOT thread-safe by default. External synchronization is required for multi-threaded access.
Resource Management: Uses RAII principles - init() must be called explicitly but cleanup is automatic.
Error Handling: Uses std::expected for robust error handling without exceptions.
|
inlineexplicitnoexcept |
|
inlinenoexcept |
Destructor - ensures clean shutdown.
|
delete |
|
deletenoexcept |
|
privatenoexcept |
Apply default configuration after initialization.
|
inlineprivatenoexcept |
Check if in config mode.
|
inlineprivatenoexcept |
Check if driver is initialized.
|
inlineprivatenoexcept |
Check if in mission mode.
|
privatenoexcept |
Parse SPI status from reply frame.
|
noexcept |
Clear all fault flags.
Clears latched fault conditions. Does not clear active faults.
|
noexcept |
Configure channel slew rate and diagnostics.
| channel | Channel to configure |
| config | Channel configuration |
|
noexcept |
Configure dither parameters.
| channel | Channel to configure |
| step_size | Dither amplitude (I_dither = steps * step_size * 2A / 32767) |
| num_steps | Number of steps in quarter period |
| flat_steps | Number of flat clock cycles at top/bottom |
|
noexcept |
Configure global device settings.
| config | Global configuration structure |
| DriverError::NotInitialized | Driver not initialized |
| DriverError::WrongMode | Must be in Config Mode |
|
noexcept |
Configure PWM parameters for ICC.
| channel | Channel to configure |
| period_mantissa | PWM period mantissa |
| period_exponent | PWM period exponent (0-7) |
| low_freq_range | Enable low frequency range (8x multiplier) |
PWM period: t_PWM = mantissa * 2^exponent * (1/f_sys) If low_freq_range: t_PWM = mantissa * 8 * 2^exponent * (1/f_sys)
|
noexcept |
Disable all channels.
|
noexcept |
Enable all channels.
|
noexcept |
Enable or disable a channel.
| channel | Channel to control |
| enabled | true to enable, false to disable |
| DriverError::WrongMode | Must be in Mission Mode |
|
noexcept |
Enable or disable multiple channels.
| channel_mask | Bitmask where bit N enables channel N |
|
noexcept |
Enter Config Mode (allows configuration changes)
Transitions from Mission Mode to Config Mode. All channel outputs are automatically disabled when entering Config Mode.
|
noexcept |
Enter Mission Mode (enables channel control)
Transitions from Config Mode to Mission Mode. Channel outputs can only be enabled in Mission Mode. Most configuration registers can only be written in Config Mode.
| DriverError::NotInitialized | Driver not initialized |
|
noexcept |
Get average current for a channel.
| channel | Channel to query |
| parallel_mode | true if in parallel mode |
|
noexcept |
Get channel diagnostic information.
| channel | Channel to query |
|
noexcept |
Read unique chip ID.
|
noexcept |
Get current setpoint for channel.
| channel | Channel to query |
| parallel_mode | true if channel is in parallel mode |
|
noexcept |
Get global device status.
|
noexcept |
Get PWM duty cycle for a channel.
| channel | Channel to query |
|
noexcept |
Read IC version and ID.
|
noexcept |
Get VBAT voltage.
|
noexcept |
Get VIO voltage
|
noexcept |
Check if any fault exists.
|
noexcept |
Initialize the driver and hardware.
Performs complete initialization sequence:
After init(), device is in Config Mode. Call enter_mission_mode() to enable outputs.
| DriverError::HardwareError | HAL initialization failed |
| DriverError::DeviceNotResponding | No SPI response |
| DriverError::WrongDeviceID | Device ID mismatch |
|
privatenoexcept |
Check if channel is currently in parallel mode.
| channel | Channel to check |
|
inlinenoexcept |
Check if driver is initialized.
|
inlinenoexcept |
Check if in mission mode.
|
inlineconstexprprivatenoexcept |
Validate channel number.
|
noexcept |
Modify register bits.
| address | Register address |
| mask | Bit mask for modification |
| value | New bit values |
|
noexcept |
Read 16-bit register.
| address | Register address (10-bit) |
| verify_crc | If true, verify CRC in response |
|
noexcept |
Reload SPI watchdog counter.
Must be called periodically when SPI watchdog is enabled to prevent watchdog timeout.
| reload_value | Reload value (watchdog period) |
|
noexcept |
Set channel operation mode.
| channel | Channel to configure |
| mode | Operation mode (ICC, Direct Drive, etc.) |
| DriverError::WrongMode | Must be in Config Mode |
|
noexcept |
Enable/disable CRC checking.
| enabled | true to enable CRC |
|
noexcept |
Set current setpoint for channel.
| channel | Channel to configure |
| current_ma | Desired current in milliamperes (0-2000 single, 0-4000 parallel) |
| parallel_mode | Set true if channel is in parallel mode |
|
noexcept |
Configure channel for parallel operation.
| pair | Parallel pair to configure (0/3, 1/2, or 4/5) |
| enabled | true to enable parallel operation |
| DriverError::WrongMode | Must be in Config Mode |
|
noexcept |
Configure VBAT under/overvoltage thresholds.
| uv_threshold | UV threshold (V_BAT_UV = value * 0.16208V) |
| ov_threshold | OV threshold (V_BAT_OV = value * 0.16208V) |
|
noexcept |
Software reset of the device.
Resets all registers to default values. init() must be called again.
|
privatenoexcept |
Transfer SPI frame with CRC calculation and verification.
|
noexcept |
Verify device ID matches expected value.
|
noexcept |
Write 16-bit register.
| address | Register address (10-bit) |
| value | Value to write (16-bit) |
| verify_crc | If true, verify CRC in response |
|
private |
Cached channel enable state.
|
private |
Cached current setpoints.
|
private |
Hardware abstraction layer.
|
private |
Initialization status.
|
private |
Mission mode flag (vs config mode)