TLE92466ED Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tle92466ed::TLE92466ED< Port > Class Template Reference

Driver for one TLE92466ED on a platform port. More...

#include <tle92466ed.hpp>

Public Member Functions

 TLE92466ED (Port &port, const Config &config={}) noexcept
 Bind the driver to a port and store the configuration. No I/O, cannot fail.
 
 TLE92466ED (const TLE92466ED &)=delete
 One driver object per chip.
 
TLE92466ED & operator= (const TLE92466ED &)=delete
 One driver object per chip.
 
Lifecycle
Result< void > EnsureInitialized () noexcept
 Start the chip, once: the only way to initialise the driver.
 
bool IsInitialized () const noexcept
 
Result< void > Deinitialize () noexcept
 Switch every channel off: Config Mode (CH_CTRL with OP_MODE and every EN_CH 0), then EN low. The driver is uninitialised afterwards even if a step failed. On an uninitialised driver (never started, or left by a reset or a critical fault) only EN is driven low, with no SPI.
 
Result< void > HardwareReset () noexcept
 Pulse RESN and start again as EnsureInitialized() does, with the stored configuration.
 
Configuration
Result< void > ApplyConfig (const Config &config) noexcept
 Change the whole configuration. Before the start it is only stored, with no I/O; on a started driver it is written as at start-up (no reset), which needs Config Mode.
 
const Config & GetConfig () const &noexcept
 
void GetConfig () const &&=delete
 Not on a temporary driver: the reference would dangle (KB-CPP20-044).
 
Result< void > ConfigureChannel (Channel channel, const ChannelConfig &config, Verify verify=Verify::None) noexcept
 Write one channel's registers (MODE is writable in Config Mode only, section 4.4.1). Before the start only stored. SETPOINT is written with TARGET 0.
 
Result< void > SetParallel (ParallelPair pair, bool enabled) noexcept
 Join or split a pair (CH_CTRL.CH_PAR, Config Mode only, section 4.5.2). Joining sets the master's SETPOINT to 0 first, since one TARGET count is then twice the current; set it again with SetCurrent(), checked against the pair's limit. Splitting rewrites the slave's registers, which the chip requires.
 
Operation state (section 4.3)
Result< void > EnterMissionMode () noexcept
 Enter Mission Mode, as Figure 4 allows it. First the entry conditions: FB_STAT (INIT_DONE = 1; no SPI watchdog, clock, central temperature, external or internal supply fault), the DIAG_ERR_CHGR and DIAG_WARN_CHGR groups FB_STAT flags (no channel OTE or OTW), GLOBAL_DIAG2 (no REG_ECC_ERR); any of them set is MissionBlocked with nothing written. Then EN high, OP_MODE with every channel off, and CH_CTRL read back, always: the copy is what the chip did, and an OP_MODE the chip refused is MissionBlocked. VPRE_OV blocks entry too, a fail-safe choice: the datasheet does not list it in Figure 4. 8 frames, 2 more per flagged group.
 
Result< void > EnterConfigMode () noexcept
 Enter Config Mode: OP_MODE 0, which turns every channel off (section 4.3.1), then EN low, whatever the SPI result; the first error is returned. Two frames.
 
bool IsMissionMode () const noexcept
 
Result< uint16_t > ReadChannelControl () noexcept
 Read CH_CTRL: the operation state and the enabled channels as the chip has them. A supply, clock or watchdog fault ends Mission Mode and clears EN_CH (sections 4.1.2, 4.2.2, 5.2.2), a channel fault clears its EN_CH (4.9.2 to 4.9.6): the driver's copy follows this read. Every enable change does this read first. Two frames.
 
Channels
Result< void > SetEnabledChannels (uint8_t mask, Verify verify=Verify::None) noexcept
 Switch channels on and off together. CH_CTRL is read first, so the copy is the chip's (a channel a fault switched off stays off), then written whole with only the EN_CH bits the mask names changed; OP_MODE is kept as the chip has it, never set (handbook KB-CPP-121, -122).
 
Result< void > EnableChannel (Channel channel, Verify verify=Verify::None) noexcept
 Switch one channel on, leaving the others as they are. As SetEnabledChannels().
 
