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

Main TLE92466ED driver class. More...

#include <TLE92466ED.hpp>

Collaboration diagram for TLE92466ED::Driver:
[legend]

Public Member Functions

 Driver (HAL &hal) noexcept
 Construct driver with HAL interface.
 
 ~Driver () noexcept
 Destructor - ensures clean shutdown.
 
 Driver (const Driver &)=delete
 
Driveroperator= (const Driver &)=delete
 
 Driver (Driver &&) noexcept=delete
 
Driveroperator= (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< DeviceStatusget_device_status () noexcept
 Get global device status.
 
DriverResult< ChannelDiagnosticsget_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< SPIFrametransfer_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

HALhal_
 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.
 

Detailed Description

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.

Initialization Sequence:
  1. Construct driver with HAL reference
  2. Call init() to initialize hardware and verify device
  3. Call enter_mission_mode() to enable channel control
  4. Configure channels with set_channel_mode() and configure_channel()
  5. Set current with set_current_setpoint()
  6. Enable outputs with enable_channel()
  7. Monitor with get diagnostics functions

Constructor & Destructor Documentation

◆ Driver() [1/3]

TLE92466ED::Driver::Driver ( HAL & hal)
inlineexplicitnoexcept

Construct driver with HAL interface.

Parameters
halReference to hardware abstraction layer
Precondition
HAL must remain valid for the lifetime of the Driver
Postcondition
Driver is constructed but not initialized

◆ ~Driver()

TLE92466ED::Driver::~Driver ( )
inlinenoexcept

Destructor - ensures clean shutdown.

◆ Driver() [2/3]

TLE92466ED::Driver::Driver ( const Driver & )
delete

◆ Driver() [3/3]

TLE92466ED::Driver::Driver ( Driver && )
deletenoexcept

Member Function Documentation

◆ apply_default_config()

DriverResult< void > TLE92466ED::Driver::apply_default_config ( )
privatenoexcept

Apply default configuration after initialization.

◆ check_config_mode()

DriverResult< void > TLE92466ED::Driver::check_config_mode ( ) const
inlineprivatenoexcept

Check if in config mode.

◆ check_initialized()

DriverResult< void > TLE92466ED::Driver::check_initialized ( ) const
inlineprivatenoexcept

Check if driver is initialized.

◆ check_mission_mode()

DriverResult< void > TLE92466ED::Driver::check_mission_mode ( ) const
inlineprivatenoexcept

Check if in mission mode.

◆ check_spi_status()

DriverResult< void > TLE92466ED::Driver::check_spi_status ( const SPIFrame & rx_frame)
privatenoexcept

Parse SPI status from reply frame.

◆ clear_faults()

DriverResult< void > TLE92466ED::Driver::clear_faults ( )
noexcept

Clear all fault flags.

Clears latched fault conditions. Does not clear active faults.

Returns
DriverResult<void> Success or error

◆ configure_channel()

DriverResult< void > TLE92466ED::Driver::configure_channel ( Channel channel,
const ChannelConfig & config )
noexcept

Configure channel slew rate and diagnostics.

Parameters
channelChannel to configure
configChannel configuration
Returns
DriverResult<void> Success or error

◆ configure_dither()

DriverResult< void > TLE92466ED::Driver::configure_dither ( Channel channel,
uint16_t step_size,
uint8_t num_steps,
uint8_t flat_steps )
noexcept

Configure dither parameters.

Parameters
channelChannel to configure
step_sizeDither amplitude (I_dither = steps * step_size * 2A / 32767)
num_stepsNumber of steps in quarter period
flat_stepsNumber of flat clock cycles at top/bottom
Returns
DriverResult<void> Success or error

◆ configure_global()

DriverResult< void > TLE92466ED::Driver::configure_global ( const GlobalConfig & config)
noexcept

Configure global device settings.

Parameters
configGlobal configuration structure
Returns
DriverResult<void> Success or error
Return values
DriverError::NotInitializedDriver not initialized
DriverError::WrongModeMust be in Config Mode

◆ configure_pwm_period()

DriverResult< void > TLE92466ED::Driver::configure_pwm_period ( Channel channel,
uint8_t period_mantissa,
uint8_t period_exponent,
bool low_freq_range = false )
noexcept

Configure PWM parameters for ICC.

Parameters
channelChannel to configure
period_mantissaPWM period mantissa
period_exponentPWM period exponent (0-7)
low_freq_rangeEnable low frequency range (8x multiplier)
Returns
DriverResult<void> Success or error

PWM period: t_PWM = mantissa * 2^exponent * (1/f_sys) If low_freq_range: t_PWM = mantissa * 8 * 2^exponent * (1/f_sys)

◆ disable_all_channels()

DriverResult< void > TLE92466ED::Driver::disable_all_channels ( )
noexcept

Disable all channels.

◆ enable_all_channels()

DriverResult< void > TLE92466ED::Driver::enable_all_channels ( )
noexcept

Enable all channels.

◆ enable_channel()

DriverResult< void > TLE92466ED::Driver::enable_channel ( Channel channel,
bool enabled )
noexcept

Enable or disable a channel.

Parameters
channelChannel to control
enabledtrue to enable, false to disable
Returns
DriverResult<void> Success or error
Return values
DriverError::WrongModeMust be in Mission Mode

◆ enable_channels()

DriverResult< void > TLE92466ED::Driver::enable_channels ( uint8_t channel_mask)
noexcept

Enable or disable multiple channels.

Parameters
channel_maskBitmask where bit N enables channel N
Returns
DriverResult<void> Success or error

◆ enter_config_mode()

DriverResult< void > TLE92466ED::Driver::enter_config_mode ( )
noexcept

Enter Config Mode (allows configuration changes)

Transitions from Mission Mode to Config Mode. All channel outputs are automatically disabled when entering Config Mode.

Returns
DriverResult<void> Success or error

◆ enter_mission_mode()

DriverResult< void > TLE92466ED::Driver::enter_mission_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.

Returns
DriverResult<void> Success or error
Return values
DriverError::NotInitializedDriver not initialized

◆ get_average_current()

DriverResult< uint16_t > TLE92466ED::Driver::get_average_current ( Channel channel,
bool parallel_mode = false )
noexcept

Get average current for a channel.

Parameters
channelChannel to query
parallel_modetrue if in parallel mode
Returns
DriverResult<uint16_t> Average current in mA or error

◆ get_channel_diagnostics()

DriverResult< ChannelDiagnostics > TLE92466ED::Driver::get_channel_diagnostics ( Channel channel)
noexcept

Get channel diagnostic information.

Parameters
channelChannel to query
Returns
DriverResult<ChannelDiagnostics> Diagnostics or error

◆ get_chip_id()

DriverResult< std::array< uint16_t, 3 > > TLE92466ED::Driver::get_chip_id ( )
noexcept

Read unique chip ID.

Returns
DriverResult<std::array<uint16_t, 3>> Three 16-bit ID registers

◆ get_current_setpoint()

DriverResult< uint16_t > TLE92466ED::Driver::get_current_setpoint ( Channel channel,
bool parallel_mode = false )
noexcept

Get current setpoint for channel.

Parameters
channelChannel to query
parallel_modetrue if channel is in parallel mode
Returns
DriverResult<uint16_t> Current in mA or error

◆ get_device_status()

DriverResult< DeviceStatus > TLE92466ED::Driver::get_device_status ( )
noexcept

Get global device status.

Returns
DriverResult<DeviceStatus> Device status or error

◆ get_duty_cycle()

DriverResult< uint16_t > TLE92466ED::Driver::get_duty_cycle ( Channel channel)
noexcept

Get PWM duty cycle for a channel.

Parameters
channelChannel to query
Returns
DriverResult<uint16_t> Duty cycle (raw 16-bit value)

◆ get_ic_version()

DriverResult< uint16_t > TLE92466ED::Driver::get_ic_version ( )
noexcept

Read IC version and ID.

Returns
DriverResult<uint16_t> ICVID register value

◆ get_vbat_voltage()

DriverResult< uint16_t > TLE92466ED::Driver::get_vbat_voltage ( )
noexcept

Get VBAT voltage.

Returns
DriverResult<uint16_t> VBAT in millivolts or error

◆ get_vio_voltage()

DriverResult< uint16_t > TLE92466ED::Driver::get_vio_voltage ( )
noexcept

Get VIO voltage

Returns
DriverResult<uint16_t> VIO in millivolts or error

◆ has_any_fault()

DriverResult< bool > TLE92466ED::Driver::has_any_fault ( )
noexcept

Check if any fault exists.

Returns
DriverResult<bool> true if any fault exists

◆ init()

DriverResult< void > TLE92466ED::Driver::init ( )
noexcept

Initialize the driver and hardware.

Performs complete initialization sequence:

  1. Initialize HAL (SPI peripheral)
  2. Verify device communication
  3. Read and verify device ID
  4. Apply default configuration (in Config Mode)
  5. Clear any power-on faults

After init(), device is in Config Mode. Call enter_mission_mode() to enable outputs.

Returns
DriverResult<void> Success or error code
Return values
DriverError::HardwareErrorHAL initialization failed
DriverError::DeviceNotRespondingNo SPI response
DriverError::WrongDeviceIDDevice ID mismatch

◆ is_channel_parallel()

DriverResult< bool > TLE92466ED::Driver::is_channel_parallel ( Channel channel)
privatenoexcept

Check if channel is currently in parallel mode.

Parameters
channelChannel to check
Returns
DriverResult<bool> true if channel is paralleled, false otherwise

◆ is_initialized()

bool TLE92466ED::Driver::is_initialized ( ) const
inlinenoexcept

Check if driver is initialized.

Returns
true if initialized and ready

◆ is_mission_mode()

bool TLE92466ED::Driver::is_mission_mode ( ) const
inlinenoexcept

Check if in mission mode.

Returns
true if in mission mode, false if in config mode

◆ is_valid_channel_internal()

constexpr bool TLE92466ED::Driver::is_valid_channel_internal ( Channel channel) const
inlineconstexprprivatenoexcept

Validate channel number.

◆ modify_register()

DriverResult< void > TLE92466ED::Driver::modify_register ( uint16_t address,
uint16_t mask,
uint16_t value )
noexcept

Modify register bits.

Parameters
addressRegister address
maskBit mask for modification
valueNew bit values
Returns
DriverResult<void> Success or error

◆ operator=() [1/2]

Driver & TLE92466ED::Driver::operator= ( const Driver & )
delete

◆ operator=() [2/2]

Driver & TLE92466ED::Driver::operator= ( Driver && )
deletenoexcept

◆ read_register()

DriverResult< uint16_t > TLE92466ED::Driver::read_register ( uint16_t address,
bool verify_crc = true )
noexcept

Read 16-bit register.

Parameters
addressRegister address (10-bit)
verify_crcIf true, verify CRC in response
Returns
DriverResult<uint16_t> Register value or error

◆ reload_spi_watchdog()

DriverResult< void > TLE92466ED::Driver::reload_spi_watchdog ( uint16_t reload_value)
noexcept

Reload SPI watchdog counter.

Must be called periodically when SPI watchdog is enabled to prevent watchdog timeout.

Parameters
reload_valueReload value (watchdog period)
Returns
DriverResult<void> Success or error

◆ set_channel_mode()

DriverResult< void > TLE92466ED::Driver::set_channel_mode ( Channel channel,
ChannelMode mode )
noexcept

Set channel operation mode.

Parameters
channelChannel to configure
modeOperation mode (ICC, Direct Drive, etc.)
Returns
DriverResult<void> Success or error
Return values
DriverError::WrongModeMust be in Config Mode

◆ set_crc_enabled()

DriverResult< void > TLE92466ED::Driver::set_crc_enabled ( bool enabled)
noexcept

Enable/disable CRC checking.

Parameters
enabledtrue to enable CRC
Returns
DriverResult<void> Success or error

◆ set_current_setpoint()

DriverResult< void > TLE92466ED::Driver::set_current_setpoint ( Channel channel,
uint16_t current_ma,
bool parallel_mode = false )
noexcept

Set current setpoint for channel.

Parameters
channelChannel to configure
current_maDesired current in milliamperes (0-2000 single, 0-4000 parallel)
parallel_modeSet true if channel is in parallel mode
Returns
DriverResult<void> Success or error
Note
Current is regulated by the Integrated Current Controller (ICC)
Resolution: 15-bit (0.061mA per LSB in single mode)
Current Limits (from datasheet):
  • Single channel: 1.5A typical continuous, 2.0A absolute maximum
  • Parallel channels: 2.7A typical continuous, 4.0A absolute maximum
Warning
Setting currents above typical continuous ratings may result in thermal limiting, reduced accuracy, or current regulation at the device's natural limit rather than the requested setpoint.

◆ set_parallel_operation()

DriverResult< void > TLE92466ED::Driver::set_parallel_operation ( ParallelPair pair,
bool enabled )
noexcept

Configure channel for parallel operation.

Parameters
pairParallel pair to configure (0/3, 1/2, or 4/5)
enabledtrue to enable parallel operation
Returns
DriverResult<void> Success or error
Return values
DriverError::WrongModeMust be in Config Mode

◆ set_vbat_thresholds()

DriverResult< void > TLE92466ED::Driver::set_vbat_thresholds ( uint8_t uv_threshold,
uint8_t ov_threshold )
noexcept

Configure VBAT under/overvoltage thresholds.

Parameters
uv_thresholdUV threshold (V_BAT_UV = value * 0.16208V)
ov_thresholdOV threshold (V_BAT_OV = value * 0.16208V)
Returns
DriverResult<void> Success or error

◆ software_reset()

DriverResult< void > TLE92466ED::Driver::software_reset ( )
noexcept

Software reset of the device.

Resets all registers to default values. init() must be called again.

Returns
DriverResult<void> Success or error

◆ transfer_frame()

DriverResult< SPIFrame > TLE92466ED::Driver::transfer_frame ( const SPIFrame & tx_frame,
bool verify_crc = true )
privatenoexcept

Transfer SPI frame with CRC calculation and verification.

◆ verify_device()

DriverResult< bool > TLE92466ED::Driver::verify_device ( )
noexcept

Verify device ID matches expected value.

Returns
DriverResult<bool> true if ID matches

◆ write_register()

DriverResult< void > TLE92466ED::Driver::write_register ( uint16_t address,
uint16_t value,
bool verify_crc = true )
noexcept

Write 16-bit register.

Parameters
addressRegister address (10-bit)
valueValue to write (16-bit)
verify_crcIf true, verify CRC in response
Returns
DriverResult<void> Success or error

Member Data Documentation

◆ channel_enable_cache_

uint16_t TLE92466ED::Driver::channel_enable_cache_
private

Cached channel enable state.

◆ channel_setpoints_

std::array<uint16_t, 6> TLE92466ED::Driver::channel_setpoints_
private

Cached current setpoints.

◆ hal_

HAL& TLE92466ED::Driver::hal_
private

Hardware abstraction layer.

◆ initialized_

bool TLE92466ED::Driver::initialized_
private

Initialization status.

◆ mission_mode_

bool TLE92466ED::Driver::mission_mode_
private

Mission mode flag (vs config mode)


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