|
HardFOC Core
API reference
|
Unified handler for TLE92466ED six-channel solenoid driver. More...
#include <Tle92466edHandler.h>
Classes | |
| struct | is_driver_result |
| Type trait to detect tle92466ed::DriverResult<T> types. More... | |
| struct | is_driver_result< tle92466ed::DriverResult< T > > |
Public Types | |
| using | DriverType = tle92466ed::Driver< HalSpiTle92466edComm > |
Driver type alias (tle92466ed::Driver bound to HalSpiTle92466edComm). | |
Public Member Functions | |
| Tle92466edHandler (BaseSpi &spi, BaseGpio &resn, BaseGpio &en, BaseGpio *faultn=nullptr) noexcept | |
| Construct TLE92466ED handler. | |
| ~Tle92466edHandler () noexcept | |
| Best-effort Deinitialize when the handler was initialized. | |
| Tle92466edHandler (const Tle92466edHandler &)=delete | |
| Tle92466edHandler & | operator= (const Tle92466edHandler &)=delete |
| Tle92466edHandler (Tle92466edHandler &&)=delete | |
| Tle92466edHandler & | operator= (Tle92466edHandler &&)=delete |
| tle92466ed::DriverResult< void > | Initialize (bool perform_hardware_reset=true) noexcept |
| Initialize driver (hardware reset + SPI init + config mode). | |
| bool | EnsureInitialized () noexcept |
| Lazy-init entrypoint: initialize on first use if needed. | |
| tle92466ed::DriverResult< void > | Initialize (const tle92466ed::GlobalConfig &config) noexcept |
Initialize, then apply config before mission mode. | |
| tle92466ed::DriverResult< void > | Deinitialize () noexcept |
| Disable all channels and tear down driver_. | |
| bool | IsInitialized () const noexcept |
true after a successful Initialize or lazy EnsureInitialized. | |
| tle92466ed::DriverResult< void > | ConfigureChannel (uint8_t channel, const tle92466ed::ChannelConfig &config) noexcept |
| Configure a channel (PWM, dither, current limit, …). | |
| tle92466ed::DriverResult< void > | EnableChannel (uint8_t channel) noexcept |
| Enable a channel in CH_CTRL (requires EnableOutputStage for load current). | |
| tle92466ed::DriverResult< void > | DisableChannel (uint8_t channel) noexcept |
| Disable a channel in CH_CTRL. | |
| tle92466ed::DriverResult< void > | EnableAllChannels () noexcept |
| Set CH_CTRL enable for every channel. | |
| tle92466ed::DriverResult< void > | DisableAllChannels () noexcept |
| Clear CH_CTRL enable for every channel. | |
| tle92466ed::DriverResult< void > | SetChannelCurrent (uint8_t channel, uint16_t current_ma) noexcept |
| Set channel current setpoint. | |
| tle92466ed::DriverResult< void > | SetChannelCurrentUa (uint8_t channel, uint32_t current_ua) noexcept |
| Set channel ICC setpoint in microamperes (15-bit TARGET resolution, ~61 µA LSB). | |
| tle92466ed::DriverResult< uint16_t > | GetChannelCurrentSetpoint (uint8_t channel, bool parallel_mode=false) noexcept |
| Read back programmed current setpoint for SW-HAL-01 verification. | |
| tle92466ed::DriverResult< void > | ConfigurePwmRaw (uint8_t channel, uint8_t mantissa, uint8_t exponent, bool low_freq_range=false) noexcept |
| Configure raw TP_MANT / TP_EXP PWM period fields. | |
| tle92466ed::DriverResult< void > | EnterMissionMode () noexcept |
| Enter mission mode after configuration (required before driving loads). | |
| tle92466ed::DriverResult< void > | EnterConfigMode () noexcept |
| Enter config mode so register writes are accepted. | |
| bool | IsMissionMode () noexcept |
true when the device is in mission (non-config) mode. | |
| tle92466ed::DriverResult< void > | EnableOutputStage () noexcept |
| Drive the chip's hardware EN pin HIGH so the output stage can deliver current to the load. | |
| tle92466ed::DriverResult< void > | DisableOutputStage () noexcept |
| Drive the chip's EN pin LOW to gate off the output stage. SPI access remains functional; only the low-side driver outputs are disabled. Useful as an emergency stop. | |
| tle92466ed::DriverResult< void > | EnableFeedbackUpdates () noexcept |
| Clear the FB_FRZ register so the chip updates FB_DC / FB_I_AVG / FB_VBAT on every channel. | |
| tle92466ed::DriverResult< void > | GetStatus (tle92466ed::DeviceStatus &status) noexcept |
| Read global device status (mode, rail voltages, OT flags, …). | |
| tle92466ed::DriverResult< void > | GetChannelDiagnostics (uint8_t channel, tle92466ed::ChannelDiagnostics &diag) noexcept |
| Read per-channel diagnostics (faults, FB_I_AVG, duty cycle, …). | |
| tle92466ed::DriverResult< void > | GetFaultReport (tle92466ed::FaultReport &report) noexcept |
| Aggregate fault snapshot across device and all channels. | |
| tle92466ed::DriverResult< void > | ClearFaults () noexcept |
| Clear latched fault registers after the fault condition is removed. | |
| bool | HasFault () noexcept |
| Check if any fault is present. | |
| tle92466ed::DriverResult< void > | KickWatchdog (uint16_t reload_value=1000) noexcept |
| Reload the SPI watchdog (must be kicked periodically in mission mode). | |
| uint32_t | GetChipId () noexcept |
| Read combined chip ID words for identity checks. | |
| uint32_t | GetIcVersion () noexcept |
| Read IC version register (ICVID). | |
| uint32_t | LastSpiRxWord () const noexcept |
| Last SPI RX word from HalSpiTle92466edComm (init / WrongDeviceID diag). | |
| uint32_t | LastSpiRxWordFirst () const noexcept |
| RX word from the first frame of the last pipelined SPI chain. | |
| bool | RawSpiChain (std::span< const uint32_t > tx, std::span< uint32_t > rx, uint32_t gap_us=0U) noexcept |
Clock tx out as one bus-ownership chain and capture every reply. | |
| template<typename Fn > | |
| auto | WithLock (Fn &&fn) noexcept |
Run fn (no arguments) while mutex_ is held. | |
| template<typename Fn > | |
| auto | WithDriver (Fn &&fn) noexcept |
Run fn against the raw driver with mutex_ held. | |
| DriverType * | GetDriver () noexcept |
| Get the underlying driver for advanced operations. | |
| const DriverType * | GetDriver () const noexcept |
| void | DumpDiagnostics () noexcept |
| Log device status, per-channel diagnostics, and chip ID to Logger. | |
Static Public Attributes | |
| static constexpr uint8_t | kNumChannels = 6 |
| Number of solenoid channels (0–5); only CH5 is populated on this board. | |
Private Member Functions | |
| tle92466ed::DriverResult< void > | InitializeLocked (bool perform_hardware_reset) noexcept |
| Initialize while mutex_ is already held. | |
| bool | EnsureInitializedLocked () noexcept |
| template<typename Fn > | |
| auto | withDriver (Fn &&fn) noexcept |
| Execute a lambda with a locked, initialized driver. | |
Private Attributes | |
| bool | initialized_ {false} |
| RtosMutex | mutex_ |
| std::unique_ptr< HalSpiTle92466edComm > | comm_ |
| std::unique_ptr< DriverType > | driver_ |
Unified handler for TLE92466ED six-channel solenoid driver.
Provides thread-safe access to all TLE92466ED driver features:
| using Tle92466edHandler::DriverType = tle92466ed::Driver<HalSpiTle92466edComm> |
Driver type alias (tle92466ed::Driver bound to HalSpiTle92466edComm).
|
noexcept |
Construct TLE92466ED handler.
| spi | Reference to pre-configured BaseSpi. |
| resn | BaseGpio for RESN pin (active LOW reset). |
| en | BaseGpio for EN pin (active HIGH enable). |
| faultn | Optional BaseGpio for FAULTN (active LOW fault indicator). |
|
noexcept |
Best-effort Deinitialize when the handler was initialized.
|
delete |
|
delete |
|
noexcept |
Clear latched fault registers after the fault condition is removed.
|
noexcept |
Configure a channel (PWM, dither, current limit, …).
| channel | Channel index 0–5 (kNumChannels). |
| config | Per-channel register image. |
| InvalidChannel | when channel >= kNumChannels. |
|
noexcept |
Configure raw TP_MANT / TP_EXP PWM period fields.
| channel | Channel index 0–5. |
| mantissa | PWM period mantissa (datasheet TP_MANT). |
| exponent | PWM period exponent (datasheet TP_EXP). |
| low_freq_range | Select low-frequency PWM range when true. |
|
noexcept |
|
noexcept |
Clear CH_CTRL enable for every channel.
|
noexcept |
Disable a channel in CH_CTRL.
| channel | Channel index 0–5. |
|
noexcept |
Drive the chip's EN pin LOW to gate off the output stage. SPI access remains functional; only the low-side driver outputs are disabled. Useful as an emergency stop.
|
noexcept |
|
noexcept |
Set CH_CTRL enable for every channel.
|
noexcept |
Enable a channel in CH_CTRL (requires EnableOutputStage for load current).
| channel | Channel index 0–5. |
|
noexcept |
Clear the FB_FRZ register so the chip updates FB_DC / FB_I_AVG / FB_VBAT on every channel.
Per the TLE92466ED datasheet §4.10 and the FB_FRZ register description (offset 0x0007): "Setting the <CH> bit in FB_FRZ
to 0 enables the update of the feedback values; setting it to
1 freezes the values." The chip's POR default leaves all six channel bits set (frozen), which is why FB_DC / FB_I_AVG read back as 0 even when the chip is actively driving a coil. Writing 0x0000 unfreezes every channel. Averaged current feedback also requires non-zero DITHER_CLK_DIV. Safe to call multiple times; idempotent.
|
noexcept |
Drive the chip's hardware EN pin HIGH so the output stage can deliver current to the load.
The TLE92466ED's EN input gates the entire output stage. While EN is LOW (the state the driver puts it in during reset), no current is delivered regardless of the per-channel EnableChannel bits or SetChannelCurrent setpoints. This method just calls Driver::Enable() which writes GpioSignal::ACTIVE to the configured EN GPIO.
|
noexcept |
|
privatenoexcept |
|
noexcept |
Enter config mode so register writes are accepted.
|
noexcept |
Enter mission mode after configuration (required before driving loads).
|
noexcept |
Read back programmed current setpoint for SW-HAL-01 verification.
| channel | Channel index 0–5. |
| parallel_mode | When true, read parallel-setpoint register path. |
|
noexcept |
Read per-channel diagnostics (faults, FB_I_AVG, duty cycle, …).
| channel | Channel index 0–5. | |
| [out] | diag | Populated on success. |
|
noexcept |
Read combined chip ID words for identity checks.
0 when uninitialized / SPI failure.
|
noexcept |
|
noexcept |
Get the underlying driver for advanced operations.
|
noexcept |
Aggregate fault snapshot across device and all channels.
| [out] | report | Populated on success. |
|
noexcept |
Read IC version register (ICVID).
0 when uninitialized / SPI failure.
|
noexcept |
Read global device status (mode, rail voltages, OT flags, …).
| [out] | status | Populated on success. |
|
noexcept |
Check if any fault is present.
false when the driver is unavailable or the query fails.
|
noexcept |
Initialize driver (hardware reset + SPI init + config mode).
| perform_hardware_reset | Pulse RESN on first bring-up; false keeps RESN released for SPI-only retries (see Driver::Init). |
|
noexcept |
Initialize, then apply config before mission mode.
tle92466ed::GlobalConfig{} is now the configuration Driver::Init() itself writes: CRC check and SPI watchdog off, VBAT UV / OV at 7 V / 40 V. Set crc_enabled / spi_watchdog_enabled explicitly to turn them on; a default-constructed config no longer arms the watchdog.
| config | Global device configuration (watchdog, dither clock, …). |
Driver::Init().
|
privatenoexcept |
Initialize while mutex_ is already held.
|
inlinenoexcept |
true after a successful Initialize or lazy EnsureInitialized.
|
noexcept |
true when the device is in mission (non-config) mode.
|
noexcept |
Reload the SPI watchdog (must be kicked periodically in mission mode).
| reload_value | Watchdog reload counter written to the device (default 1000). |
|
inlinenoexcept |
Last SPI RX word from HalSpiTle92466edComm (init / WrongDeviceID diag).
|
inlinenoexcept |
RX word from the first frame of the last pipelined SPI chain.
|
delete |
|
delete |
|
inlinenoexcept |
Clock tx out as one bus-ownership chain and capture every reply.
| tx | Frames to send (CRC must already be set by the caller). |
| rx | Receives one MISO word per frame; same size as tx. |
The driver's own read path decodes only the slot it expects the reply in, so a register that reads back zero cannot be told apart from a reply that arrived one slot early or late. This hands back the untouched words for exactly that comparison.
tle reg raw). Arbitrary frames can change device state — not for production paths.
|
noexcept |
Set channel current setpoint.
| channel | Channel index 0–5. |
| current_ma | Target coil current in milliamps (e.g. 115 mA at full flow on CH5). |
|
noexcept |
Set channel ICC setpoint in microamperes (15-bit TARGET resolution, ~61 µA LSB).
| channel | Channel index. |
| current_ua | Target current in µA. |
|
inlinenoexcept |
Run fn against the raw driver with mutex_ held.
This is the only safe way to reach advanced driver APIs (ConfigureDither, GetAverageCurrent, ReadPinStatus, rail reads, …) from production code. The TLE92466ED answers a read on the next CS window, so two threads interleaving driver calls consume each other's pipeline slots — which surfaced as sticky-zero register readback and impossible FB_I_AVG ratios. Holding the handler mutex for the whole sequence keeps a multi-register operation coherent across host control (~500 Hz) and diagnostic threads; HalSpiTle92466edComm::TransferMulti additionally keeps the SPI2 bus lock across the frames of a single pipelined access.
| Fn | Callable taking DriverType&. |
fn's result, or a NotInitialized error / value-initialized result when the driver is unavailable. When fn returns void, this returns bool (true when fn actually ran).
|
inlineprivatenoexcept |
Execute a lambda with a locked, initialized driver.
Acquires the mutex, ensures initialization, and invokes fn(*driver_). Returns a default-constructed R on failure, or for DriverResult types, returns an error indicating the driver is not initialized.
|
inlinenoexcept |
Run fn (no arguments) while mutex_ is held.
WithDriver keeps a single driver call coherent, but a snapshot built from several handler calls (probe: PIN_STAT + FB_STAT + FB_FRZ + CH_CTRL + …) can still interleave with other host SPI users between those calls, so the fields describe different instants. mutex_ is recursive, so fn may freely call WithDriver and any other handler method; the outer hold makes the whole composition atomic with respect to every other TLE user.
fn runs with the TLE pipeline blocked for other threads — keep sleeps inside to a few milliseconds.
|
private |
|
private |
|
private |
|
staticconstexpr |
Number of solenoid channels (0–5); only CH5 is populated on this board.
|
mutableprivate |