Result< void > DisableChannel (Channel channel, Verify verify=Verify::None) noexcept
 Switch one channel off, leaving the others as they are. Allowed in any state. When the CH_CTRL read fails, the write still goes out, from the copy with the channel cleared, and the read's error is returned: switching off never depends on a read.
 
uint8_t GetDroppedChannels () const noexcept
 
void ClearDroppedChannels () noexcept
 Empty the record of GetDroppedChannels(). No I/O.
 
uint8_t GetEnabledChannels () const noexcept
 
Result< uint32_t > SetCurrent (Channel channel, uint32_t microamps, Verify verify=Verify::None) noexcept
 Set a channel's average current setpoint (SETPOINT.TARGET, section 4.6.1).
 
uint32_t GetCurrentSetpoint (Channel channel) const noexcept
 
Result< void > SetDither (Channel channel, const DitherConfig &dither, Verify verify=Verify::None) noexcept
 Change a channel's dither at run time (section 4.7.2): DITHER_CLK_DIV (takes effect at once), DITHER_STEP, then DITHER_CTRL, whose write starts the update at the next dither period.
 
Result< void > StartOvercurrentCheck (Channel channel) noexcept
 Run the OFF-state overcurrent check once (section 4.9.6): set CH_CONFIG.OC_DIAG_EN and the channel's EN_CH; the chip switches the stage on for t_OCon and clears OC_DIAG_EN. Read the result with ReadFaults() after t_OCon. The channel must be off with setpoint 0, so the check does not start the current controller; afterwards it stays enabled with setpoint 0, which is the OFF-state diagnosis condition (4.9.1): DisableChannel() when that is not wanted.
 
Result< void > SetDrivePin (CtrlPin pin, bool high) noexcept
 Drive DRV0 or DRV1, the inputs of the direct-drive channels (section 4.8.1).
 
Watchdog (section 5.2.2)
Result< void > ReloadWatchdog () noexcept
 Reload the SPI watchdog: write Config::watchdog_reload to WD_RELOAD. Call it more often than the timeout while Config::spi_watchdog is set. Not verifiable: the counter runs. Two frames.
 
Diagnostics
Result< DeviceStatus > ReadStatus () noexcept
 Read FB_STAT, the one-register summary (section 5.3.2.21). Two frames.
 
Result< Faults > ReadFaults () noexcept
 Read the nine diagnosis registers (GLOBAL_DIAG0..2, DIAG_ERR_CHGR0..2, DIAG_WARN_CHGR0..2). Reading DIAG_WARN_CHGR clears OLSG_WARN_CHK_NOK on the chip (4.9.3); every flag read is also ORed into the latch (GetLatchedFaults()). 18 frames.
 
Result< void > ClearFaults () noexcept
 Clear the diagnosis flags on the chip: every diagnosis register is read and latched (GetLatchedFaults()), then exactly the flags read are cleared, so a flag raised since the last read is never lost (handbook KB-CPP-119). An rwh flag is cleared by a 1 where it read 1, an rw flag (POR_EVENT, RES_EVENT, VDD2V5_UV/OV) by a 0 (sections 4.1.2, 4.9.1, 5.3.1); OC and OTP_ECC_ERR get the two clears they need (4.9.6, 4.9.7); OTP_VIRGIN is never cleared. A register with nothing set is not written. With the reset watch armed, POR_EVENT or RES_EVENT read 1 is UnexpectedReset, nothing cleared. A flag set again at once means the cause is still there. Not verified. 18 frames, 2 more per register written (4 with OC or OTP_ECC_ERR).
 
Result< void > ClearChannelFaults (Channel channel) noexcept
 Clear one channel's flags and warnings: its DIAG_ERR_CHGR and DIAG_WARN_CHGR group read and latched (both channels), then 1 written to the flags of this channel that read 1 (twice for OC), 0 to everything else. A channel switched off by a fault stays off until its flags are cleared and EN_CH is set again (sections 4.9.2 to 4.9.6). 4 frames, 2 more per write.
 
const Faults & GetLatchedFaults () const &noexcept
 
void GetLatchedFaults () const &&=delete
 Not on a temporary driver.
 
void ClearLatchedFaults () noexcept
 Empty the latch of GetLatchedFaults(). No I/O.
 
const Faults & GetStartupFaults () const &noexcept
 
void GetStartupFaults () const &&=delete
 Not on a temporary driver.
 
Result< bool > ReadFaultPin () noexcept
 Read the FAULTN pin through the port's GpioRead().
 
Result< PinStatus > ReadPinStatus () noexcept
 Read PIN_STAT (section 5.3.2.20). Two frames.
 
Result< SupplyReadings > ReadSupply () noexcept
 Read FB_VOLTAGE1 and FB_VOLTAGE2: VIO, VDD, VBAT and the central temperature (sections 4.1.2, 4.11.1). Four frames.
 
Result< ChannelFeedback > ReadChannelFeedback (Channel channel) noexcept
 Read one measurement period of a channel's feedback, as section 4.10.5 recommends: read FB_UPD; when the channel has new values, freeze it (FB_FRZ), read FB_DC, FB_VBAT, FB_I_AVG, FB_IMIN_IMAX and FB_PERIOD_MIN_MAX, and release the freeze, which clears its FB_UPD bit. The conversions use f_SYS of the configuration (handbook KB-CPP-128). 16 frames; 2 when there is nothing new.
 
Result< BistResult > RunBist () noexcept
 Run the safety flip-flop self-test (section 4.9.8, Config Mode only): start it, poll SMU_SLF_TST_DONE every kPollIntervalUs for at most kBistTimeoutUs, read the result, clear SFF_BIST (a write of 0), read and latch GLOBAL_DIAG2 and clear only the REG_ECC_ERR the test sets on purpose.
 
Result< ChipId > ReadChipId () noexcept
 Read CHIPID0..2, the unique chip identification. Six frames.
 
uint8_t GetIcVersion () const noexcept
 
bool IsResetWatchArmed () const noexcept
 
Raw access (handbook KB-CPP-129)
Result< uint32_t > ReadRegister (uint16_t address) noexcept
 Read one register once: two frames, no retry, no decoding. Reading DIAG_WARN_CHGR clears OLSG_WARN_CHK_NOK on the chip; a diagnosis register read here feeds the latch too.
 
uint32_t GetLastReply () const noexcept
 
uint8_t GetLastCriticalFault () const noexcept
 
BusDiagnostics GetBusDiagnostics () const noexcept
 

Detailed Description

template<SpiPort Port>
class tle92466ed::TLE92466ED< Port >

Driver for one TLE92466ED on a platform port.

Lifecycle: construct with the configuration (no I/O), then EnsureInitialized(), the one way to start (reset, readiness, identity, start-up faults, every register), which leaves the chip in Config Mode; EnterMissionMode() lets the channels switch. Every call that touches the chip returns Error::NotInitialized until EnsureInitialized() has succeeded; no call starts the chip as a side effect.

Optional port hooks, found at compile time:

Hook Used for Without it
void DelayUs(uint32_t us) noexcept t_POR, t_RESN, the INIT_DONE and self-test polls Compile error: the waits are required
bool GpioSet(CtrlPin, GpioSignal) noexcept RESN pulse at start-up, EN with the operation state, DRV0/DRV1 Start-up waits t_POR and rewrites every register; HardwareReset() and SetDrivePin() return Unsupported
bool GpioRead(CtrlPin, GpioSignal&) noexcept ReadFaultPin() ReadFaultPin() returns Unsupported
void Log(LogLevel, const char* message) noexcept One line per lifecycle event or start-up failure Nothing is logged

A hook declared with the wrong signature (for example void GpioSet(...)) is a compile error.

Template Parameters
PortYour class derived from SpiInterface<Port>.

Constructor & Destructor Documentation

◆ TLE92466ED()

template<SpiPort Port>
tle92466ed::TLE92466ED< Port >::TLE92466ED ( Port &  port,
const Config &  config = {} 
)
inlineexplicitnoexcept

Bind the driver to a port and store the configuration. No I/O, cannot fail.

Parameters
portThe port; it must outlive the driver.
configWhat EnsureInitialized() will apply; checked there, before any I/O.

Member Function Documentation

◆ ApplyConfig()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::ApplyConfig ( const Config &  config)
noexcept

Change the whole configuration. Before the start it is only stored, with no I/O; on a started driver it is written as at start-up (no reset), which needs Config Mode.

Parameters
configChecked with Validate() before any I/O.
Returns
Ok, InvalidArgument, NotInitialized never, WrongState (Mission Mode), WriteMismatch, Bus or a reply error.

◆ ClearChannelFaults()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::ClearChannelFaults ( Channel  channel)
noexcept

Clear one channel's flags and warnings: its DIAG_ERR_CHGR and DIAG_WARN_CHGR group read and latched (both channels), then 1 written to the flags of this channel that read 1 (twice for OC), 0 to everything else. A channel switched off by a fault stays off until its flags are cleared and EN_CH is set again (sections 4.9.2 to 4.9.6). 4 frames, 2 more per write.

Parameters
channelThe channel.
Returns
Ok, NotInitialized, InvalidArgument, Bus or a reply error.

◆ ClearFaults()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::ClearFaults ( )
noexcept

Clear the diagnosis flags on the chip: every diagnosis register is read and latched (GetLatchedFaults()), then exactly the flags read are cleared, so a flag raised since the last read is never lost (handbook KB-CPP-119). An rwh flag is cleared by a 1 where it read 1, an rw flag (POR_EVENT, RES_EVENT, VDD2V5_UV/OV) by a 0 (sections 4.1.2, 4.9.1, 5.3.1); OC and OTP_ECC_ERR get the two clears they need (4.9.6, 4.9.7); OTP_VIRGIN is never cleared. A register with nothing set is not written. With the reset watch armed, POR_EVENT or RES_EVENT read 1 is UnexpectedReset, nothing cleared. A flag set again at once means the cause is still there. Not verified. 18 frames, 2 more per register written (4 with OC or OTP_ECC_ERR).

Returns
Ok, NotInitialized, UnexpectedReset, Bus or a reply error.

◆ ConfigureChannel()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::ConfigureChannel ( Channel  channel,
const ChannelConfig &  config,
Verify  verify = Verify::None 
)
noexcept

Write one channel's registers (MODE is writable in Config Mode only, section 4.4.1). Before the start only stored. SETPOINT is written with TARGET 0.

Parameters
channelThe channel; not the slave of an enabled pair.
configIts configuration; the whole Config with it must pass Validate().
verifyReadBack: read the 11 registers back and compare, 22 more frames.
Returns
Ok, InvalidArgument, WrongState (Mission Mode, or a slave), WriteMismatch, Bus or a reply error. 26 frames: the 11 registers and FAULT_MASK0..1.

◆ Deinitialize()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::Deinitialize ( )
noexcept

Switch every channel off: Config Mode (CH_CTRL with OP_MODE and every EN_CH 0), then EN low. The driver is uninitialised afterwards even if a step failed. On an uninitialised driver (never started, or left by a reset or a critical fault) only EN is driven low, with no SPI.

Returns
Ok, Bus or a reply error.

◆ DisableChannel()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::DisableChannel ( Channel  channel,
Verify  verify = Verify::None 
)
noexcept

Switch one channel off, leaving the others as they are. Allowed in any state. When the CH_CTRL read fails, the write still goes out, from the copy with the channel cleared, and the read's error is returned: switching off never depends on a read.

Parameters
channelThe channel.
verifyAs SetEnabledChannels().
Returns
As SetEnabledChannels().

◆ EnableChannel()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::EnableChannel ( Channel  channel,
Verify  verify = Verify::None 
)
noexcept

Switch one channel on, leaving the others as they are. As SetEnabledChannels().

Parameters
channelThe channel.
verifyAs SetEnabledChannels().
Returns
As SetEnabledChannels().

◆ EnsureInitialized()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::EnsureInitialized ( )
noexcept

Start the chip, once: the only way to initialise the driver.

In order: check the configuration; bring the port up; reset the chip (EN low, RESN low for kResetPulseUs, then t_RESN; without GpioSet() write CH_CTRL to 0 at once, so a chip an earlier run left in Mission Mode is switched off, then wait t_POR, section 4.1.3); poll FB_STAT until INIT_DONE = 1, at most Config::init_timeout_us (4.2.1); check ICVID (manufacturer 0xC1, version A11 or A13); write CH_CTRL to Config Mode with every channel off; read, keep (GetStartupFaults()) and clear the diagnosis flags it found, refusing an unprogrammed OTP (4.9.7); write CLK_DIV and wait for INIT_DONE again; write GLOBAL_CONFIG with the SPI watchdog off and read it back; write VBAT_TH, FAULT_MASK0..2, the pairs and every register of every channel that is not an enabled pair's slave; write WD_RELOAD, and last, with Config::spi_watchdog, GLOBAL_CONFIG with SPI_WD_EN, read back (5.2.2); then arm the reset watch if POR_EVENT and RES_EVENT read 0 (4.1.1). It ends in Config Mode. 181 frames on a clean chip with every channel written, plus the reset; later calls return Ok at once with no I/O. After a failure the driver stays uninitialised and the next call starts again from the beginning.

Returns
Ok, InvalidArgument (no I/O), Bus, Timeout, DeviceIdMismatch, DeviceFault (OTP_VIRGIN), WriteMismatch (GLOBAL_CONFIG), or a reply error (NoDevice, CriticalFault, Crc, ReplyMismatch, FrameRejected).

◆ EnterConfigMode()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::EnterConfigMode ( )
noexcept

Enter Config Mode: OP_MODE 0, which turns every channel off (section 4.3.1), then EN low, whatever the SPI result; the first error is returned. Two frames.

Returns
Ok, NotInitialized, Bus or a reply error.

◆ EnterMissionMode()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::EnterMissionMode ( )
noexcept

Enter Mission Mode, as Figure 4 allows it. First the entry conditions: FB_STAT (INIT_DONE = 1; no SPI watchdog, clock, central temperature, external or internal supply fault), the DIAG_ERR_CHGR and DIAG_WARN_CHGR groups FB_STAT flags (no channel OTE or OTW), GLOBAL_DIAG2 (no REG_ECC_ERR); any of them set is MissionBlocked with nothing written. Then EN high, OP_MODE with every channel off, and CH_CTRL read back, always: the copy is what the chip did, and an OP_MODE the chip refused is MissionBlocked. VPRE_OV blocks entry too, a fail-safe choice: the datasheet does not list it in Figure 4. 8 frames, 2 more per flagged group.

Returns
Ok, NotInitialized, MissionBlocked, Bus or a reply error.

◆ GetBusDiagnostics()

template<SpiPort Port>
BusDiagnostics tle92466ed::TLE92466ED< Port >::GetBusDiagnostics ( ) const
inlinenoexcept
Returns
The protocol counters: frames, retries, rejected replies, resyncs. No I/O.

◆ GetConfig()

template<SpiPort Port>
const Config & tle92466ed::TLE92466ED< Port >::GetConfig ( ) const &
inlinenoexcept
Returns
The configuration last applied or stored. No I/O.

◆ GetCurrentSetpoint()

template<SpiPort Port>
uint32_t tle92466ed::TLE92466ED< Port >::GetCurrentSetpoint ( Channel  channel) const
noexcept
Parameters
channelThe channel.
Returns
The setpoint last programmed, in microamps; 0 for an invalid channel. After a failed SetCurrent() the larger of the old and the requested setpoint, which the chip may hold, until a SetCurrent() succeeds. No I/O.

◆ GetDroppedChannels()

template<SpiPort Port>
uint8_t tle92466ed::TLE92466ED< Port >::GetDroppedChannels ( ) const
inlinenoexcept
Returns
The channels the chip switched off on its own since ClearDroppedChannels(), bit x for channel x: a channel the driver last asked on that a validated read of CH_CTRL (the read before every channel call, or Verify::ReadBack) found off: a refused enable or a latched fault (4.9.2 to 4.9.6), or a supply, clock or watchdog fault (4.1.2, 4.2.2, 5.2.2). Never taken from a write's reply. Each is also logged. Emptied by every start (EnsureInitialized(), HardwareReset()). No I/O.

◆ GetEnabledChannels()

template<SpiPort Port>
uint8_t tle92466ed::TLE92466ED< Port >::GetEnabledChannels ( ) const
inlinenoexcept
Returns
The EN_CH bits of the driver's copy of CH_CTRL. No I/O. After a write without Verify::ReadBack a bit is set only when both the value written and the write's reply have it, so the copy can under-report a channel that is on, never report one that is off.

◆ GetIcVersion()

template<SpiPort Port>
uint8_t tle92466ed::TLE92466ED< Port >::GetIcVersion ( ) const
inlinenoexcept
Returns
ICVID.VERSION read by the last start-up (0xFC A11, 0xFE A13); 0 before. No I/O.

◆ GetLastCriticalFault()

template<SpiPort Port>
uint8_t tle92466ed::TLE92466ED< Port >::GetLastCriticalFault ( ) const
inlinenoexcept
Returns
The flags byte of the last critical fault frame (section 5.2.3.5): bits 7..5 are 1 when the 1V5, 2V5 and bandgap are fine, bits 4..0 are clock faults. 0 before the first. No I/O.

◆ GetLastReply()

template<SpiPort Port>
uint32_t tle92466ed::TLE92466ED< Port >::GetLastReply ( ) const
inlinenoexcept
Returns
The last word clocked in as a reply, by any call; 0 before. No I/O.

◆ GetLatchedFaults()

template<SpiPort Port>
const Faults & tle92466ed::TLE92466ED< Port >::GetLatchedFaults ( ) const &
inlinenoexcept
Returns
Every flag any read of a diagnosis register saw since the last ClearLatchedFaults(), the reads inside ReadFaults() and ReadRegister() included (handbook KB-CPP-119). No I/O.

◆ GetStartupFaults()

template<SpiPort Port>
const Faults & tle92466ed::TLE92466ED< Port >::GetStartupFaults ( ) const &
inlinenoexcept
Returns
The diagnosis registers as the start-up found them, before it cleared them (POR_EVENT and RES_EVENT of the start-up's own reset included). No I/O.

◆ HardwareReset()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::HardwareReset ( )
noexcept

Pulse RESN and start again as EnsureInitialized() does, with the stored configuration.

Returns
Ok, NotInitialized, Unsupported (no GpioSet()), or the errors of EnsureInitialized().

◆ IsInitialized()

template<SpiPort Port>
bool tle92466ed::TLE92466ED< Port >::IsInitialized ( ) const
inlinenoexcept
Returns
true after a successful EnsureInitialized() and before Deinitialize(). No I/O.

◆ IsMissionMode()

template<SpiPort Port>
bool tle92466ed::TLE92466ED< Port >::IsMissionMode ( ) const
inlinenoexcept
Returns
true when the driver last set Mission Mode and saw nothing leave it. No I/O.

◆ IsResetWatchArmed()

template<SpiPort Port>
bool tle92466ed::TLE92466ED< Port >::IsResetWatchArmed ( ) const
inlinenoexcept
Returns
true while a reset of the chip is detected on every access: the start-up cleared POR_EVENT and RES_EVENT and saw them read 0. No I/O.

◆ ReadChannelControl()

template<SpiPort Port>
Result< uint16_t > tle92466ed::TLE92466ED< Port >::ReadChannelControl ( )
noexcept

Read CH_CTRL: the operation state and the enabled channels as the chip has them. A supply, clock or watchdog fault ends Mission Mode and clears EN_CH (sections 4.1.2, 4.2.2, 5.2.2), a channel fault clears its EN_CH (4.9.2 to 4.9.6): the driver's copy follows this read. Every enable change does this read first. Two frames.

Returns
CH_CTRL, or NotInitialized, Bus or a reply error.

◆ ReadChannelFeedback()

template<SpiPort Port>
Result< ChannelFeedback > tle92466ed::TLE92466ED< Port >::ReadChannelFeedback ( Channel  channel)
noexcept

Read one measurement period of a channel's feedback, as section 4.10.5 recommends: read FB_UPD; when the channel has new values, freeze it (FB_FRZ), read FB_DC, FB_VBAT, FB_I_AVG, FB_IMIN_IMAX and FB_PERIOD_MIN_MAX, and release the freeze, which clears its FB_UPD bit. The conversions use f_SYS of the configuration (handbook KB-CPP-128). 16 frames; 2 when there is nothing new.

Parameters
channelThe channel; not a slave (its feedback is meaningless, section 4.5.2).
Returns
The feedback, or NotInitialized, InvalidArgument, WrongState, NotReady (no new values, or TP_MANT = 0: no measurement period, as with a dither clock of 0), Bus or a reply error.

◆ ReadChipId()

template<SpiPort Port>
Result< ChipId > tle92466ed::TLE92466ED< Port >::ReadChipId ( )
noexcept

Read CHIPID0..2, the unique chip identification. Six frames.

Returns
The ID, or NotInitialized, Bus or a reply error.

◆ ReadFaultPin()

template<SpiPort Port>
Result< bool > tle92466ed::TLE92466ED< Port >::ReadFaultPin ( )
noexcept

Read the FAULTN pin through the port's GpioRead().

Returns
true while a fault pulls FAULTN low, or NotInitialized, Unsupported or Bus.

◆ ReadFaults()

template<SpiPort Port>
Result< Faults > tle92466ed::TLE92466ED< Port >::ReadFaults ( )
noexcept

Read the nine diagnosis registers (GLOBAL_DIAG0..2, DIAG_ERR_CHGR0..2, DIAG_WARN_CHGR0..2). Reading DIAG_WARN_CHGR clears OLSG_WARN_CHK_NOK on the chip (4.9.3); every flag read is also ORed into the latch (GetLatchedFaults()). 18 frames.

Returns
The registers, or NotInitialized, Bus or a reply error.

◆ ReadPinStatus()

template<SpiPort Port>
Result< PinStatus > tle92466ed::TLE92466ED< Port >::ReadPinStatus ( )
noexcept

Read PIN_STAT (section 5.3.2.20). Two frames.

Returns
The levels, or NotInitialized, Bus or a reply error.

◆ ReadRegister()

template<SpiPort Port>
Result< uint32_t > tle92466ed::TLE92466ED< Port >::ReadRegister ( uint16_t  address)
noexcept

Read one register once: two frames, no retry, no decoding. Reading DIAG_WARN_CHGR clears OLSG_WARN_CHK_NOK on the chip; a diagnosis register read here feeds the latch too.

Parameters
addressA register of Tables 19 and 24 (reg::IsRegister()).
Returns
The 16 or 22 data bits, or NotInitialized, InvalidArgument (no such register; nothing sent), Bus or a reply error.

◆ ReadStatus()

template<SpiPort Port>
Result< DeviceStatus > tle92466ed::TLE92466ED< Port >::ReadStatus ( )
noexcept

Read FB_STAT, the one-register summary (section 5.3.2.21). Two frames.

Returns
The status, or NotInitialized, Bus or a reply error.

◆ ReadSupply()

template<SpiPort Port>
Result< SupplyReadings > tle92466ed::TLE92466ED< Port >::ReadSupply ( )
noexcept

Read FB_VOLTAGE1 and FB_VOLTAGE2: VIO, VDD, VBAT and the central temperature (sections 4.1.2, 4.11.1). Four frames.

Returns
The readings, or NotInitialized, Bus or a reply error.

◆ ReloadWatchdog()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::ReloadWatchdog ( )
noexcept

Reload the SPI watchdog: write Config::watchdog_reload to WD_RELOAD. Call it more often than the timeout while Config::spi_watchdog is set. Not verifiable: the counter runs. Two frames.

Returns
Ok, NotInitialized, Bus or a reply error.

◆ RunBist()

template<SpiPort Port>
Result< BistResult > tle92466ed::TLE92466ED< Port >::RunBist ( )
noexcept

Run the safety flip-flop self-test (section 4.9.8, Config Mode only): start it, poll SMU_SLF_TST_DONE every kPollIntervalUs for at most kBistTimeoutUs, read the result, clear SFF_BIST (a write of 0), read and latch GLOBAL_DIAG2 and clear only the REG_ECC_ERR the test sets on purpose.

Returns
The result, or NotInitialized, WrongState, Timeout, Bus or a reply error.

◆ SetCurrent()

template<SpiPort Port>
Result< uint32_t > tle92466ed::TLE92466ED< Port >::SetCurrent ( Channel  channel,
uint32_t  microamps,
Verify  verify = Verify::None 
)
noexcept

Set a channel's average current setpoint (SETPOINT.TARGET, section 4.6.1).

The current is checked against the operating range, never clamped (handbook KB-CPP-126): up to 1.5 A, and with the configured dither amplitude up to 1.8 A; for the master of a pair, up to 2.7 A with dither (Table 14). With dither, a non-zero setpoint must exceed the amplitude (section 4.7.1). The value is rounded to the nearest TARGET count; the call returns what was programmed. Allowed in either state: the channel switches when it is enabled in Mission Mode.

Parameters
channelThe channel; not a slave.
microampsThe setpoint.
verifyReadBack: read SETPOINT back, two more frames.
Returns
The programmed current in microamps, or NotInitialized, InvalidArgument, WrongState (a slave), WriteMismatch, Bus or a reply error. Two frames.

◆ SetDither()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::SetDither ( Channel  channel,
const DitherConfig &  dither,
Verify  verify = Verify::None 
)
noexcept

Change a channel's dither at run time (section 4.7.2): DITHER_CLK_DIV (takes effect at once), DITHER_STEP, then DITHER_CTRL, whose write starts the update at the next dither period.

Parameters
channelThe channel; not a slave.
ditherThe settings; checked as Validate() does and against the current setpoint.
verifyReadBack: read the three registers back, six more frames.
Returns
Ok, NotInitialized, InvalidArgument, WrongState, WriteMismatch, Bus or a reply error. Six frames.

◆ SetDrivePin()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::SetDrivePin ( CtrlPin  pin,
bool  high 
)
noexcept

Drive DRV0 or DRV1, the inputs of the direct-drive channels (section 4.8.1).

Parameters
pinCtrlPin::Drv0 or CtrlPin::Drv1.
highThe level.
Returns
Ok, NotInitialized, InvalidArgument (another pin), Unsupported (no GpioSet()) or Bus.

◆ SetEnabledChannels()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::SetEnabledChannels ( uint8_t  mask,
Verify  verify = Verify::None 
)
noexcept

Switch channels on and off together. CH_CTRL is read first, so the copy is the chip's (a channel a fault switched off stays off), then written whole with only the EN_CH bits the mask names changed; OP_MODE is kept as the chip has it, never set (handbook KB-CPP-121, -122).

Parameters
maskBit x for channel x, 0 to 0x3F. A channel the mask enables must be declared loaded and not be a slave, and Mission Mode is needed to enable one (section 5.3.2.3). A channel already on whose state a failed write left unknown is kept as the chip has it, so the mask still switches the others off; only a channel it newly turns on is refused (WrongState).
verifyReadBack: read CH_CTRL back, two more frames.
Returns
Ok, NotInitialized, InvalidArgument, WrongState (nothing sent), MissionBlocked (the chip left Mission Mode on its own), WriteMismatch (the chip keeps a channel with a latched fault off, section 4.9.2), Bus or a reply error. 4 frames.

◆ SetParallel()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::SetParallel ( ParallelPair  pair,
bool  enabled 
)
noexcept

Join or split a pair (CH_CTRL.CH_PAR, Config Mode only, section 4.5.2). Joining sets the master's SETPOINT to 0 first, since one TARGET count is then twice the current; set it again with SetCurrent(), checked against the pair's limit. Splitting rewrites the slave's registers, which the chip requires.

Parameters
pairThe pair.
enabledJoin or split.
Returns
Ok, NotInitialized, InvalidArgument (the slave is declared loaded), WrongState (Mission Mode), Bus or a reply error.

◆ StartOvercurrentCheck()

template<SpiPort Port>
Result< void > tle92466ed::TLE92466ED< Port >::StartOvercurrentCheck ( Channel  channel)
noexcept

Run the OFF-state overcurrent check once (section 4.9.6): set CH_CONFIG.OC_DIAG_EN and the channel's EN_CH; the chip switches the stage on for t_OCon and clears OC_DIAG_EN. Read the result with ReadFaults() after t_OCon. The channel must be off with setpoint 0, so the check does not start the current controller; afterwards it stays enabled with setpoint 0, which is the OFF-state diagnosis condition (4.9.1): DisableChannel() when that is not wanted.

Parameters
channelA loaded channel, not a slave, with on_time_mant not 0 and t_OCon at most 300 ms (TON register note).
Returns
Ok, NotInitialized, InvalidArgument, WrongState (Config Mode, a slave, a setpoint, or the channel on or asked on since the last read of CH_CTRL: nothing sent), MissionBlocked, Bus or a reply error. 6 frames.

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