TLE92466ED Driver 2.0.0
API reference
Loading...
Searching...
No Matches
tle92466ed_registers.hpp
Go to the documentation of this file.
1
6#pragma once
7#include <algorithm>
8#include <cmath>
9#include <cstddef>
10#include <cstdint>
11
12namespace tle92466ed {
13
14//==============================================================================
15// REGISTER ADDRESSES - CENTRAL/GLOBAL REGISTERS
16//==============================================================================
17
25namespace CentralReg {
26constexpr uint16_t CH_CTRL = 0x0000;
27constexpr uint16_t GLOBAL_CONFIG = 0x0002;
28constexpr uint16_t GLOBAL_DIAG0 = 0x0003;
29constexpr uint16_t GLOBAL_DIAG1 = 0x0004;
30constexpr uint16_t GLOBAL_DIAG2 = 0x0005;
31constexpr uint16_t VBAT_TH = 0x0006;
32constexpr uint16_t FB_FRZ = 0x0007;
33constexpr uint16_t FB_UPD = 0x0008;
34constexpr uint16_t WD_RELOAD = 0x0009;
35
36// Channel Group Diagnosis (per datasheet §5.3.2.12 / §5.3.2.13)
37// There are ONLY 3 groups. Each group covers a pair of channels via
38// an internal y=0/y=1 field offset:
39// CHGR0 covers CH0 (y=0) + CH1 (y=1)
40// CHGR1 covers CH2 (y=0) + CH3 (y=1)
41// CHGR2 covers CH4 (y=0) + CH5 (y=1)
42// Use DIAG_ERR_CHGR::AddressForChannel(ch) / DIAG_WARN_CHGR::AddressForChannel(ch).
43// Addresses 0x000D..0x000F and 0x0013..0x0015 are NOT DIAG registers.
44constexpr uint16_t DIAG_ERR_CHGR0 = 0x000A;
45constexpr uint16_t DIAG_ERR_CHGR1 = 0x000B;
46constexpr uint16_t DIAG_ERR_CHGR2 = 0x000C;
47
48constexpr uint16_t DIAG_WARN_CHGR0 = 0x0010;
49constexpr uint16_t DIAG_WARN_CHGR1 = 0x0011;
50constexpr uint16_t DIAG_WARN_CHGR2 = 0x0012;
51
52constexpr uint16_t FAULT_MASK0 = 0x0016;
53constexpr uint16_t FAULT_MASK1 = 0x0017;
54constexpr uint16_t FAULT_MASK2 = 0x0018;
55constexpr uint16_t CLK_DIV = 0x0019;
56constexpr uint16_t SFF_BIST = 0x003F;
57
58// Feedback/Status Registers
59constexpr uint16_t ICVID = 0x0200;
60constexpr uint16_t PIN_STAT = 0x0201;
61constexpr uint16_t FB_STAT = 0x0202;
62constexpr uint16_t FB_VOLTAGE1 = 0x0203;
63constexpr uint16_t FB_VOLTAGE2 = 0x0204;
64constexpr uint16_t CHIPID0 = 0x0205;
65constexpr uint16_t CHIPID1 = 0x0206;
66constexpr uint16_t CHIPID2 = 0x0207;
67} // namespace CentralReg
68
69//==============================================================================
70// DEVICE IDENTIFICATION CONSTANTS
71//==============================================================================
72
83namespace DeviceID {
84constexpr uint16_t DEVICE_TYPE_MASK = 0xFF00;
85constexpr uint16_t REVISION_MASK = 0x00FF;
86
87// Expected manufacturer/device-type code for TLE92466ED (upper byte of ICVID).
88// Per datasheet §5.3.2.19 p.75 the high byte is fixed at 0xC1 (Infineon
89// manufacturer ID for this family); the low byte is the silicon revision
90// and may vary by part lot. VerifyDevice() accepts any 0xC1?? value.
91constexpr uint8_t EXPECTED_TYPE_92466ED = 0xC1;
92
93// Minimum supported silicon revision
94constexpr uint8_t MIN_REVISION = 0x00;
95
101[[nodiscard]] constexpr bool IsValidDevice(uint16_t icvid) noexcept {
102 // Reject obviously broken reads (all-zero / all-one).
103 if (icvid == 0x0000 || icvid == 0xFFFF) return false;
104 const uint8_t device_type = static_cast<uint8_t>((icvid >> 8) & 0xFF);
105 return device_type == EXPECTED_TYPE_92466ED;
106}
107
111[[nodiscard]] constexpr uint8_t GetDeviceType(uint16_t icvid) noexcept {
112 return (icvid >> 8) & 0xFF;
113}
114
118[[nodiscard]] constexpr uint8_t GetRevision(uint16_t icvid) noexcept {
119 return icvid & 0xFF;
120}
121} // namespace DeviceID
122
123//==============================================================================
124// CHANNEL REGISTER OFFSETS
125//==============================================================================
126
142namespace ChannelBase {
143constexpr uint16_t CH0 = 0x0040;
144constexpr uint16_t CH1 = 0x0050;
145constexpr uint16_t CH2 = 0x0060;
146constexpr uint16_t CH3 = 0x0070;
147constexpr uint16_t CH4 = 0x0020;
148constexpr uint16_t CH5 = 0x0030;
149} // namespace ChannelBase
150
154namespace ChannelReg {
155constexpr uint16_t SETPOINT = 0x0000;
156constexpr uint16_t CTRL = 0x0001;
157constexpr uint16_t PERIOD = 0x0002;
158constexpr uint16_t INTEGRATOR_LIMIT = 0x0003;
159constexpr uint16_t DITHER_CLK_DIV = 0x0004;
160constexpr uint16_t DITHER_STEP = 0x0005;
161constexpr uint16_t DITHER_CTRL = 0x0006;
162constexpr uint16_t CH_CONFIG = 0x0007;
163constexpr uint16_t MODE = 0x000C;
164constexpr uint16_t TON = 0x000D;
165constexpr uint16_t CTRL_INT_THRESH = 0x000E;
166constexpr uint16_t FB_DC = 0x0200;
167constexpr uint16_t FB_VBAT = 0x0201;
168constexpr uint16_t FB_I_AVG = 0x0202;
169constexpr uint16_t FB_IMIN_IMAX = 0x0203;
170constexpr uint16_t FB_I_AVG_s16 = 0x0204;
171constexpr uint16_t FB_INT_THRESH = 0x0205;
172constexpr uint16_t FB_PERIOD_MIN_MAX = 0x0206;
173} // namespace ChannelReg
174
175//==============================================================================
176// CH_CTRL REGISTER (0x0000) - Channel Control
177//==============================================================================
178
204namespace CH_CTRL {
205constexpr uint16_t EN_CH0 = (1 << 0);
206constexpr uint16_t EN_CH1 = (1 << 1);
207constexpr uint16_t EN_CH2 = (1 << 2);
208constexpr uint16_t EN_CH3 = (1 << 3);
209constexpr uint16_t EN_CH4 = (1 << 4);
210constexpr uint16_t EN_CH5 = (1 << 5);
211constexpr uint16_t CH_PAR_4_5 = (1 << 12);
212constexpr uint16_t CH_PAR_0_3 = (1 << 13);
213constexpr uint16_t CH_PAR_1_2 = (1 << 14);
214constexpr uint16_t OP_MODE = (1 << 15);
215
216constexpr uint16_t ALL_CH_MASK = 0x003F;
217constexpr uint16_t ALL_PAR_MASK = 0x7000;
218
219constexpr uint16_t DEFAULT = 0x0000;
220
222constexpr uint16_t CONFIG_MODE = 0x0000;
224constexpr uint16_t MISSION_MODE = OP_MODE;
225
229[[nodiscard]] constexpr uint16_t ChannelMask(uint8_t channel) noexcept {
230 return (channel < 6) ? static_cast<uint16_t>(1 << channel) : 0;
231}
232} // namespace CH_CTRL
233
234//==============================================================================
235// GLOBAL_CONFIG REGISTER (0x0002) - Global Configuration
236//==============================================================================
237
258namespace GLOBAL_CONFIG {
259constexpr uint16_t CLK_WD_EN = (1 << 0);
260constexpr uint16_t SPI_WD_EN = (1 << 1);
261constexpr uint16_t CRC_EN = (1 << 2);
262constexpr uint16_t V1V5_UV_TEST = (1 << 4);
263constexpr uint16_t V1V5_OV_TEST = (1 << 5);
264constexpr uint16_t OT_TEST = (1 << 12);
265constexpr uint16_t UV_OV_SWAP = (1 << 13);
266constexpr uint16_t VIO_SEL = (1 << 14);
267
268constexpr uint16_t DEFAULT = 0x4005;
269} // namespace GLOBAL_CONFIG
270
271//==============================================================================
272// GLOBAL_DIAG0 REGISTER (0x0003) - Global Diagnosis Register 0
273//==============================================================================
274
299namespace GLOBAL_DIAG0 {
300constexpr uint16_t VBAT_UV = (1 << 0);
301constexpr uint16_t VBAT_OV = (1 << 1);
302constexpr uint16_t VIO_UV = (1 << 2);
303constexpr uint16_t VIO_OV = (1 << 3);
304constexpr uint16_t VDD_UV = (1 << 4);
305constexpr uint16_t VDD_OV = (1 << 5);
306constexpr uint16_t CLK_NOK = (1 << 6);
307constexpr uint16_t COTERR = (1 << 7);
308constexpr uint16_t COTWARN = (1 << 8);
309constexpr uint16_t RES_EVENT = (1 << 9);
310constexpr uint16_t POR_EVENT = (1 << 10);
311constexpr uint16_t SPI_WD_ERR = (1 << 14);
312
313constexpr uint16_t DEFAULT = 0x0600;
314constexpr uint16_t FAULT_MASK = 0x47FF;
315constexpr uint16_t CLEAR_ALL = 0xFFFF;
316} // namespace GLOBAL_DIAG0
317
318//==============================================================================
319// WD_RELOAD REGISTER (0x0009) - SPI Watchdog Reload Register
320//==============================================================================
321
344namespace WD_RELOAD {
345constexpr uint16_t WD_TIME_MASK = 0x07FF;
346constexpr uint16_t WD_TIME_MAX = 0x07FF;
347constexpr uint16_t DEFAULT = 0x0001;
348
354[[nodiscard]] constexpr uint16_t MaskValue(uint16_t value) noexcept {
355 return value & WD_TIME_MASK;
356}
357} // namespace WD_RELOAD
358
359//==============================================================================
360// GLOBAL_DIAG1 REGISTER (0x0004) - Global Diagnosis Register 1
361//==============================================================================
362
383namespace GLOBAL_DIAG1 {
384constexpr uint16_t VR_IREF_UV = (1 << 0);
385constexpr uint16_t VR_IREF_OV = (1 << 1);
386constexpr uint16_t VDD2V5_UV = (1 << 2);
387constexpr uint16_t VDD2V5_OV = (1 << 3);
388constexpr uint16_t REF_UV = (1 << 4);
389constexpr uint16_t REF_OV = (1 << 5);
390constexpr uint16_t VPRE_OV = (1 << 6);
391constexpr uint16_t HVADC_ERR = (1 << 15);
392
393constexpr uint16_t DEFAULT = 0x0000;
394constexpr uint16_t CLEAR_ALL = 0xFFFF;
395} // namespace GLOBAL_DIAG1
396
397//==============================================================================
398// DIAG_ERR_CHGRx REGISTERS (0x000A..0x000C) - Per-Channel-Pair Error Diagnostics
399//==============================================================================
400
418namespace DIAG_ERR_CHGR {
419constexpr uint8_t BIT_OLSG = 0;
420constexpr uint8_t BIT_OL = 1;
421constexpr uint8_t BIT_OC = 2;
422constexpr uint8_t BIT_SG = 3;
423constexpr uint8_t BIT_OTE = 4;
424
426constexpr uint16_t PER_CHANNEL_MASK = 0x001Fu;
427
429constexpr uint16_t OC_BOTH_MASK = (1u << BIT_OC) | (1u << (BIT_OC + 8));
430
432[[nodiscard]] constexpr uint16_t AddressForChannel(uint8_t channel) noexcept {
433 return static_cast<uint16_t>(CentralReg::DIAG_ERR_CHGR0 + (channel / 2));
434}
435
437[[nodiscard]] constexpr uint8_t YShiftForChannel(uint8_t channel) noexcept {
438 return static_cast<uint8_t>((channel & 1u) * 8u);
439}
440
442[[nodiscard]] constexpr uint16_t ChannelBitMask(uint8_t channel, uint8_t bit_index) noexcept {
443 return static_cast<uint16_t>(1u << (bit_index + YShiftForChannel(channel)));
444}
445
447[[nodiscard]] constexpr uint16_t OcClearMaskForChannel(uint8_t channel) noexcept {
448 return ChannelBitMask(channel, BIT_OC);
449}
450} // namespace DIAG_ERR_CHGR
451
452//==============================================================================
453// DIAG_WARN_CHGRx REGISTERS (0x0010..0x0012) - Per-Channel-Pair Warnings
454//==============================================================================
455
469namespace DIAG_WARN_CHGR {
470constexpr uint8_t BIT_PWM_REG = 0;
471constexpr uint8_t BIT_I_REG = 1;
472constexpr uint8_t BIT_OTW = 2;
473constexpr uint8_t BIT_OLSG_WARN = 3;
474constexpr uint8_t BIT_OLSG_CHK_NOK = 4;
475
476constexpr uint16_t PER_CHANNEL_MASK = 0x001Fu;
477
479[[nodiscard]] constexpr uint16_t AddressForChannel(uint8_t channel) noexcept {
480 return static_cast<uint16_t>(CentralReg::DIAG_WARN_CHGR0 + (channel / 2));
481}
482
484[[nodiscard]] constexpr uint8_t YShiftForChannel(uint8_t channel) noexcept {
485 return static_cast<uint8_t>((channel & 1u) * 8u);
486}
487
489[[nodiscard]] constexpr uint16_t ChannelBitMask(uint8_t channel, uint8_t bit_index) noexcept {
490 return static_cast<uint16_t>(1u << (bit_index + YShiftForChannel(channel)));
491}
492} // namespace DIAG_WARN_CHGR
493
494//==============================================================================
495// GLOBAL_DIAG2 REGISTER (0x0005) - Global Diagnosis Register 2
496//==============================================================================
497
510namespace GLOBAL_DIAG2 {
511constexpr uint16_t REG_ECC_ERR = (1 << 1);
512constexpr uint16_t OTP_ECC_ERR = (1 << 3);
513constexpr uint16_t OTP_VIRGIN = (1 << 4);
514
515constexpr uint16_t DEFAULT = 0x0000;
516constexpr uint16_t CLEAR_ALL = 0xFFFF;
517} // namespace GLOBAL_DIAG2
518
519//==============================================================================
520// FB_STAT REGISTER (0x0202) - Feedback Status
521//==============================================================================
522
538namespace FB_STAT {
539constexpr uint32_t DIAG_WARN_CHGR0 = (1u << 0);
540constexpr uint32_t DIAG_WARN_CHGR1 = (1u << 1);
541constexpr uint32_t DIAG_WARN_CHGR2 = (1u << 2);
542constexpr uint32_t OLSG_WARN_CHK_NOK_CHGR0 = (1u << 3);
543constexpr uint32_t OLSG_WARN_CHK_NOK_CHGR1 = (1u << 4);
544constexpr uint32_t OLSG_WARN_CHK_NOK_CHGR2 = (1u << 5);
545constexpr uint32_t CLK_NOK_STAT = (1u << 6);
546constexpr uint32_t COTERR = (1u << 7);
547constexpr uint32_t COTWARN = (1u << 8);
548constexpr uint32_t RES_EVENT = (1u << 9);
549constexpr uint32_t POR_EVENT = (1u << 10);
550constexpr uint32_t DATA_ERR = (1u << 11);
551constexpr uint32_t SUP_NOK_EXT = (1u << 12);
552constexpr uint32_t SUP_NOK_INT = (1u << 13);
553constexpr uint32_t ERR_CHGR0 = (1u << 14);
554constexpr uint32_t ERR_CHGR1 = (1u << 15);
555constexpr uint32_t ERR_CHGR2 = (1u << 16);
556constexpr uint32_t SPI_WD_ERR = (1u << 20);
557constexpr uint32_t INIT_DONE = (1u << 21);
558} // namespace FB_STAT
559
560//==============================================================================
561// CHANNEL SETPOINT REGISTER - Per Channel
562//==============================================================================
563
593namespace SETPOINT {
594constexpr uint16_t TARGET_MASK = 0x7FFF;
595constexpr uint16_t AUTO_LIMIT_DIS = (1 << 15);
596
597constexpr uint16_t DEFAULT = 0x0000;
598
600constexpr uint16_t MAX_TARGET = 0x6000;
601
610[[nodiscard]] constexpr uint16_t CalculateTarget(uint16_t current_ma,
611 bool parallel_mode = false) noexcept {
612 uint32_t max_current = parallel_mode ? 4000 : 2000;
613 // Integer math: adding (max_current/2) before division is equivalent to (val / max_current + 0.5)
614 // for rounding up (uint32_t(current_ma) * 32767UL + max_current / 2) / max_current <=>
615 // (current_ma * 32767 / max_current + 0.5)
616 uint32_t target = (static_cast<uint32_t>(current_ma) * 32767UL + (max_current / 2)) / max_current;
617 // Saturate at MAX_TARGET
618 target = std::min(target, static_cast<uint32_t>(MAX_TARGET));
619 return static_cast<uint16_t>(target);
620}
621
630[[nodiscard]] constexpr uint16_t CalculateTargetUa(uint32_t current_ua,
631 bool parallel_mode = false) noexcept {
632 const uint64_t max_ua = parallel_mode ? 4000000ULL : 2000000ULL;
633 uint64_t target = (static_cast<uint64_t>(current_ua) * 32767ULL + (max_ua / 2ULL)) / max_ua;
634 if (target > MAX_TARGET) {
635 target = MAX_TARGET;
636 }
637 return static_cast<uint16_t>(target);
638}
639
648[[nodiscard]] constexpr uint16_t CalculateCurrent(uint16_t target,
649 bool parallel_mode = false) noexcept {
650 uint32_t max_current = parallel_mode ? 4000 : 2000;
651 // Use rounding: add half of 32767 before division to minimize quantization error
652 uint32_t current = (static_cast<uint32_t>(target & TARGET_MASK) * max_current + 16383) / 32767UL;
653 return static_cast<uint16_t>(current);
654}
655
656// Datasheet §5.3.3.3: I_set = 2 A * TARGET / (2^15-1); 0x6000 saturates at 1.5 A.
657// A 9-bit TARGET (0x1FF) decodes as 31 mA — the HIL "clamped to 31 mA" signature
658// when SETPOINT readback is actually FB_IMIN (10-bit signed, max +511) or a
659// truncated field rather than the 15-bit TARGET. CH_CTRL 0x8020 (Mission+CH5)
660// decodes as 2 mA — the leftover from a MakeRead(0) dummy.
661static_assert(CalculateTarget(115) == 1884, "115 mA → TARGET 0x075C");
662static_assert(CalculateCurrent(1884) == 115, "TARGET 0x075C → 115 mA");
663static_assert(CalculateCurrent(0x01FF) == 31, "9-bit max TARGET decodes as 31 mA");
664static_assert(CalculateCurrent(0x0020) == 2, "CH_CTRL EN_CH5 leftover decodes as 2 mA");
665} // namespace SETPOINT
666
667//==============================================================================
668// PERIOD REGISTER - PWM Period Configuration
669//==============================================================================
670
690namespace PERIOD {
691constexpr uint16_t MANT_MASK = 0x00FF;
692constexpr uint16_t EXP_MASK = 0x0700;
693constexpr uint16_t EXP_SHIFT = 8;
694constexpr uint8_t EXP_VALUE_MASK = 0x07;
695constexpr uint16_t LOW_FREQ_BIT = (1 << 11);
696
699constexpr uint16_t PWM_CTRL_PARAM_SHIFT = 12;
700constexpr uint16_t PWM_CTRL_PARAM_MASK = 0xF000;
701
702constexpr uint32_t F_SYS_HZ = 28'000'000UL;
703constexpr float F_SYS_PERIOD_US = 1.0F / 28.0F;
704
705//
706// Datasheet-spec PWM frequency range
707// ----------------------------------
708// Per datasheet (Electrical Characteristics, parameter "Target PWM frequency
709// fPWM"): the PWM frequency controller is specified to operate between
710// 110 Hz and 4000 Hz. Setting a value outside this range will not be
711// rejected by the chip — it simply isn't guaranteed to work.
712//
713// With the LOW_FREQ_RANGE_EN bit set, the period is multiplied by 8, so
714// the supported frequency range is 8× lower (≈13.75 Hz – 500 Hz).
715//
716// Periods are derived from the formula T_pwm = 1 / f_pwm.
717//
718// Note: the chip family cannot drive PWM above 4 kHz, so reaching the
719// ultrasonic range (>20 kHz) is not possible with the TLE92466ED.
720//
721constexpr float kSpecMinFrequency_Hz = 110.0F;
722constexpr float kSpecMaxFrequency_Hz = 4000.0F;
723constexpr float kSpecMinPeriod_us = 1.0e6F / kSpecMaxFrequency_Hz;
724constexpr float kSpecMaxPeriod_us = 1.0e6F / kSpecMinFrequency_Hz;
725
729 1.0e6F / kSpecLowRangeMaxFreq_Hz;
731 1.0e6F / kSpecLowRangeMinFreq_Hz;
732
737
752 uint8_t mantissa;
753 uint8_t exponent;
755
760 [[nodiscard]] constexpr float CalculatePeriodUs() const noexcept {
761 float base_period =
762 static_cast<float>(mantissa) * static_cast<float>(1ULL << exponent) * F_SYS_PERIOD_US;
763 return low_freq_range ? (base_period * 8.0F) : base_period;
764 }
765};
766
772[[nodiscard]] inline PeriodConfig CalculateFromPeriodUs(float period_us) noexcept {
773 PeriodConfig config{};
774
775 // Try standard range first
776 for (uint8_t exp = 0; exp <= 7; ++exp) {
777 float divisor = static_cast<float>(1ULL << exp) * F_SYS_PERIOD_US;
778 float mantissa_f = period_us / divisor;
779
780 if (mantissa_f <= 255.0F && mantissa_f >= 1.0F) {
781 config.mantissa = static_cast<uint8_t>(std::lround(mantissa_f)); // Round
782 config.exponent = exp;
783 config.low_freq_range = false;
784 return config;
785 }
786 }
787
788 // Try low frequency range (8x multiplier)
789 for (uint8_t exp = 0; exp <= 7; ++exp) {
790 float divisor = static_cast<float>(1ULL << exp) * F_SYS_PERIOD_US * 8.0F;
791 float mantissa_f = period_us / divisor;
792
793 if (mantissa_f <= 255.0F && mantissa_f >= 1.0F) {
794 config.mantissa = static_cast<uint8_t>(std::lround(mantissa_f)); // Round
795 config.exponent = exp;
796 config.low_freq_range = true;
797 return config;
798 }
799 }
800
801 // Out of range - return invalid (mantissa = 0)
802 config.mantissa = 0;
803 config.exponent = 0;
804 config.low_freq_range = false;
805 return config;
806}
807
813[[nodiscard]] constexpr uint16_t BuildRegisterValue(const PeriodConfig& config) noexcept {
814 return config.mantissa | ((config.exponent & 0x07) << EXP_SHIFT) |
815 (config.low_freq_range ? LOW_FREQ_BIT : 0);
816}
817} // namespace PERIOD
818
819//==============================================================================
820// CHANNEL CTRL REGISTER - Per Channel
821//==============================================================================
822
834namespace CH_CTRL_REG {
835constexpr uint16_t MIN_INT_THRESH_MASK = 0x00FF;
836constexpr uint16_t PWM_PERIOD_CALC_MODE = (1 << 8);
837constexpr uint16_t OLSG_WARN_WINDOW_MASK = 0x3E00;
838constexpr uint16_t OLSG_WARN_WINDOW_SHIFT = 9;
839constexpr uint16_t OLSG_WARN_EN = (1 << 14);
840
841constexpr uint16_t DEFAULT = 0x4600;
842
844constexpr uint16_t DEFAULT_OLSG_WARN_WINDOW = 3u;
845
860constexpr uint8_t MIN_INT_THRESH_FLOOR = 2u;
861
870constexpr uint8_t MIN_INT_THRESH_CEIL = 12u;
871
884[[nodiscard]] constexpr uint16_t Build(uint8_t min_int_thresh,
885 bool olsg_warning_enabled,
886 bool pwm_period_calc_mode) noexcept {
887 return static_cast<uint16_t>(
888 (static_cast<uint16_t>(min_int_thresh) & MIN_INT_THRESH_MASK) |
890 (olsg_warning_enabled ? OLSG_WARN_EN : 0u) |
891 (pwm_period_calc_mode ? PWM_PERIOD_CALC_MODE : 0u));
892}
893
894static_assert(Build(0u, true, false) == DEFAULT,
895 "Build with POR fields must reproduce the datasheet reset value");
896} // namespace CH_CTRL_REG
897
898//==============================================================================
899// CH_CONFIG REGISTER - Per Channel Configuration
900//==============================================================================
901
920namespace CH_CONFIG {
921// Slew rate control [1:0]
922constexpr uint16_t SLEWR_1V0_US = 0b00;
923constexpr uint16_t SLEWR_2V5_US = 0b01;
924constexpr uint16_t SLEWR_5V0_US = 0b10;
925constexpr uint16_t SLEWR_10V0_US = 0b11;
926constexpr uint16_t SLEWR_MASK = 0x0003;
927
928// OFF-state diagnostic current [3:2]
929constexpr uint16_t I_DIAG_80UA = (0 << 2);
930constexpr uint16_t I_DIAG_190UA = (1 << 2);
931constexpr uint16_t I_DIAG_720UA = (2 << 2);
932constexpr uint16_t I_DIAG_1250UA = (3 << 2);
933constexpr uint16_t I_DIAG_MASK = 0x000C;
934
935// Open load threshold relative to setpoint [6:4]
936constexpr uint16_t OL_TH_DISABLED = (0 << 4);
937constexpr uint16_t OL_TH_1_8 = (1 << 4);
938constexpr uint16_t OL_TH_2_8 = (2 << 4);
939constexpr uint16_t OL_TH_3_8 = (3 << 4);
940constexpr uint16_t OL_TH_4_8 = (4 << 4);
941constexpr uint16_t OL_TH_5_8 = (5 << 4);
942constexpr uint16_t OL_TH_6_8 = (6 << 4);
943constexpr uint16_t OL_TH_7_8 = (7 << 4);
944constexpr uint16_t OL_TH_MASK = 0x0070;
945constexpr uint8_t OL_TH_VALUE_MASK = 0x07;
946constexpr uint8_t OL_TH_SHIFT = 4;
947
948// Fixed open load threshold [12:7]
949constexpr uint16_t OL_TH_FIXED_SHIFT = 7;
950constexpr uint16_t OL_TH_FIXED_MASK = 0x1F80;
951
952constexpr uint16_t OC_DIAG_EN = (1 << 13);
953
954// OFF-state diagnostic control [15:14]
955constexpr uint16_t OFF_DIAG_ENABLED = (0 << 14);
956constexpr uint16_t OFF_DIAG_LS_ONLY = (1 << 14);
957constexpr uint16_t OFF_DIAG_HS_ONLY = (2 << 14);
958constexpr uint16_t OFF_DIAG_MASK = 0xC000;
959
960constexpr uint16_t DEFAULT = 0x0003;
961} // namespace CH_CONFIG
962
963//==============================================================================
964// MODE REGISTER - Channel Mode
965//==============================================================================
966
978namespace CH_MODE {
979constexpr uint16_t OFF = 0x0000;
980constexpr uint16_t ICC_CURRENT_CTRL = 0x0001;
981constexpr uint16_t DIRECT_DRIVE_SPI = 0x0002;
982constexpr uint16_t DIRECT_DRIVE_DRV0 = 0x0003;
983constexpr uint16_t DIRECT_DRIVE_DRV1 = 0x0004;
984constexpr uint16_t FREE_RUN_MEAS = 0x000C;
985constexpr uint16_t MODE_MASK = 0x000F;
986
987constexpr uint16_t DEFAULT = OFF;
988} // namespace CH_MODE
989
990//==============================================================================
991// TON REGISTER - Direct-Drive On-Time (Per Channel, offset 0x000D)
992//==============================================================================
993
1006namespace TON {
1007constexpr uint16_t TON_MANT_MASK = 0x03FFu;
1008constexpr uint16_t OLSG_TIMEOUT_SHIFT = 10u;
1009constexpr uint16_t OLSG_TIMEOUT_MASK = 0xFC00u;
1010
1011constexpr uint16_t DEFAULT = 0x0000;
1012
1014[[nodiscard]] constexpr uint16_t Build(uint16_t ton_mant, uint8_t olsg_timeout) noexcept {
1015 return static_cast<uint16_t>((ton_mant & TON_MANT_MASK)
1016 | ((static_cast<uint16_t>(olsg_timeout) << OLSG_TIMEOUT_SHIFT) & OLSG_TIMEOUT_MASK));
1017}
1018} // namespace TON
1019
1020//==============================================================================
1021// INTEGRATOR_LIMIT REGISTER - ICC Integrator Limit (Per Channel, offset 0x0003)
1022//==============================================================================
1023
1036namespace INTEGRATOR_LIMIT {
1037constexpr uint16_t LIM_VALUE_ABS_MASK = 0x03FFu;
1038constexpr uint16_t AUTO_LIM_VALUE_ABS_SHIFT = 10u;
1039constexpr uint16_t AUTO_LIM_VALUE_ABS_MASK = 0x7C00u;
1040
1052constexpr uint16_t DEFAULT = 0x43FFu;
1053
1054[[nodiscard]] constexpr uint16_t Build(uint16_t lim_value_abs,
1055 uint8_t auto_lim_value_abs) noexcept {
1056 return static_cast<uint16_t>((lim_value_abs & LIM_VALUE_ABS_MASK)
1057 | ((static_cast<uint16_t>(auto_lim_value_abs) << AUTO_LIM_VALUE_ABS_SHIFT)
1059}
1060} // namespace INTEGRATOR_LIMIT
1061
1062//==============================================================================
1063// CTRL_INT_THRESH REGISTER - ICC Integrator Threshold (Per Channel, offset 0x000E)
1064//==============================================================================
1065
1089namespace CTRL_INT_THRESH {
1090constexpr uint16_t INT_THRESH_MASK = 0x01FFu;
1091constexpr uint16_t INT_THRESH_MAX = 0x01FFu;
1092
1093constexpr uint16_t DEFAULT = 0x0003u;
1094
1096[[nodiscard]] constexpr uint16_t Build(uint16_t int_thresh) noexcept {
1097 return static_cast<uint16_t>(int_thresh & INT_THRESH_MASK);
1098}
1099} // namespace CTRL_INT_THRESH
1100
1101//==============================================================================
1102// CLK_DIV REGISTER (0x0019) - Central Clock Source and PLL Divider
1103//==============================================================================
1104
1119namespace CLK_DIV {
1120constexpr uint16_t EXT_CLK_BIT = (1u << 15);
1121constexpr uint16_t PLL_REFDIV_SHIFT = 9u;
1122constexpr uint16_t PLL_REFDIV_MASK = 0x7E00u; // 6-bit
1123constexpr uint16_t PLL_FBDIV_MASK = 0x01FFu; // 9-bit
1124
1125constexpr uint32_t F_SYS_TARGET_HZ = 28'000'000UL;
1126
1128[[nodiscard]] constexpr uint16_t BuildExternalPll(uint8_t pll_refdiv,
1129 uint16_t pll_fbdiv) noexcept {
1130 return static_cast<uint16_t>(EXT_CLK_BIT
1131 | ((static_cast<uint16_t>(pll_refdiv) << PLL_REFDIV_SHIFT) & PLL_REFDIV_MASK)
1132 | (pll_fbdiv & PLL_FBDIV_MASK));
1133}
1134
1136constexpr uint16_t INTERNAL_OSC = 0x0000u;
1137
1141struct PllConfig { uint8_t refdiv; uint16_t fbdiv; uint32_t actual_f_sys_hz; };
1142[[nodiscard]] inline PllConfig CalculatePllFromExternalHz(uint32_t f_clk_hz) noexcept {
1143 PllConfig cfg{0u, 0u, 0u};
1144 if (f_clk_hz == 0) return cfg;
1145 const uint32_t n_plus_1 = (F_SYS_TARGET_HZ + (f_clk_hz / 2)) / f_clk_hz;
1146 if (n_plus_1 == 0 || n_plus_1 > 512) return cfg;
1147 cfg.refdiv = 0u;
1148 cfg.fbdiv = static_cast<uint16_t>(n_plus_1 - 1u);
1149 cfg.actual_f_sys_hz = f_clk_hz * n_plus_1;
1150 return cfg;
1151}
1152} // namespace CLK_DIV
1153
1154//==============================================================================
1155// SFF_BIST REGISTER (0x003F) - Safe State / BIST Control
1156//==============================================================================
1157
1170namespace SFF_BIST {
1171constexpr uint16_t EN = (1u << 0);
1172constexpr uint16_t DONE = (1u << 1);
1173constexpr uint16_t FAIL = (1u << 2);
1174constexpr uint16_t UERR = (1u << 3);
1175constexpr uint16_t CERR = (1u << 4);
1176
1177constexpr uint16_t DEFAULT = 0x0000;
1178} // namespace SFF_BIST
1179
1180//==============================================================================
1181// PIN_STAT REGISTER (0x0201) - Input Pin Status (read-only)
1182//==============================================================================
1183
1196namespace PIN_STAT {
1197constexpr uint16_t DRV0 = (1u << 0);
1198constexpr uint16_t DRV1 = (1u << 1);
1199constexpr uint16_t EN = (1u << 4);
1200constexpr uint16_t FAULTN = (1u << 5);
1201constexpr uint16_t FAULTN_FB = (1u << 6);
1202} // namespace PIN_STAT
1203
1204//==============================================================================
1205// FAULT_MASK0/1/2 REGISTERS (0x0016-0x0018) - Contribution to FAULTN
1206//==============================================================================
1207
1216namespace FAULT_MASK0 {
1217constexpr uint16_t CH_ERR_MASK = 0x003Fu;
1218constexpr uint16_t EN_PIN_MASK = (1u << 13);
1219constexpr uint16_t SUP_NOK_INT_MASK = (1u << 14);
1220constexpr uint16_t SUP_NOK_EXT_MASK = (1u << 15);
1221constexpr uint16_t DEFAULT = 0xC03Fu;
1222} // namespace FAULT_MASK0
1223
1224namespace FAULT_MASK1 {
1225constexpr uint16_t CH_WARN_MASK = 0x003Fu;
1226constexpr uint16_t COTWARN_MASK = (1u << 12);
1227constexpr uint16_t COTERR_MASK = (1u << 13);
1228constexpr uint16_t CLK_LOW_MASK = (1u << 14);
1229constexpr uint16_t DEFAULT = 0x703Fu;
1230} // namespace FAULT_MASK1
1231
1232namespace FAULT_MASK2 {
1233constexpr uint16_t VBAT_UV_MASK = (1u << 0);
1234constexpr uint16_t VBAT_OV_MASK = (1u << 1);
1235constexpr uint16_t VIO_UV_MASK = (1u << 2);
1236constexpr uint16_t VIO_OV_MASK = (1u << 3);
1237constexpr uint16_t VDD_UV_MASK = (1u << 4);
1238constexpr uint16_t VDD_OV_MASK = (1u << 5);
1239constexpr uint16_t DATA_ERR_MASK = (1u << 14);
1240constexpr uint16_t SPI_WD_MASK = (1u << 15);
1242constexpr uint16_t DEFAULT = 0xC000u;
1243} // namespace FAULT_MASK2
1244
1245//==============================================================================
1246// DITHER CONTROL REGISTER - Per Channel
1247//==============================================================================
1248
1259namespace DITHER_CTRL {
1260constexpr uint16_t STEP_SIZE_MASK = 0x0FFF;
1261constexpr uint16_t DEEP_DITHER = (1 << 13);
1262constexpr uint16_t FAST_MEAS_DITH = (0 << 14);
1263constexpr uint16_t FAST_MEAS_HALF = (1 << 14);
1264constexpr uint16_t FAST_MEAS_QUAD = (2 << 14);
1265constexpr uint16_t FAST_MEAS_MASK = 0xC000;
1266
1267constexpr uint16_t DEFAULT = 0x0000;
1268} // namespace DITHER_CTRL
1269
1270//==============================================================================
1271// DITHER STEP REGISTER - Per Channel
1272//==============================================================================
1273
1283namespace DITHER_STEP {
1284constexpr uint16_t FLAT_MASK = 0x00FF;
1285constexpr uint16_t STEPS_SHIFT = 8;
1286constexpr uint16_t STEPS_MASK = 0xFF00;
1287
1288constexpr uint16_t DEFAULT = 0x0000;
1289} // namespace DITHER_STEP
1290
1291//==============================================================================
1292// DITHER HELPER FUNCTIONS
1293//==============================================================================
1294
1295//==============================================================================
1296// DITHER_CLK_DIV REGISTER - Per Channel (offset 0x0004 within channel bank)
1297//==============================================================================
1298
1321namespace DITHER_CLK_DIV {
1322constexpr uint16_t MANT_MASK = 0x03FFu;
1323constexpr uint16_t EXP_SHIFT = 10u;
1324constexpr uint16_t EXP_MASK = 0x3C00u;
1325constexpr uint8_t EXP_VALUE_MASK = 0x0Fu;
1326constexpr uint16_t DITHER_PWM_SYNC_EN_BIT = (1u << 14);
1327constexpr uint16_t DITHER_SETPOINT_SYNC_EN_BIT = (1u << 15);
1328
1329constexpr uint32_t F_SYS_HZ = 28'000'000UL;
1330constexpr float F_SYS_PERIOD_US = 1.0F / 28.0F;
1331
1334 uint16_t mantissa;
1335 uint8_t exponent;
1338
1340 [[nodiscard]] constexpr float CalculateTrefClkUs() const noexcept {
1341 return static_cast<float>(mantissa)
1342 * static_cast<float>(1ULL << exponent)
1344 }
1345
1347 [[nodiscard]] constexpr uint16_t ToRegister() const noexcept {
1348 return (mantissa & MANT_MASK)
1349 | ((static_cast<uint16_t>(exponent) & EXP_VALUE_MASK) << EXP_SHIFT)
1352 }
1353};
1354
1367[[nodiscard]] inline ClkDivConfig CalculateFromTrefClkUs(float t_ref_clk_us) noexcept {
1368 ClkDivConfig best{};
1369 best.mantissa = 1;
1370 best.exponent = 0;
1371 best.dither_pwm_sync_en = false;
1372 best.dither_setpoint_sync_en = false;
1373
1374 if (t_ref_clk_us <= 0.0F) return best;
1375
1376 float best_err = 1e30F;
1377 for (uint8_t exp = 0; exp <= 15; ++exp) {
1378 const float divisor = static_cast<float>(1ULL << exp) * F_SYS_PERIOD_US;
1379 const float mant_f = t_ref_clk_us / divisor;
1380 if (mant_f < 1.0F) continue; // mantissa would round to 0
1381 if (mant_f > 1023.0F) continue; // out of 10-bit range
1382 const uint16_t mant = static_cast<uint16_t>(mant_f + 0.5F);
1383 const float actual = static_cast<float>(mant) * divisor;
1384 const float err = std::fabs(actual - t_ref_clk_us);
1385 if (err < best_err) {
1386 best_err = err;
1387 best.mantissa = mant;
1388 best.exponent = exp;
1389 }
1390 }
1391 return best;
1392}
1393
1394} // namespace DITHER_CLK_DIV
1395
1413namespace DITHER {
1414constexpr float F_SYS_HZ = 28'000'000.0F;
1415constexpr float DEFAULT_T_REF_CLK_US = 1.0F / 28.0F;
1416
1421 uint16_t step_size;
1422 uint8_t num_steps;
1423 uint8_t flat_steps;
1424
1430 [[nodiscard]] constexpr float CalculateAmplitudeMa(bool parallel_mode = false) const noexcept {
1431 uint32_t max_current = parallel_mode ? 4000 : 2000;
1432 float amplitude = (static_cast<float>(num_steps) * static_cast<float>(step_size) *
1433 static_cast<float>(max_current)) /
1434 32767.0F;
1435 return amplitude;
1436 }
1437
1443 [[nodiscard]] constexpr float CalculatePeriodUs(
1444 float t_ref_clk_us = DEFAULT_T_REF_CLK_US) const noexcept {
1445 return (4.0F * static_cast<float>(num_steps) + 2.0F * static_cast<float>(flat_steps)) *
1446 t_ref_clk_us;
1447 }
1448};
1449
1465 float amplitude_ma, // Current amplitude in milliamperes
1466 float frequency_hz, // Dither frequency in hertz
1467 bool parallel_mode = false,
1468 float t_ref_clk_us = DEFAULT_T_REF_CLK_US) noexcept {
1469
1470 DitherConfig config{};
1471
1472 // Calculate desired period from frequency
1473 float period_us = 1'000'000.0F / frequency_hz;
1474
1475 // Calculate dither period from formula: T_dither = [4×STEPS + 2×FLAT] × t_ref_clk
1476 // Use reasonable defaults: num_steps = 16, flat_steps = 2
1477 constexpr uint8_t default_steps = 16;
1478 constexpr uint8_t default_flat = 2;
1479
1480 float calculated_period = (4.0F * default_steps + 2.0F * default_flat) * t_ref_clk_us;
1481
1482 // If calculated period doesn't match desired, adjust steps
1483 if (calculated_period < period_us * 0.9F || calculated_period > period_us * 1.1F) {
1484 // Adjust num_steps to get closer to desired period
1485 float target_steps = (period_us / t_ref_clk_us - 2.0F * default_flat) / 4.0F;
1486 // Clamp to valid range before casting to uint8_t
1487 target_steps = std::max(1.0F, target_steps);
1488 target_steps = std::min(255.0F, target_steps);
1489 config.num_steps = static_cast<uint8_t>(std::lround(target_steps));
1490 } else {
1491 config.num_steps = default_steps;
1492 }
1493
1494 config.flat_steps = default_flat;
1495
1496 // Calculate step_size from amplitude formula: I_dither = STEPS × STEP_SIZE × 2A / 32767
1497 uint32_t max_current = parallel_mode ? 4000 : 2000;
1498 float step_size_f = (amplitude_ma * 32767.0F) /
1499 (static_cast<float>(config.num_steps) * static_cast<float>(max_current));
1500
1501 config.step_size = static_cast<uint16_t>(std::lround(step_size_f));
1502 config.step_size = std::min(config.step_size, static_cast<uint16_t>(DITHER_CTRL::STEP_SIZE_MASK));
1503
1504 return config;
1505}
1506} // namespace DITHER
1507
1508//==============================================================================
1509// VBAT THRESHOLD HELPER FUNCTIONS
1510//==============================================================================
1511
1523namespace VBAT_THRESHOLD {
1524constexpr float LSB_VOLTAGE = 0.16208F;
1525constexpr float MIN_VOLTAGE = 0.0F;
1526constexpr float MAX_VOLTAGE = 41.4F;
1527
1533[[nodiscard]] constexpr uint8_t CalculateFromVoltage(float voltage_volts) noexcept {
1534 if (voltage_volts < MIN_VOLTAGE || voltage_volts > MAX_VOLTAGE) {
1535 return 0;
1536 }
1537 float register_value_f = voltage_volts / LSB_VOLTAGE;
1538 // Clamp to valid range before casting to uint8_t
1539 register_value_f = std::max(0.0F, register_value_f);
1540 register_value_f = std::min(255.0F, register_value_f);
1541 return static_cast<uint8_t>(std::lround(register_value_f)); // Round
1542}
1543
1549[[nodiscard]] constexpr float CalculateVoltage(uint8_t register_value) noexcept {
1550 return static_cast<float>(register_value) * LSB_VOLTAGE;
1551}
1552} // namespace VBAT_THRESHOLD
1553
1554//==============================================================================
1555// VOLTAGE FEEDBACK HELPER FUNCTIONS
1556//==============================================================================
1557
1573namespace VOLTAGE_FEEDBACK {
1574// VIO/VDD conversion constants (from FB_VOLTAGE1)
1575constexpr float VIO_VDD_LSB_VOLTAGE = 0.0034534F;
1576constexpr uint32_t VIO_VDD_MASK = 0x7FF;
1577constexpr uint32_t VDD_SHIFT = 11;
1578
1579// VBAT conversion constants (from FB_VOLTAGE2)
1580constexpr float VBAT_MAX_VOLTAGE = 41.47F;
1581constexpr uint32_t VBAT_MAX_COUNT = 2047;
1582constexpr uint32_t VBAT_MASK = 0x7FF;
1583constexpr uint32_t VBAT_SHIFT = 11;
1584
1590[[nodiscard]] constexpr uint16_t ExtractVioMillivolts(uint32_t register_value) noexcept {
1591 uint32_t vio_raw = (register_value >> 0) & VIO_VDD_MASK; // Bits [10:0]
1592 float vio_volts = static_cast<float>(vio_raw) * VIO_VDD_LSB_VOLTAGE;
1593 return static_cast<uint16_t>(std::lround(vio_volts * 1000.0F)); // Convert to mV and round
1594}
1595
1601[[nodiscard]] constexpr uint16_t ExtractVddMillivolts(uint32_t register_value) noexcept {
1602 uint32_t vdd_raw = (register_value >> VDD_SHIFT) & VIO_VDD_MASK; // Bits [21:11]
1603 float vdd_volts = static_cast<float>(vdd_raw) * VIO_VDD_LSB_VOLTAGE;
1604 return static_cast<uint16_t>(std::lround(vdd_volts * 1000.0F)); // Convert to mV and round
1605}
1606
1612[[nodiscard]] constexpr uint16_t ExtractVbatMillivolts(uint32_t register_value) noexcept {
1613 uint32_t vbat_raw = (register_value >> VBAT_SHIFT) & VBAT_MASK; // Bits [21:11]
1614 float vbat_volts =
1615 (static_cast<float>(vbat_raw) / static_cast<float>(VBAT_MAX_COUNT)) * VBAT_MAX_VOLTAGE;
1616 return static_cast<uint16_t>(std::lround(vbat_volts * 1000.0F)); // Convert to mV and round
1617}
1618
1624[[nodiscard]] constexpr uint16_t ExtractTemperatureRaw(uint32_t register_value) noexcept {
1625 return static_cast<uint16_t>((register_value >> 0) & VBAT_MASK); // Bits [10:0]
1626}
1627
1640[[nodiscard]] constexpr float TemperatureCelsiusFromRaw(uint16_t temp_value) noexcept {
1641 constexpr float K_VPERLSB = 0.000593F; // V per LSB
1642 constexpr float K_OFFSET_V = 0.819F; // V offset
1643 constexpr float K_SLOPE_VPERC = -0.0016F; // V per \u00b0C (negative slope)
1644 const float v = static_cast<float>(temp_value & 0x7FFu) * K_VPERLSB - K_OFFSET_V;
1645 return v / K_SLOPE_VPERC;
1646}
1647
1651[[nodiscard]] constexpr float TemperatureCelsiusFromFbVoltage2(uint32_t register_value) noexcept {
1652 return TemperatureCelsiusFromRaw(ExtractTemperatureRaw(register_value));
1653}
1654} // namespace VOLTAGE_FEEDBACK
1655
1656//==============================================================================
1657// FB_IMIN_IMAX DECODER - Per-Channel Signed Min/Max Load Current
1658//==============================================================================
1659
1678namespace FB_IMIN_IMAX {
1679constexpr uint32_t IMIN_SHIFT = 0u;
1680constexpr uint32_t IMIN_MASK = 0x3FFu; // 10-bit
1681constexpr uint32_t IMAX_SHIFT = 10u;
1682constexpr uint32_t IMAX_MASK = 0x3FFu; // 10-bit
1683constexpr int32_t FULL_SCALE_mA = 4000; // 4 A full scale
1684constexpr int32_t FULL_SCALE_COUNT = 511; // 2^9 - 1
1685
1687[[nodiscard]] constexpr int16_t SignExtend10(uint32_t v) noexcept {
1688 const uint32_t masked = v & 0x3FFu;
1689 return static_cast<int16_t>((masked & 0x200u) ? (masked | 0xFC00u) : masked);
1690}
1691
1693[[nodiscard]] constexpr int16_t ExtractIMin(uint32_t raw) noexcept {
1694 return SignExtend10((raw >> IMIN_SHIFT) & IMIN_MASK);
1695}
1696
1698[[nodiscard]] constexpr int16_t ExtractIMax(uint32_t raw) noexcept {
1699 return SignExtend10((raw >> IMAX_SHIFT) & IMAX_MASK);
1700}
1701
1703[[nodiscard]] constexpr int32_t FieldToMilliamps(int16_t field) noexcept {
1704 // I [mA] = field * 4000 / 511 (round toward zero)
1705 return (static_cast<int32_t>(field) * FULL_SCALE_mA) / FULL_SCALE_COUNT;
1706}
1707
1709[[nodiscard]] constexpr int32_t IMin_mA(uint32_t raw) noexcept {
1710 return FieldToMilliamps(ExtractIMin(raw));
1711}
1712
1714[[nodiscard]] constexpr int32_t IMax_mA(uint32_t raw) noexcept {
1715 return FieldToMilliamps(ExtractIMax(raw));
1716}
1717} // namespace FB_IMIN_IMAX
1718
1719//==============================================================================
1720// PER-CHANNEL FEEDBACK HELPERS — FB_DC, FB_I_AVG, FB_VBAT
1721//==============================================================================
1722
1752namespace FB_FEEDBACK {
1753
1754constexpr uint32_t MANT11_MASK = 0x7FFu;
1755constexpr uint32_t TP_MANT_SHIFT = 0u;
1756constexpr uint32_t TO_MANT_SHIFT = 11u;
1757constexpr uint32_t I_AVG_MANT_SHIFT = 0u;
1758constexpr uint32_t VBAT_MANT_SHIFT = 0u;
1759constexpr uint32_t MEAS_EXP_SHIFT = 12u;
1760constexpr uint32_t MEAS_EXP_MASK = 0xFu;
1761
1762constexpr float I_AVG_FULL_SCALE_AMPS = 4.0f;
1763constexpr float VBAT_FULL_SCALE_VOLTS = 41.47f;
1764
1766[[nodiscard]] constexpr int16_t SignExtend11(uint32_t v) noexcept {
1767 const uint32_t masked = v & MANT11_MASK;
1768 return static_cast<int16_t>((masked & 0x400u) ? (masked | 0xFFFFF800u) : masked);
1769}
1770
1772[[nodiscard]] constexpr uint16_t ExtractTpMant(uint32_t fb_dc_raw) noexcept {
1773 return static_cast<uint16_t>((fb_dc_raw >> TP_MANT_SHIFT) & MANT11_MASK);
1774}
1775
1777[[nodiscard]] constexpr uint16_t ExtractToMant(uint32_t fb_dc_raw) noexcept {
1778 return static_cast<uint16_t>((fb_dc_raw >> TO_MANT_SHIFT) & MANT11_MASK);
1779}
1780
1782[[nodiscard]] constexpr int16_t ExtractIAvgMant(uint32_t fb_i_avg_raw) noexcept {
1783 return SignExtend11((fb_i_avg_raw >> I_AVG_MANT_SHIFT) & MANT11_MASK);
1784}
1785
1787[[nodiscard]] constexpr uint8_t ExtractMeasExp(uint32_t fb_vbat_or_iavg_raw) noexcept {
1788 return static_cast<uint8_t>((fb_vbat_or_iavg_raw >> MEAS_EXP_SHIFT) & MEAS_EXP_MASK);
1789}
1790
1795[[nodiscard]] constexpr float ComputeDutyCycle(uint32_t fb_dc_raw) noexcept {
1796 const uint16_t tp = ExtractTpMant(fb_dc_raw);
1797 if (tp == 0) return 0.0f;
1798 return static_cast<float>(ExtractToMant(fb_dc_raw)) / static_cast<float>(tp);
1799}
1800
1812constexpr uint16_t kMinValidTpMant = 64u;
1813
1815[[nodiscard]] constexpr bool HasValidMeasurementWindow(uint32_t fb_dc_raw) noexcept {
1816 return ExtractTpMant(fb_dc_raw) >= kMinValidTpMant;
1817}
1818
1828[[nodiscard]] inline int32_t ComputeAverageCurrent_mA(uint32_t fb_i_avg_raw,
1829 uint32_t fb_dc_raw) noexcept {
1830 const uint16_t tp = ExtractTpMant(fb_dc_raw);
1831 if (tp == 0) return 0;
1832 const int16_t i_mant = ExtractIAvgMant(fb_i_avg_raw);
1833 // Iavg [A] = 4 A × I_AVG_MANT / TP_MANT
1834 // Iavg [mA] = 4000 × I_AVG_MANT / TP_MANT
1835 return static_cast<int32_t>(
1836 (static_cast<int32_t>(i_mant) * 4000) / static_cast<int32_t>(tp));
1837}
1838
1845[[nodiscard]] inline uint32_t ComputeVbatChannel_mV(uint32_t fb_vbat_raw,
1846 uint32_t fb_dc_raw) noexcept {
1847 const uint16_t tp = ExtractTpMant(fb_dc_raw);
1848 if (tp == 0) return 0;
1849 const uint16_t vbat_mant = static_cast<uint16_t>(
1850 (fb_vbat_raw >> VBAT_MANT_SHIFT) & MANT11_MASK);
1851 // VBAT [V] = 41.47 V × VBAT_AVG_MANT / TP_MANT
1852 // VBAT [mV] = 41470 × VBAT_AVG_MANT / TP_MANT
1853 return (static_cast<uint32_t>(vbat_mant) * 41470u)
1854 / static_cast<uint32_t>(tp);
1855}
1856
1857} // namespace FB_FEEDBACK
1858
1859//==============================================================================
1860// FB_I_AVG_s16 REGISTER (Per Channel, offset 0x0204) - High-res signed average
1861//==============================================================================
1862
1890namespace FB_I_AVG_s16 {
1891constexpr uint32_t I_AVG_MASK = 0x0001FFFFu;
1892constexpr uint32_t I_AVG_SIGN_BIT = (1u << 16);
1893constexpr uint32_t TIME_STAMP_SHIFT = 20u;
1894constexpr uint32_t TIME_STAMP_MASK = 0x00300000u;
1895
1896constexpr int32_t FULL_SCALE_mA = 4000;
1897constexpr int32_t FULL_SCALE_COUNT = 65535;
1898
1900[[nodiscard]] constexpr int32_t SignExtend17(uint32_t raw17) noexcept {
1901 const uint32_t m = raw17 & I_AVG_MASK;
1902 return (m & I_AVG_SIGN_BIT) ? static_cast<int32_t>(m | 0xFFFE0000u)
1903 : static_cast<int32_t>(m);
1904}
1905
1913constexpr uint32_t SETTLING_CODE = 0x8000u;
1914
1923[[nodiscard]] constexpr bool IsSettlingFrame(uint32_t reply_22bit) noexcept {
1924 return (reply_22bit & I_AVG_MASK) == SETTLING_CODE;
1925}
1926
1932[[nodiscard]] constexpr int32_t ToMilliamps(uint32_t reply_22bit) noexcept {
1933 const int32_t s = SignExtend17(reply_22bit);
1934 return (s * FULL_SCALE_mA) / FULL_SCALE_COUNT;
1935}
1936
1938[[nodiscard]] constexpr uint8_t ExtractTimestamp(uint32_t reply_22bit) noexcept {
1939 return static_cast<uint8_t>((reply_22bit & TIME_STAMP_MASK) >> TIME_STAMP_SHIFT);
1940}
1941} // namespace FB_I_AVG_s16
1942
1943//==============================================================================
1944// FB_INT_THRESH REGISTER (Per Channel, offset 0x0205) - Integrator Threshold Readback
1945//==============================================================================
1946
1955namespace FB_INT_THRESH {
1956constexpr uint32_t INT_THRESH_MASK = 0x0000FFFFu;
1957
1958[[nodiscard]] constexpr int16_t Extract(uint32_t reply_22bit) noexcept {
1959 return static_cast<int16_t>(reply_22bit & INT_THRESH_MASK);
1960}
1961} // namespace FB_INT_THRESH
1962
1963//==============================================================================
1964// FB_PERIOD_MIN_MAX REGISTER (Per Channel, offset 0x0206) - PWM Period Bounds
1965//==============================================================================
1966
1977namespace FB_PERIOD_MIN_MAX {
1978constexpr uint32_t PERIOD_MIN_MASK = 0x000003FFu;
1979constexpr uint32_t PERIOD_MAX_SHIFT = 10u;
1980constexpr uint32_t PERIOD_MAX_MASK = 0x000FFC00u;
1981constexpr uint32_t TICK_CYCLES = 256u;
1982
1984[[nodiscard]] constexpr uint32_t ToMicroseconds(uint16_t raw_count) noexcept {
1985 // T_us = count * 256 / 28 = count * 64 / 7 (exact)
1986 return (static_cast<uint32_t>(raw_count) * TICK_CYCLES) / 28u;
1987}
1988
1989[[nodiscard]] constexpr uint16_t ExtractMin(uint32_t reply_22bit) noexcept {
1990 return static_cast<uint16_t>(reply_22bit & PERIOD_MIN_MASK);
1991}
1992[[nodiscard]] constexpr uint16_t ExtractMax(uint32_t reply_22bit) noexcept {
1993 return static_cast<uint16_t>((reply_22bit & PERIOD_MAX_MASK) >> PERIOD_MAX_SHIFT);
1994}
1995
1996[[nodiscard]] constexpr uint32_t PeriodMinMicroseconds(uint32_t reply_22bit) noexcept {
1997 return ToMicroseconds(ExtractMin(reply_22bit));
1998}
1999[[nodiscard]] constexpr uint32_t PeriodMaxMicroseconds(uint32_t reply_22bit) noexcept {
2000 return ToMicroseconds(ExtractMax(reply_22bit));
2001}
2002} // namespace FB_PERIOD_MIN_MAX
2003
2004//==============================================================================
2005// HELPER ENUMERATIONS
2006//==============================================================================
2007
2011enum class Channel : uint8_t {
2012 CH0 = 0,
2013 CH1 = 1,
2014 CH2 = 2,
2015 CH3 = 3,
2016 CH4 = 4,
2017 CH5 = 5,
2018
2019 COUNT = 6
2020};
2021
2025enum class ChannelMode : uint8_t {
2026 OFF = 0x0,
2027 ICC = 0x1,
2028 DIRECT_DRIVE_SPI = 0x2,
2029 DIRECT_DRIVE_DRV0 = 0x3,
2030 DIRECT_DRIVE_DRV1 = 0x4,
2031 FREE_RUN_MEAS = 0xC
2032};
2033
2037enum class SlewRate : uint8_t {
2038 SLOW_1V0_US = 0,
2039 MEDIUM_2V5_US = 1,
2040 FAST_5V0_US = 2,
2041 FASTEST_10V0_US = 3
2042};
2043
2047enum class DiagCurrent : uint8_t {
2048 I_80UA = 0,
2049 I_190UA = 1,
2050 I_720UA = 2,
2051 I_1250UA = 3
2052};
2053
2057enum class ParallelPair : uint8_t {
2058 NONE = 0,
2059 CH0_CH3 = 1,
2060 CH1_CH2 = 2,
2061 CH4_CH5 = 3
2062};
2063
2064//==============================================================================
2065// ADDRESS CALCULATION HELPERS
2066//==============================================================================
2067
2084[[nodiscard]] constexpr uint16_t GetChannelBase(Channel channel) noexcept {
2085 switch (channel) {
2086 case Channel::CH0:
2087 return ChannelBase::CH0;
2088 case Channel::CH1:
2089 return ChannelBase::CH1;
2090 case Channel::CH2:
2091 return ChannelBase::CH2;
2092 case Channel::CH3:
2093 return ChannelBase::CH3;
2094 case Channel::CH4:
2095 return ChannelBase::CH4;
2096 case Channel::CH5:
2097 return ChannelBase::CH5;
2098 default:
2099 return 0x0000; // Invalid channel
2100 }
2101}
2102
2109[[nodiscard]] constexpr uint16_t GetChannelRegister(Channel channel, uint16_t offset) noexcept {
2110 return GetChannelBase(channel) + offset;
2111}
2112
2117enum class ExpectedReply : uint8_t {
2118 Bits16,
2119 Bits22
2120};
2121
2143[[nodiscard]] constexpr ExpectedReply ExpectedReplyFor(uint16_t address) noexcept {
2144 if (address == CentralReg::FB_STAT || address == CentralReg::FB_VOLTAGE1 ||
2145 address == CentralReg::FB_VOLTAGE2) {
2146 return ExpectedReply::Bits22;
2147 }
2148 /* Per-channel feedback bank: base (0x20..0x70) + 0x200, offsets +0..+6.
2149 * Every register in the bank answers in reply mode 01B.
2150 *
2151 * Datasheet Rev 1.2 §5.3.3.14–5.3.3.23 draws each of these with a bits-21:16
2152 * row and a six-hex-digit reset value ("00 0000H"), the convention this
2153 * document uses for 22-bit replies; true 16-bit registers (FB_FRZ 0x0007,
2154 * FB_UPD 0x0008) stop at bit 15 and show "0000H". FB_I_AVG_s16 (+4) carries
2155 * TIME_STAMP at 21:20 and FB_INT_THRESH (+5) reserves 21:16, so both are
2156 * 22-bit. Listing them as 16-bit made every read of those two fail the
2157 * reply-width check, burn its retry, and return an error — which is why the
2158 * Iavg16 path looked unusable rather than merely unsuitable for control. */
2159 if (address > CentralReg::FB_VOLTAGE2) {
2160 const uint16_t base = static_cast<uint16_t>((address - 0x0200U) & 0x00F0U);
2161 const uint16_t offset = static_cast<uint16_t>(address & 0x000FU);
2162 const bool in_channel_bank =
2163 (address >= 0x0220U) && (address <= 0x0276U) && (base >= 0x0020U) &&
2164 (base <= 0x0070U) && (offset <= 0x0006U);
2165 if (in_channel_bank) {
2166 return ExpectedReply::Bits22;
2167 }
2168 }
2169 return ExpectedReply::Bits16;
2170}
2171
2175[[nodiscard]] constexpr uint8_t ToIndex(Channel ch) noexcept {
2176 return static_cast<uint8_t>(ch);
2177}
2178
2179//==============================================================================
2180// ENUM TO_STRING HELPERS
2181//==============================================================================
2182
2188[[nodiscard]] inline const char* ToString(ChannelMode mode) noexcept {
2189 switch (mode) {
2190 case ChannelMode::OFF:
2191 return "OFF";
2192 case ChannelMode::ICC:
2193 return "ICC";
2195 return "DIRECT_DRIVE_SPI";
2197 return "DIRECT_DRIVE_DRV0";
2199 return "DIRECT_DRIVE_DRV1";
2201 return "FREE_RUN_MEAS";
2202 default:
2203 return "UNKNOWN";
2204 }
2205}
2206
2212[[nodiscard]] inline const char* ToString(SlewRate rate) noexcept {
2213 switch (rate) {
2215 return "SLOW_1V0_US";
2217 return "MEDIUM_2V5_US";
2219 return "FAST_5V0_US";
2221 return "FASTEST_10V0_US";
2222 default:
2223 return "UNKNOWN";
2224 }
2225}
2226
2232[[nodiscard]] inline const char* ToString(DiagCurrent current) noexcept {
2233 switch (current) {
2235 return "I_80UA";
2237 return "I_190UA";
2239 return "I_720UA";
2241 return "I_1250UA";
2242 default:
2243 return "UNKNOWN";
2244 }
2245}
2246
2252[[nodiscard]] inline const char* ToString(ParallelPair pair) noexcept {
2253 switch (pair) {
2254 case ParallelPair::NONE:
2255 return "NONE";
2257 return "CH0_CH3";
2259 return "CH1_CH2";
2261 return "CH4_CH5";
2262 default:
2263 return "UNKNOWN";
2264 }
2265}
2266
2272[[nodiscard]] inline const char* ToString(Channel channel) noexcept {
2273 switch (channel) {
2274 case Channel::CH0:
2275 return "CH0";
2276 case Channel::CH1:
2277 return "CH1";
2278 case Channel::CH2:
2279 return "CH2";
2280 case Channel::CH3:
2281 return "CH3";
2282 case Channel::CH4:
2283 return "CH4";
2284 case Channel::CH5:
2285 return "CH5";
2286 default:
2287 return "UNKNOWN";
2288 }
2289}
2290
2294[[nodiscard]] constexpr bool IsValidChannel(Channel ch) noexcept {
2295 return ToIndex(ch) < static_cast<uint8_t>(Channel::COUNT);
2296}
2297
2298//==============================================================================
2299// CRC CALCULATION (SAE J1850)
2300//==============================================================================
2301
2314[[nodiscard]] constexpr uint8_t CalculateCrc8J1850(const uint8_t* data,
2315 std::size_t length) noexcept {
2316 constexpr uint8_t POLY = 0x1D;
2317 uint8_t crc = 0xFF;
2318
2319 for (std::size_t i = 0; i < length; ++i) {
2320 crc ^= data[i];
2321 for (uint8_t bit = 0; bit < 8; ++bit) {
2322 if ((crc & 0x80) != 0) {
2323 crc = (crc << 1) ^ POLY;
2324 } else {
2325 crc = (crc << 1);
2326 }
2327 }
2328 }
2329
2330 return crc ^ 0xFF;
2331}
2332
2343[[nodiscard]] inline uint8_t CalculateFrameCrc(const tle92466ed::SPIFrame& frame) noexcept {
2344 static_assert(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__,
2345 "CRC byte sequence (datasheet §5.1.2) assumes little-endian frame storage");
2346 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - Required for hardware register byte access
2347 const auto* bytes = reinterpret_cast<const uint8_t*>(&frame);
2348 // Calculate CRC on bytes 0-2 (excluding CRC byte itself at position 3)
2349 return CalculateCrc8J1850(bytes, 3);
2350}
2351
2357[[nodiscard]] inline bool VerifyFrameCrc(const tle92466ed::SPIFrame& frame) noexcept {
2358 tle92466ed::SPIFrame temp = frame;
2359 uint8_t received_crc = temp.tx_fields.crc;
2360 temp.tx_fields.crc = 0;
2361 uint8_t calculated_crc{}; // Initialize to zero
2362 calculated_crc = CalculateFrameCrc(temp);
2363 return (received_crc == calculated_crc);
2364}
2365
2366//==============================================================================
2367// PHASE 2 / 4 / 5 / 6 - SHARED ENUMS AND STRUCTS
2368//==============================================================================
2369
2373enum class ClockSource : uint8_t {
2376};
2377
2381enum class VioLevel : uint8_t { V3_3 = 0, V5_0 = 1 };
2382
2387 uint16_t vbat_mV{0};
2388 uint16_t vio_mV{0};
2389 uint16_t vdd_mV{0};
2390 float temperature_c{0.0F};
2391};
2392
2396enum class OperationState : uint8_t {
2397 Reset,
2398 Config,
2399 Mission,
2401};
2402
2406enum class FastMeasureMode : uint8_t {
2407 FullPeriod = 0,
2408 HalfPeriod = 1,
2409 QuarterPeriod = 2
2410};
2411
2423
2428 bool done{false};
2429 bool pass{false};
2432 uint16_t raw{0};
2433};
2434
2439 bool drv0{false};
2440 bool drv1{false};
2441 bool en{false};
2442 bool faultn_driver{false};
2443 bool faultn_fb{false};
2444 uint16_t raw{0};
2445};
2446
2453enum class MaskableFault : uint32_t {
2454 // FAULT_MASK0 — per-channel error contribution
2455 Ch0Error = (0u << 24) | (1u << 0),
2456 Ch1Error = (0u << 24) | (1u << 1),
2457 Ch2Error = (0u << 24) | (1u << 2),
2458 Ch3Error = (0u << 24) | (1u << 3),
2459 Ch4Error = (0u << 24) | (1u << 4),
2460 Ch5Error = (0u << 24) | (1u << 5),
2461 EnPin = (0u << 24) | (1u << 13),
2462 SupplyNokInternal = (0u << 24) | (1u << 14),
2463 SupplyNokExternal = (0u << 24) | (1u << 15),
2464 // FAULT_MASK1 — per-channel warning and system warnings
2465 Ch0Warning = (1u << 24) | (1u << 0),
2466 Ch1Warning = (1u << 24) | (1u << 1),
2467 Ch2Warning = (1u << 24) | (1u << 2),
2468 Ch3Warning = (1u << 24) | (1u << 3),
2469 Ch4Warning = (1u << 24) | (1u << 4),
2470 Ch5Warning = (1u << 24) | (1u << 5),
2471 CentralOtWarning = (1u << 24) | (1u << 12),
2472 CentralOtError = (1u << 24) | (1u << 13),
2473 ClockLow = (1u << 24) | (1u << 14),
2474 // FAULT_MASK2 — supply UV/OV + POR-enabled DATA_ERR / SPI_WD
2475 VbatUv = (2u << 24) | (1u << 0),
2476 VbatOv = (2u << 24) | (1u << 1),
2477 VioUv = (2u << 24) | (1u << 2),
2478 VioOv = (2u << 24) | (1u << 3),
2479 VddUv = (2u << 24) | (1u << 4),
2480 VddOv = (2u << 24) | (1u << 5),
2481 DataErr = (2u << 24) | (1u << 14),
2482 SpiWatchdog = (2u << 24) | (1u << 15),
2483};
2484
2486[[nodiscard]] constexpr uint8_t FaultMaskIndex(MaskableFault f) noexcept {
2487 return static_cast<uint8_t>((static_cast<uint32_t>(f) >> 24) & 0x3u);
2488}
2490[[nodiscard]] constexpr uint16_t FaultMaskBit(MaskableFault f) noexcept {
2491 return static_cast<uint16_t>(static_cast<uint32_t>(f) & 0xFFFFu);
2492}
2493
2502 int32_t avg_current_mA{0};
2504 uint32_t avg_vbat_mV{0};
2505 int32_t imin_mA{0};
2506 int32_t imax_mA{0};
2507 uint32_t period_min_us{0};
2508 uint32_t period_max_us{0};
2509 int16_t int_thresh_seed{0};
2510 uint8_t period_seq{0};
2511 uint8_t quad_seq{0};
2512};
2513
2518 bool uv_ov_swap_ok{false};
2519 bool v1v5_uv_ok{false};
2520 bool v1v5_ov_ok{false};
2521 bool ot_test_ok{false};
2522 bool overall_pass{false};
2523};
2524
2525} // namespace tle92466ed
constexpr uint16_t OL_TH_4_8
4/8 of setpoint
Definition tle92466ed_registers.hpp:940
constexpr uint16_t OL_TH_2_8
2/8 of setpoint
Definition tle92466ed_registers.hpp:938
constexpr uint16_t I_DIAG_80UA
80 µA
Definition tle92466ed_registers.hpp:929
constexpr uint16_t SLEWR_1V0_US
1.0 V/µs
Definition tle92466ed_registers.hpp:922
constexpr uint16_t OL_TH_FIXED_SHIFT
Definition tle92466ed_registers.hpp:949
constexpr uint16_t I_DIAG_190UA
190 µA
Definition tle92466ed_registers.hpp:930
constexpr uint16_t OL_TH_5_8
5/8 of setpoint
Definition tle92466ed_registers.hpp:941
constexpr uint16_t SLEWR_5V0_US
5.0 V/µs
Definition tle92466ed_registers.hpp:924
constexpr uint16_t SLEWR_MASK
Slew rate mask.
Definition tle92466ed_registers.hpp:926
constexpr uint16_t OL_TH_FIXED_MASK
Definition tle92466ed_registers.hpp:950
constexpr uint16_t OFF_DIAG_MASK
OFF diag mask.
Definition tle92466ed_registers.hpp:958
constexpr uint8_t OL_TH_VALUE_MASK
OL threshold value mask (3 bits: 0-7)
Definition tle92466ed_registers.hpp:945
constexpr uint16_t OL_TH_6_8
6/8 of setpoint
Definition tle92466ed_registers.hpp:942
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:960
constexpr uint16_t OL_TH_MASK
OL threshold mask.
Definition tle92466ed_registers.hpp:944
constexpr uint16_t OL_TH_1_8
1/8 of setpoint
Definition tle92466ed_registers.hpp:937
constexpr uint16_t OL_TH_7_8
7/8 of setpoint
Definition tle92466ed_registers.hpp:943
constexpr uint16_t I_DIAG_MASK
I_DIAG mask.
Definition tle92466ed_registers.hpp:933
constexpr uint16_t I_DIAG_720UA
720 µA
Definition tle92466ed_registers.hpp:931
constexpr uint16_t OL_TH_3_8
3/8 of setpoint
Definition tle92466ed_registers.hpp:939
constexpr uint16_t OL_TH_DISABLED
OL detection disabled.
Definition tle92466ed_registers.hpp:936
constexpr uint16_t I_DIAG_1250UA
1250 µA
Definition tle92466ed_registers.hpp:932
constexpr uint16_t OFF_DIAG_HS_ONLY
High side current only.
Definition tle92466ed_registers.hpp:957
constexpr uint16_t SLEWR_10V0_US
10.0 V/µs
Definition tle92466ed_registers.hpp:925
constexpr uint16_t SLEWR_2V5_US
2.5 V/µs
Definition tle92466ed_registers.hpp:923
constexpr uint8_t OL_TH_SHIFT
OL threshold shift in register.
Definition tle92466ed_registers.hpp:946
constexpr uint16_t OC_DIAG_EN
OC diag in OFF state.
Definition tle92466ed_registers.hpp:952
constexpr uint16_t OFF_DIAG_LS_ONLY
Low side current only.
Definition tle92466ed_registers.hpp:956
constexpr uint16_t OFF_DIAG_ENABLED
OFF diag enabled.
Definition tle92466ed_registers.hpp:955
constexpr uint16_t Build(uint8_t min_int_thresh, bool olsg_warning_enabled, bool pwm_period_calc_mode) noexcept
Build a complete CTRL value instead of read-modify-writing it.
Definition tle92466ed_registers.hpp:884
constexpr uint16_t MIN_INT_THRESH_MASK
Min threshold mask.
Definition tle92466ed_registers.hpp:835
constexpr uint16_t OLSG_WARN_WINDOW_SHIFT
OLSG window shift.
Definition tle92466ed_registers.hpp:838
constexpr uint8_t MIN_INT_THRESH_FLOOR
Smallest MIN_INT_THRESH that keeps the ICC power stage switching.
Definition tle92466ed_registers.hpp:860
constexpr uint16_t DEFAULT
POR: OLSG_WARN_EN, window 3, MIN_INT_THRESH 0.
Definition tle92466ed_registers.hpp:841
constexpr uint8_t MIN_INT_THRESH_CEIL
Largest MIN_INT_THRESH compatible with the Autolimit constraint.
Definition tle92466ed_registers.hpp:870
constexpr uint16_t PWM_PERIOD_CALC_MODE
PWM calc mode.
Definition tle92466ed_registers.hpp:836
constexpr uint16_t OLSG_WARN_EN
OLSG warn enable.
Definition tle92466ed_registers.hpp:839
constexpr uint16_t DEFAULT_OLSG_WARN_WINDOW
OLSG warning window encoded in the POR value, preserved when rebuilding.
Definition tle92466ed_registers.hpp:844
constexpr uint16_t OLSG_WARN_WINDOW_MASK
OLSG window mask.
Definition tle92466ed_registers.hpp:837
constexpr uint16_t ALL_CH_MASK
All channel bits.
Definition tle92466ed_registers.hpp:216
constexpr uint16_t EN_CH5
Enable Channel 5.
Definition tle92466ed_registers.hpp:210
constexpr uint16_t CH_PAR_1_2
Parallel CH1/CH2.
Definition tle92466ed_registers.hpp:213
constexpr uint16_t ChannelMask(uint8_t channel) noexcept
Get channel enable bit mask.
Definition tle92466ed_registers.hpp:229
constexpr uint16_t EN_CH2
Enable Channel 2.
Definition tle92466ed_registers.hpp:207
constexpr uint16_t OP_MODE
Operation Mode.
Definition tle92466ed_registers.hpp:214
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:219
constexpr uint16_t EN_CH4
Enable Channel 4.
Definition tle92466ed_registers.hpp:209
constexpr uint16_t EN_CH3
Enable Channel 3.
Definition tle92466ed_registers.hpp:208
constexpr uint16_t EN_CH1
Enable Channel 1.
Definition tle92466ed_registers.hpp:206
constexpr uint16_t ALL_PAR_MASK
All parallel bits.
Definition tle92466ed_registers.hpp:217
constexpr uint16_t MISSION_MODE
Mission Mode (OP_MODE=1)
Definition tle92466ed_registers.hpp:224
constexpr uint16_t CH_PAR_4_5
Parallel CH4/CH5.
Definition tle92466ed_registers.hpp:211
constexpr uint16_t CONFIG_MODE
Config Mode (OP_MODE=0)
Definition tle92466ed_registers.hpp:222
constexpr uint16_t EN_CH0
Enable Channel 0.
Definition tle92466ed_registers.hpp:205
constexpr uint16_t CH_PAR_0_3
Parallel CH0/CH3.
Definition tle92466ed_registers.hpp:212
constexpr uint16_t MODE_MASK
Mode mask.
Definition tle92466ed_registers.hpp:985
constexpr uint16_t DIRECT_DRIVE_DRV0
Direct drive via DRV0 pin.
Definition tle92466ed_registers.hpp:982
constexpr uint16_t ICC_CURRENT_CTRL
ICC current control.
Definition tle92466ed_registers.hpp:980
constexpr uint16_t DIRECT_DRIVE_SPI
Direct drive via SPI.
Definition tle92466ed_registers.hpp:981
constexpr uint16_t DIRECT_DRIVE_DRV1
Direct drive via DRV1 pin.
Definition tle92466ed_registers.hpp:983
constexpr uint16_t OFF
Channel off.
Definition tle92466ed_registers.hpp:979
constexpr uint16_t DEFAULT
Default (off)
Definition tle92466ed_registers.hpp:987
constexpr uint16_t FREE_RUN_MEAS
Free running measurement.
Definition tle92466ed_registers.hpp:984
PllConfig CalculatePllFromExternalHz(uint32_t f_clk_hz) noexcept
Definition tle92466ed_registers.hpp:1142
constexpr uint16_t EXT_CLK_BIT
Definition tle92466ed_registers.hpp:1120
constexpr uint16_t PLL_FBDIV_MASK
Definition tle92466ed_registers.hpp:1123
constexpr uint32_t F_SYS_TARGET_HZ
Target fSYS.
Definition tle92466ed_registers.hpp:1125
constexpr uint16_t PLL_REFDIV_SHIFT
Definition tle92466ed_registers.hpp:1121
constexpr uint16_t PLL_REFDIV_MASK
Definition tle92466ed_registers.hpp:1122
constexpr uint16_t BuildExternalPll(uint8_t pll_refdiv, uint16_t pll_fbdiv) noexcept
Pack the external-clock PLL configuration.
Definition tle92466ed_registers.hpp:1128
constexpr uint16_t INTERNAL_OSC
Internal-oscillator configuration (no PLL).
Definition tle92466ed_registers.hpp:1136
constexpr uint16_t DEFAULT
POR per §5.3.3.13.
Definition tle92466ed_registers.hpp:1093
constexpr uint16_t INT_THRESH_MASK
9-bit, bits 8:0
Definition tle92466ed_registers.hpp:1090
constexpr uint16_t INT_THRESH_MAX
Field maximum (511)
Definition tle92466ed_registers.hpp:1091
constexpr uint16_t Build(uint16_t int_thresh) noexcept
Build raw value from a 9-bit integrator threshold.
Definition tle92466ed_registers.hpp:1096
constexpr uint16_t GLOBAL_DIAG2
Global Diagnosis Register 2.
Definition tle92466ed_registers.hpp:30
constexpr uint16_t ICVID
IC Version and ID.
Definition tle92466ed_registers.hpp:59
constexpr uint16_t WD_RELOAD
SPI Watchdog Reload Register.
Definition tle92466ed_registers.hpp:34
constexpr uint16_t FB_VOLTAGE2
Feedback Voltage Register 2.
Definition tle92466ed_registers.hpp:63
constexpr uint16_t DIAG_WARN_CHGR2
Diag Warn CHGR2 (CH4+CH5)
Definition tle92466ed_registers.hpp:50
constexpr uint16_t CHIPID1
Unique Chip ID Register 1.
Definition tle92466ed_registers.hpp:65
constexpr uint16_t FB_FRZ
Feedback Freeze Register.
Definition tle92466ed_registers.hpp:32
constexpr uint16_t DIAG_ERR_CHGR2
Diag Error CHGR2 (CH4+CH5)
Definition tle92466ed_registers.hpp:46
constexpr uint16_t DIAG_ERR_CHGR0
Diag Error CHGR0 (CH0+CH1)
Definition tle92466ed_registers.hpp:44
constexpr uint16_t DIAG_WARN_CHGR0
Diag Warn CHGR0 (CH0+CH1)
Definition tle92466ed_registers.hpp:48
constexpr uint16_t DIAG_ERR_CHGR1
Diag Error CHGR1 (CH2+CH3)
Definition tle92466ed_registers.hpp:45
constexpr uint16_t GLOBAL_CONFIG
Global Configuration Register.
Definition tle92466ed_registers.hpp:27
constexpr uint16_t CHIPID2
Unique Chip ID Register 2.
Definition tle92466ed_registers.hpp:66
constexpr uint16_t VBAT_TH
VBAT Threshold Register.
Definition tle92466ed_registers.hpp:31
constexpr uint16_t SFF_BIST
BIST Register.
Definition tle92466ed_registers.hpp:56
constexpr uint16_t DIAG_WARN_CHGR1
Diag Warn CHGR1 (CH2+CH3)
Definition tle92466ed_registers.hpp:49
constexpr uint16_t FAULT_MASK1
Fault Mask Register 1.
Definition tle92466ed_registers.hpp:53
constexpr uint16_t FAULT_MASK0
Fault Mask Register 0.
Definition tle92466ed_registers.hpp:52
constexpr uint16_t GLOBAL_DIAG0
Global Diagnosis Register 0.
Definition tle92466ed_registers.hpp:28
constexpr uint16_t CLK_DIV
Clock Control Register.
Definition tle92466ed_registers.hpp:55
constexpr uint16_t CHIPID0
Unique Chip ID Register 0.
Definition tle92466ed_registers.hpp:64
constexpr uint16_t FB_UPD
Feedback Update Register.
Definition tle92466ed_registers.hpp:33
constexpr uint16_t FB_STAT
Feedback Status Register.
Definition tle92466ed_registers.hpp:61
constexpr uint16_t FAULT_MASK2
Fault Mask Register 2.
Definition tle92466ed_registers.hpp:54
constexpr uint16_t GLOBAL_DIAG1
Global Diagnosis Register 1.
Definition tle92466ed_registers.hpp:29
constexpr uint16_t FB_VOLTAGE1
Feedback Voltage Register 1.
Definition tle92466ed_registers.hpp:62
constexpr uint16_t CH_CTRL
Channel Control Register.
Definition tle92466ed_registers.hpp:26
constexpr uint16_t PIN_STAT
Pin Status Register.
Definition tle92466ed_registers.hpp:60
constexpr uint16_t CH1
Channel 1 base address.
Definition tle92466ed_registers.hpp:144
constexpr uint16_t CH5
Channel 5 base address.
Definition tle92466ed_registers.hpp:148
constexpr uint16_t CH3
Channel 3 base address.
Definition tle92466ed_registers.hpp:146
constexpr uint16_t CH0
Channel 0 base address.
Definition tle92466ed_registers.hpp:143
constexpr uint16_t CH2
Channel 2 base address.
Definition tle92466ed_registers.hpp:145
constexpr uint16_t CH4
Channel 4 base address.
Definition tle92466ed_registers.hpp:147
constexpr uint16_t FB_I_AVG_s16
Feedback signed Current (16-bit)
Definition tle92466ed_registers.hpp:170
constexpr uint16_t FB_IMIN_IMAX
Feedback Min/Max Current.
Definition tle92466ed_registers.hpp:169
constexpr uint16_t DITHER_STEP
Dither Step Register.
Definition tle92466ed_registers.hpp:160
constexpr uint16_t INTEGRATOR_LIMIT
ICC Integrator Limitation.
Definition tle92466ed_registers.hpp:158
constexpr uint16_t DITHER_CTRL
Dither Control Register.
Definition tle92466ed_registers.hpp:161
constexpr uint16_t FB_VBAT
Feedback Average VBAT.
Definition tle92466ed_registers.hpp:167
constexpr uint16_t PERIOD
ICC PWM Frequency Controller.
Definition tle92466ed_registers.hpp:157
constexpr uint16_t CH_CONFIG
Channel Configuration.
Definition tle92466ed_registers.hpp:162
constexpr uint16_t CTRL_INT_THRESH
ICC Integrator Threshold.
Definition tle92466ed_registers.hpp:165
constexpr uint16_t FB_DC
Feedback Duty Cycle.
Definition tle92466ed_registers.hpp:166
constexpr uint16_t TON
On-Time Register.
Definition tle92466ed_registers.hpp:164
constexpr uint16_t SETPOINT
Current Setpoint Register.
Definition tle92466ed_registers.hpp:155
constexpr uint16_t FB_I_AVG
Feedback Average Current.
Definition tle92466ed_registers.hpp:168
constexpr uint16_t DITHER_CLK_DIV
Dither Clock Register.
Definition tle92466ed_registers.hpp:159
constexpr uint16_t FB_PERIOD_MIN_MAX
Feedback Min/Max PWM Period.
Definition tle92466ed_registers.hpp:172
constexpr uint16_t CTRL
Control Register.
Definition tle92466ed_registers.hpp:156
constexpr uint16_t FB_INT_THRESH
Feedback ICC Integrator Threshold.
Definition tle92466ed_registers.hpp:171
constexpr uint16_t MODE
Channel Mode Register.
Definition tle92466ed_registers.hpp:163
constexpr uint8_t BIT_OTE
Channel overtemperature error.
Definition tle92466ed_registers.hpp:423
constexpr uint16_t AddressForChannel(uint8_t channel) noexcept
Register address for the group covering a channel.
Definition tle92466ed_registers.hpp:432
constexpr uint16_t PER_CHANNEL_MASK
5-bit mask of all error bits for one channel (before 8*y shift).
Definition tle92466ed_registers.hpp:426
constexpr uint16_t OC_BOTH_MASK
16-bit mask of both-channel OC bits in a group (bits 2 and 10).
Definition tle92466ed_registers.hpp:429
constexpr uint8_t YShiftForChannel(uint8_t channel) noexcept
Bit shift (0 or 8) selecting the channel within its group.
Definition tle92466ed_registers.hpp:437
constexpr uint16_t OcClearMaskForChannel(uint8_t channel) noexcept
Clear mask writing 1s only to the OC bit(s) of the affected channel.
Definition tle92466ed_registers.hpp:447
constexpr uint8_t BIT_OL
Open-Load.
Definition tle92466ed_registers.hpp:420
constexpr uint8_t BIT_SG
Short-to-Ground.
Definition tle92466ed_registers.hpp:422
constexpr uint8_t BIT_OLSG
Open-Load / Short-to-Ground.
Definition tle92466ed_registers.hpp:419
constexpr uint16_t ChannelBitMask(uint8_t channel, uint8_t bit_index) noexcept
Build a single-bit test mask for a given channel and bit index.
Definition tle92466ed_registers.hpp:442
constexpr uint8_t BIT_OC
Overcurrent (double-clear)
Definition tle92466ed_registers.hpp:421
constexpr uint16_t AddressForChannel(uint8_t channel) noexcept
Register address for the group covering a channel.
Definition tle92466ed_registers.hpp:479
constexpr uint8_t BIT_I_REG
Definition tle92466ed_registers.hpp:471
constexpr uint8_t BIT_OTW
Definition tle92466ed_registers.hpp:472
constexpr uint16_t ChannelBitMask(uint8_t channel, uint8_t bit_index) noexcept
Build a single-bit test mask for a given channel and bit index.
Definition tle92466ed_registers.hpp:489
constexpr uint8_t BIT_OLSG_WARN
Definition tle92466ed_registers.hpp:473
constexpr uint16_t PER_CHANNEL_MASK
Definition tle92466ed_registers.hpp:476
constexpr uint8_t BIT_PWM_REG
Definition tle92466ed_registers.hpp:470
constexpr uint8_t BIT_OLSG_CHK_NOK
Definition tle92466ed_registers.hpp:474
constexpr uint8_t YShiftForChannel(uint8_t channel) noexcept
Bit shift (0 or 8) selecting the channel within its group.
Definition tle92466ed_registers.hpp:484
constexpr uint16_t DITHER_SETPOINT_SYNC_EN_BIT
Definition tle92466ed_registers.hpp:1327
constexpr uint16_t DITHER_PWM_SYNC_EN_BIT
Definition tle92466ed_registers.hpp:1326
constexpr uint32_t F_SYS_HZ
System clock (28 MHz, §4.2.1)
Definition tle92466ed_registers.hpp:1329
constexpr uint16_t EXP_MASK
4-bit exponent mask
Definition tle92466ed_registers.hpp:1324
constexpr uint8_t EXP_VALUE_MASK
Exponent value (4 bits)
Definition tle92466ed_registers.hpp:1325
constexpr uint16_t EXP_SHIFT
Exponent bit position.
Definition tle92466ed_registers.hpp:1323
ClkDivConfig CalculateFromTrefClkUs(float t_ref_clk_us) noexcept
Pick MANT/EXP that approximate a desired tref_clk in microseconds.
Definition tle92466ed_registers.hpp:1367
constexpr float F_SYS_PERIOD_US
1 / fSYS (µs, ≈35.71 ns)
Definition tle92466ed_registers.hpp:1330
constexpr uint16_t MANT_MASK
10-bit mantissa mask
Definition tle92466ed_registers.hpp:1322
constexpr uint16_t FAST_MEAS_DITH
Dither period.
Definition tle92466ed_registers.hpp:1262
constexpr uint16_t DEEP_DITHER
Deep dither enable.
Definition tle92466ed_registers.hpp:1261
constexpr uint16_t STEP_SIZE_MASK
Step size mask.
Definition tle92466ed_registers.hpp:1260
constexpr uint16_t FAST_MEAS_MASK
Fast meas mask.
Definition tle92466ed_registers.hpp:1265
constexpr uint16_t FAST_MEAS_HALF
Half dither period.
Definition tle92466ed_registers.hpp:1263
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:1267
constexpr uint16_t FAST_MEAS_QUAD
Quarter dither period.
Definition tle92466ed_registers.hpp:1264
constexpr uint16_t STEPS_MASK
Steps mask.
Definition tle92466ed_registers.hpp:1286
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:1288
constexpr uint16_t STEPS_SHIFT
Steps shift.
Definition tle92466ed_registers.hpp:1285
constexpr uint16_t FLAT_MASK
Flat period mask.
Definition tle92466ed_registers.hpp:1284
constexpr float DEFAULT_T_REF_CLK_US
tref_clk at MANT=1, EXP=0 (≈35.71 ns)
Definition tle92466ed_registers.hpp:1415
DitherConfig CalculateFromAmplitudeFrequency(float amplitude_ma, float frequency_hz, bool parallel_mode=false, float t_ref_clk_us=DEFAULT_T_REF_CLK_US) noexcept
Calculate dither configuration from amplitude and frequency.
Definition tle92466ed_registers.hpp:1464
constexpr float F_SYS_HZ
System clock frequency (28 MHz)
Definition tle92466ed_registers.hpp:1414
constexpr uint8_t GetRevision(uint16_t icvid) noexcept
Extract silicon revision from ICVID.
Definition tle92466ed_registers.hpp:118
constexpr uint16_t DEVICE_TYPE_MASK
Device type mask [15:8].
Definition tle92466ed_registers.hpp:84
constexpr uint8_t MIN_REVISION
Minimum silicon revision.
Definition tle92466ed_registers.hpp:94
constexpr uint8_t GetDeviceType(uint16_t icvid) noexcept
Extract device type from ICVID.
Definition tle92466ed_registers.hpp:111
constexpr uint16_t REVISION_MASK
Silicon revision mask [7:0].
Definition tle92466ed_registers.hpp:85
constexpr uint8_t EXPECTED_TYPE_92466ED
Expected manufacturer/type byte.
Definition tle92466ed_registers.hpp:91
constexpr bool IsValidDevice(uint16_t icvid) noexcept
Check if ICVID value is valid for TLE92466ED.
Definition tle92466ed_registers.hpp:101
constexpr uint16_t DEFAULT
Definition tle92466ed_registers.hpp:1221
constexpr uint16_t SUP_NOK_INT_MASK
Definition tle92466ed_registers.hpp:1219
constexpr uint16_t CH_ERR_MASK
Per-channel error (CH0..5)
Definition tle92466ed_registers.hpp:1217
constexpr uint16_t EN_PIN_MASK
Definition tle92466ed_registers.hpp:1218
constexpr uint16_t SUP_NOK_EXT_MASK
Definition tle92466ed_registers.hpp:1220
constexpr uint16_t DEFAULT
Definition tle92466ed_registers.hpp:1229
constexpr uint16_t CLK_LOW_MASK
Definition tle92466ed_registers.hpp:1228
constexpr uint16_t COTWARN_MASK
Definition tle92466ed_registers.hpp:1226
constexpr uint16_t CH_WARN_MASK
Per-channel warning (CH0..5)
Definition tle92466ed_registers.hpp:1225
constexpr uint16_t COTERR_MASK
Definition tle92466ed_registers.hpp:1227
constexpr uint16_t VBAT_OV_MASK
Definition tle92466ed_registers.hpp:1234
constexpr uint16_t DATA_ERR_MASK
FB_STAT.DATA_err → FAULTN.
Definition tle92466ed_registers.hpp:1239
constexpr uint16_t VBAT_UV_MASK
Definition tle92466ed_registers.hpp:1233
constexpr uint16_t VDD_UV_MASK
Definition tle92466ed_registers.hpp:1237
constexpr uint16_t SPI_WD_MASK
SPI watchdog → FAULTN.
Definition tle92466ed_registers.hpp:1240
constexpr uint16_t VDD_OV_MASK
Definition tle92466ed_registers.hpp:1238
constexpr uint16_t DEFAULT
Definition tle92466ed_registers.hpp:1242
constexpr uint16_t VIO_UV_MASK
Definition tle92466ed_registers.hpp:1235
constexpr uint16_t VIO_OV_MASK
Definition tle92466ed_registers.hpp:1236
constexpr float VBAT_FULL_SCALE_VOLTS
VBAT formula scale (41.47 V)
Definition tle92466ed_registers.hpp:1763
constexpr uint32_t TP_MANT_SHIFT
FB_DC: TP_MANT in [10:0].
Definition tle92466ed_registers.hpp:1755
constexpr bool HasValidMeasurementWindow(uint32_t fb_dc_raw) noexcept
True when FB_DC reports a measurement period usable for ratio decoding.
Definition tle92466ed_registers.hpp:1815
constexpr int16_t ExtractIAvgMant(uint32_t fb_i_avg_raw) noexcept
Extract signed I_AVG_MANT (11-bit two's-complement) from FB_I_AVG.
Definition tle92466ed_registers.hpp:1782
int32_t ComputeAverageCurrent_mA(uint32_t fb_i_avg_raw, uint32_t fb_dc_raw) noexcept
Compute average current in mA (signed) from FB_I_AVG and FB_DC.
Definition tle92466ed_registers.hpp:1828
uint32_t ComputeVbatChannel_mV(uint32_t fb_vbat_raw, uint32_t fb_dc_raw) noexcept
Compute averaged battery voltage in mV from FB_VBAT and FB_DC.
Definition tle92466ed_registers.hpp:1845
constexpr uint32_t VBAT_MANT_SHIFT
FB_VBAT: VBAT_AVG_MANT in [10:0].
Definition tle92466ed_registers.hpp:1758
constexpr uint32_t MEAS_EXP_MASK
4-bit exponent mask
Definition tle92466ed_registers.hpp:1760
constexpr uint8_t ExtractMeasExp(uint32_t fb_vbat_or_iavg_raw) noexcept
Extract the 4-bit measurement exponent from FB_VBAT or FB_I_AVG.
Definition tle92466ed_registers.hpp:1787
constexpr float I_AVG_FULL_SCALE_AMPS
Iavg formula scale (4 A)
Definition tle92466ed_registers.hpp:1762
constexpr uint16_t ExtractTpMant(uint32_t fb_dc_raw) noexcept
Extract TP_MANT (Period Mantissa, 11 bits unsigned) from a raw FB_DC read.
Definition tle92466ed_registers.hpp:1772
constexpr uint32_t I_AVG_MANT_SHIFT
FB_I_AVG: I_AVG_MANT in [10:0].
Definition tle92466ed_registers.hpp:1757
constexpr uint16_t ExtractToMant(uint32_t fb_dc_raw) noexcept
Extract TO_MANT (On-time Mantissa, 11 bits unsigned) from a raw FB_DC read.
Definition tle92466ed_registers.hpp:1777
constexpr uint16_t kMinValidTpMant
Smallest TP_MANT that makes the mantissa-ratio formula meaningful.
Definition tle92466ed_registers.hpp:1812
constexpr uint32_t MEAS_EXP_SHIFT
FB_VBAT/FB_I_AVG: EXP in [15:12].
Definition tle92466ed_registers.hpp:1759
constexpr int16_t SignExtend11(uint32_t v) noexcept
Sign-extend an 11-bit two's-complement value into int16_t.
Definition tle92466ed_registers.hpp:1766
constexpr uint32_t TO_MANT_SHIFT
FB_DC: TO_MANT in [21:11].
Definition tle92466ed_registers.hpp:1756
constexpr uint32_t MANT11_MASK
11-bit mantissa mask
Definition tle92466ed_registers.hpp:1754
constexpr float ComputeDutyCycle(uint32_t fb_dc_raw) noexcept
Compute duty cycle (0.0 – 1.0) from a raw FB_DC value.
Definition tle92466ed_registers.hpp:1795
constexpr int32_t FULL_SCALE_mA
Definition tle92466ed_registers.hpp:1896
constexpr uint32_t TIME_STAMP_SHIFT
Definition tle92466ed_registers.hpp:1893
constexpr uint32_t I_AVG_SIGN_BIT
Definition tle92466ed_registers.hpp:1892
constexpr uint32_t TIME_STAMP_MASK
2-bit
Definition tle92466ed_registers.hpp:1894
constexpr int32_t FULL_SCALE_COUNT
Definition tle92466ed_registers.hpp:1897
constexpr uint32_t I_AVG_MASK
17-bit
Definition tle92466ed_registers.hpp:1891
constexpr int32_t SignExtend17(uint32_t raw17) noexcept
Sign-extend the 17-bit signed field.
Definition tle92466ed_registers.hpp:1900
constexpr uint32_t SETTLING_CODE
Raw code the frame carries before a measurement has settled.
Definition tle92466ed_registers.hpp:1913
constexpr int32_t ToMilliamps(uint32_t reply_22bit) noexcept
Decode signed 17-bit raw to milliamps.
Definition tle92466ed_registers.hpp:1932
constexpr bool IsSettlingFrame(uint32_t reply_22bit) noexcept
True when the frame is the pre-measurement placeholder.
Definition tle92466ed_registers.hpp:1923
constexpr uint8_t ExtractTimestamp(uint32_t reply_22bit) noexcept
Extract the 2-bit rolling timestamp.
Definition tle92466ed_registers.hpp:1938
constexpr int16_t ExtractIMin(uint32_t raw) noexcept
Extract signed 10-bit IMIN field from raw FB_IMIN_IMAX read.
Definition tle92466ed_registers.hpp:1693
constexpr uint32_t IMAX_MASK
Definition tle92466ed_registers.hpp:1682
constexpr int32_t FieldToMilliamps(int16_t field) noexcept
Convert a signed 10-bit IMIN/IMAX field value to milliamperes.
Definition tle92466ed_registers.hpp:1703
constexpr int32_t IMax_mA(uint32_t raw) noexcept
Decode IMAX in mA from a raw FB_IMIN_IMAX read.
Definition tle92466ed_registers.hpp:1714
constexpr uint32_t IMIN_MASK
Definition tle92466ed_registers.hpp:1680
constexpr int32_t IMin_mA(uint32_t raw) noexcept
Decode IMIN in mA from a raw FB_IMIN_IMAX read.
Definition tle92466ed_registers.hpp:1709
constexpr int16_t ExtractIMax(uint32_t raw) noexcept
Extract signed 10-bit IMAX field from raw FB_IMIN_IMAX read.
Definition tle92466ed_registers.hpp:1698
constexpr uint32_t IMAX_SHIFT
Definition tle92466ed_registers.hpp:1681
constexpr int32_t FULL_SCALE_mA
Definition tle92466ed_registers.hpp:1683
constexpr uint32_t IMIN_SHIFT
Definition tle92466ed_registers.hpp:1679
constexpr int32_t FULL_SCALE_COUNT
Definition tle92466ed_registers.hpp:1684
constexpr int16_t SignExtend10(uint32_t v) noexcept
Sign-extend a 10-bit two's-complement field to int16_t.
Definition tle92466ed_registers.hpp:1687
constexpr uint32_t INT_THRESH_MASK
Definition tle92466ed_registers.hpp:1956
constexpr int16_t Extract(uint32_t reply_22bit) noexcept
Definition tle92466ed_registers.hpp:1958
constexpr uint32_t TICK_CYCLES
Definition tle92466ed_registers.hpp:1981
constexpr uint16_t ExtractMax(uint32_t reply_22bit) noexcept
Definition tle92466ed_registers.hpp:1992
constexpr uint32_t PERIOD_MAX_MASK
Definition tle92466ed_registers.hpp:1980
constexpr uint32_t ToMicroseconds(uint16_t raw_count) noexcept
Convert a raw 10-bit count to microseconds (fSYS = 28 MHz).
Definition tle92466ed_registers.hpp:1984
constexpr uint32_t PERIOD_MIN_MASK
Definition tle92466ed_registers.hpp:1978
constexpr uint32_t PERIOD_MAX_SHIFT
Definition tle92466ed_registers.hpp:1979
constexpr uint32_t PeriodMinMicroseconds(uint32_t reply_22bit) noexcept
Definition tle92466ed_registers.hpp:1996
constexpr uint16_t ExtractMin(uint32_t reply_22bit) noexcept
Definition tle92466ed_registers.hpp:1989
constexpr uint32_t PeriodMaxMicroseconds(uint32_t reply_22bit) noexcept
Definition tle92466ed_registers.hpp:1999
constexpr uint32_t DIAG_WARN_CHGR1
DIAG_WARN_CHGR1 status.
Definition tle92466ed_registers.hpp:540
constexpr uint32_t DIAG_WARN_CHGR2
DIAG_WARN_CHGR2 status.
Definition tle92466ed_registers.hpp:541
constexpr uint32_t INIT_DONE
Chip initialization done.
Definition tle92466ed_registers.hpp:557
constexpr uint32_t POR_EVENT
Power-on reset event.
Definition tle92466ed_registers.hpp:549
constexpr uint32_t OLSG_WARN_CHK_NOK_CHGR1
OL/SG check group 1.
Definition tle92466ed_registers.hpp:543
constexpr uint32_t ERR_CHGR0
DIAG_ERR_CHGR1 status.
Definition tle92466ed_registers.hpp:553
constexpr uint32_t SUP_NOK_INT
Internal rail UV or OV.
Definition tle92466ed_registers.hpp:552
constexpr uint32_t SPI_WD_ERR
SPI watchdog error status.
Definition tle92466ed_registers.hpp:556
constexpr uint32_t CLK_NOK_STAT
Clock fault status.
Definition tle92466ed_registers.hpp:545
constexpr uint32_t OLSG_WARN_CHK_NOK_CHGR0
OL/SG check group 0.
Definition tle92466ed_registers.hpp:542
constexpr uint32_t COTWARN
Central overtemperature warning.
Definition tle92466ed_registers.hpp:547
constexpr uint32_t DATA_ERR
OTP_ECC_ERR / OTP_VIRGIN / HV_ADC_ERR.
Definition tle92466ed_registers.hpp:550
constexpr uint32_t DIAG_WARN_CHGR0
DIAG_WARN_CHGR0 status.
Definition tle92466ed_registers.hpp:539
constexpr uint32_t ERR_CHGR2
DIAG_ERR_CHGR3 status.
Definition tle92466ed_registers.hpp:555
constexpr uint32_t OLSG_WARN_CHK_NOK_CHGR2
OL/SG check group 2.
Definition tle92466ed_registers.hpp:544
constexpr uint32_t SUP_NOK_EXT
VIO/VDD/VBAT UV or OV.
Definition tle92466ed_registers.hpp:551
constexpr uint32_t RES_EVENT
Reset event (RESN pin)
Definition tle92466ed_registers.hpp:548
constexpr uint32_t ERR_CHGR1
DIAG_ERR_CHGR2 status.
Definition tle92466ed_registers.hpp:554
constexpr uint32_t COTERR
Central overtemperature error.
Definition tle92466ed_registers.hpp:546
constexpr uint16_t VIO_SEL
VIO select (0=3.3V, 1=5V)
Definition tle92466ed_registers.hpp:266
constexpr uint16_t V1V5_OV_TEST
1.5V OV test
Definition tle92466ed_registers.hpp:263
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:268
constexpr uint16_t CLK_WD_EN
Clock watchdog enable.
Definition tle92466ed_registers.hpp:259
constexpr uint16_t V1V5_UV_TEST
1.5V UV test
Definition tle92466ed_registers.hpp:262
constexpr uint16_t CRC_EN
CRC check enable.
Definition tle92466ed_registers.hpp:261
constexpr uint16_t OT_TEST
Over-temp test.
Definition tle92466ed_registers.hpp:264
constexpr uint16_t UV_OV_SWAP
UV/OV swap test.
Definition tle92466ed_registers.hpp:265
constexpr uint16_t SPI_WD_EN
SPI watchdog enable.
Definition tle92466ed_registers.hpp:260
constexpr uint16_t CLK_NOK
Clock fault.
Definition tle92466ed_registers.hpp:306
constexpr uint16_t VBAT_UV
VBAT undervoltage.
Definition tle92466ed_registers.hpp:300
constexpr uint16_t VBAT_OV
VBAT overvoltage.
Definition tle92466ed_registers.hpp:301
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:313
constexpr uint16_t SPI_WD_ERR
SPI watchdog error.
Definition tle92466ed_registers.hpp:311
constexpr uint16_t RES_EVENT
Reset event.
Definition tle92466ed_registers.hpp:309
constexpr uint16_t POR_EVENT
Power-on reset.
Definition tle92466ed_registers.hpp:310
constexpr uint16_t VDD_OV
VDD overvoltage.
Definition tle92466ed_registers.hpp:305
constexpr uint16_t COTERR
Central OT error.
Definition tle92466ed_registers.hpp:307
constexpr uint16_t VIO_UV
VIO undervoltage.
Definition tle92466ed_registers.hpp:302
constexpr uint16_t VDD_UV
VDD undervoltage.
Definition tle92466ed_registers.hpp:304
constexpr uint16_t FAULT_MASK
All fault bits.
Definition tle92466ed_registers.hpp:314
constexpr uint16_t COTWARN
Central OT warning.
Definition tle92466ed_registers.hpp:308
constexpr uint16_t VIO_OV
VIO overvoltage.
Definition tle92466ed_registers.hpp:303
constexpr uint16_t CLEAR_ALL
Clear all bits (write-to-clear)
Definition tle92466ed_registers.hpp:315
constexpr uint16_t VR_IREF_OV
Bias current OV.
Definition tle92466ed_registers.hpp:385
constexpr uint16_t VPRE_OV
Pre-reg OV.
Definition tle92466ed_registers.hpp:390
constexpr uint16_t VDD2V5_UV
2.5V supply UV
Definition tle92466ed_registers.hpp:386
constexpr uint16_t REF_UV
Reference UV.
Definition tle92466ed_registers.hpp:388
constexpr uint16_t HVADC_ERR
HV ADC error.
Definition tle92466ed_registers.hpp:391
constexpr uint16_t VR_IREF_UV
Bias current UV.
Definition tle92466ed_registers.hpp:384
constexpr uint16_t CLEAR_ALL
Clear all bits (write-to-clear)
Definition tle92466ed_registers.hpp:394
constexpr uint16_t VDD2V5_OV
2.5V supply OV
Definition tle92466ed_registers.hpp:387
constexpr uint16_t REF_OV
Reference OV.
Definition tle92466ed_registers.hpp:389
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:393
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:515
constexpr uint16_t CLEAR_ALL
Clear all bits (write-to-clear)
Definition tle92466ed_registers.hpp:516
constexpr uint16_t OTP_VIRGIN
1 = virgin OTP address (must be 0)
Definition tle92466ed_registers.hpp:513
constexpr uint16_t OTP_ECC_ERR
Non-repairable OTP multi-bit flip.
Definition tle92466ed_registers.hpp:512
constexpr uint16_t REG_ECC_ERR
Multi-bit flip in a register.
Definition tle92466ed_registers.hpp:511
constexpr uint16_t AUTO_LIM_VALUE_ABS_SHIFT
Definition tle92466ed_registers.hpp:1038
constexpr uint16_t Build(uint16_t lim_value_abs, uint8_t auto_lim_value_abs) noexcept
Definition tle92466ed_registers.hpp:1054
constexpr uint16_t AUTO_LIM_VALUE_ABS_MASK
5-bit
Definition tle92466ed_registers.hpp:1039
constexpr uint16_t DEFAULT
Definition tle92466ed_registers.hpp:1052
constexpr uint16_t LIM_VALUE_ABS_MASK
10-bit
Definition tle92466ed_registers.hpp:1037
constexpr uint16_t LOW_FREQ_BIT
Low frequency range bit.
Definition tle92466ed_registers.hpp:695
constexpr float kSpecLowRangeMinFreq_Hz
13.75 Hz
Definition tle92466ed_registers.hpp:726
constexpr uint16_t BuildRegisterValue(const PeriodConfig &config) noexcept
Build PERIOD register value from configuration.
Definition tle92466ed_registers.hpp:813
constexpr uint16_t PWM_CTRL_PARAM_SHIFT
Definition tle92466ed_registers.hpp:699
constexpr float kSpecMinPeriod_us
250 µs
Definition tle92466ed_registers.hpp:723
constexpr float kSpecMinFrequency_Hz
Datasheet minimum f_PWM.
Definition tle92466ed_registers.hpp:721
constexpr uint16_t MANT_MASK
Mantissa mask (bits 7:0)
Definition tle92466ed_registers.hpp:691
constexpr float F_SYS_PERIOD_US
System clock period (≈35.71 ns)
Definition tle92466ed_registers.hpp:703
constexpr uint16_t EXP_SHIFT
Exponent shift.
Definition tle92466ed_registers.hpp:693
PeriodConfig CalculateFromPeriodUs(float period_us) noexcept
Calculate period configuration from desired period in microseconds.
Definition tle92466ed_registers.hpp:772
constexpr float kSpecMaxFrequency_Hz
Datasheet maximum f_PWM.
Definition tle92466ed_registers.hpp:722
constexpr uint16_t EXP_MASK
Exponent mask (bits 10:8)
Definition tle92466ed_registers.hpp:692
constexpr float kSpecLowRangeMaxFreq_Hz
500 Hz
Definition tle92466ed_registers.hpp:727
constexpr uint8_t EXP_VALUE_MASK
Exponent value mask (3 bits: 0-7)
Definition tle92466ed_registers.hpp:694
constexpr float kSpecCombinedMinPeriod_us
Combined min period across both ranges (250 µs).
Definition tle92466ed_registers.hpp:734
constexpr float kSpecLowRangeMinPeriod_us
2000 µs
Definition tle92466ed_registers.hpp:728
constexpr float kSpecMaxPeriod_us
9090.9 µs
Definition tle92466ed_registers.hpp:724
constexpr float kSpecCombinedMaxPeriod_us
Combined max period across both ranges (low-range 72.7 ms).
Definition tle92466ed_registers.hpp:736
constexpr uint16_t PWM_CTRL_PARAM_MASK
Definition tle92466ed_registers.hpp:700
constexpr uint32_t F_SYS_HZ
System clock frequency (28 MHz)
Definition tle92466ed_registers.hpp:702
constexpr float kSpecLowRangeMaxPeriod_us
72727 µs
Definition tle92466ed_registers.hpp:730
constexpr uint16_t EN
Definition tle92466ed_registers.hpp:1199
constexpr uint16_t DRV0
Definition tle92466ed_registers.hpp:1197
constexpr uint16_t FAULTN
Definition tle92466ed_registers.hpp:1200
constexpr uint16_t DRV1
Definition tle92466ed_registers.hpp:1198
constexpr uint16_t FAULTN_FB
Definition tle92466ed_registers.hpp:1201
constexpr uint16_t CalculateTargetUa(uint32_t current_ua, bool parallel_mode=false) noexcept
Calculate setpoint value for a desired current in microamperes.
Definition tle92466ed_registers.hpp:630
constexpr uint16_t CalculateTarget(uint16_t current_ma, bool parallel_mode=false) noexcept
Calculate setpoint value for desired current.
Definition tle92466ed_registers.hpp:610
constexpr uint16_t AUTO_LIMIT_DIS
Disable auto-limit.
Definition tle92466ed_registers.hpp:595
constexpr uint16_t CalculateCurrent(uint16_t target, bool parallel_mode=false) noexcept
Calculate current from setpoint value.
Definition tle92466ed_registers.hpp:648
constexpr uint16_t DEFAULT
Default (0A)
Definition tle92466ed_registers.hpp:597
constexpr uint16_t TARGET_MASK
Target current mask.
Definition tle92466ed_registers.hpp:594
constexpr uint16_t MAX_TARGET
Maximum safe target value (datasheet saturates above 0x6000)
Definition tle92466ed_registers.hpp:600
constexpr uint16_t EN
Definition tle92466ed_registers.hpp:1171
constexpr uint16_t DEFAULT
Definition tle92466ed_registers.hpp:1177
constexpr uint16_t FAIL
Definition tle92466ed_registers.hpp:1173
constexpr uint16_t DONE
Definition tle92466ed_registers.hpp:1172
constexpr uint16_t UERR
Definition tle92466ed_registers.hpp:1174
constexpr uint16_t CERR
Definition tle92466ed_registers.hpp:1175
constexpr uint16_t OLSG_TIMEOUT_SHIFT
OLSG timeout shift.
Definition tle92466ed_registers.hpp:1008
constexpr uint16_t Build(uint16_t ton_mant, uint8_t olsg_timeout) noexcept
Pack TON_MANT + OLSG_TIMEOUT into the raw register value.
Definition tle92466ed_registers.hpp:1014
constexpr uint16_t DEFAULT
POR default.
Definition tle92466ed_registers.hpp:1011
constexpr uint16_t OLSG_TIMEOUT_MASK
6-bit OLSG timeout mask
Definition tle92466ed_registers.hpp:1009
constexpr uint16_t TON_MANT_MASK
10-bit mantissa mask
Definition tle92466ed_registers.hpp:1007
constexpr float LSB_VOLTAGE
Voltage per LSB (0.16208V)
Definition tle92466ed_registers.hpp:1524
constexpr float MIN_VOLTAGE
Minimum voltage (0V)
Definition tle92466ed_registers.hpp:1525
constexpr float MAX_VOLTAGE
Maximum voltage (255 × 0.16208V)
Definition tle92466ed_registers.hpp:1526
constexpr uint8_t CalculateFromVoltage(float voltage_volts) noexcept
Calculate register value from voltage.
Definition tle92466ed_registers.hpp:1533
constexpr float CalculateVoltage(uint8_t register_value) noexcept
Calculate voltage from register value.
Definition tle92466ed_registers.hpp:1549
constexpr uint32_t VDD_SHIFT
VDD is in bits [21:11].
Definition tle92466ed_registers.hpp:1577
constexpr float TemperatureCelsiusFromRaw(uint16_t temp_value) noexcept
Convert a raw TEMP_VALUE (11-bit) to die temperature in \u00b0C.
Definition tle92466ed_registers.hpp:1640
constexpr uint32_t VBAT_SHIFT
VBAT is in bits [21:11].
Definition tle92466ed_registers.hpp:1583
constexpr float VIO_VDD_LSB_VOLTAGE
Voltage per LSB for VIO/VDD (0.0034534V)
Definition tle92466ed_registers.hpp:1575
constexpr uint16_t ExtractVddMillivolts(uint32_t register_value) noexcept
Extract VDD voltage from FB_VOLTAGE1 register (22-bit value)
Definition tle92466ed_registers.hpp:1601
constexpr uint16_t ExtractVioMillivolts(uint32_t register_value) noexcept
Extract VIO voltage from FB_VOLTAGE1 register (22-bit value)
Definition tle92466ed_registers.hpp:1590
constexpr uint16_t ExtractVbatMillivolts(uint32_t register_value) noexcept
Extract VBAT voltage from FB_VOLTAGE2 register (22-bit value)
Definition tle92466ed_registers.hpp:1612
constexpr float VBAT_MAX_VOLTAGE
Maximum VBAT voltage (41.47V)
Definition tle92466ed_registers.hpp:1580
constexpr uint16_t ExtractTemperatureRaw(uint32_t register_value) noexcept
Extract temperature value from FB_VOLTAGE2 register (22-bit value)
Definition tle92466ed_registers.hpp:1624
constexpr float TemperatureCelsiusFromFbVoltage2(uint32_t register_value) noexcept
Convert a raw 22-bit FB_VOLTAGE2 read to die temperature in \u00b0C.
Definition tle92466ed_registers.hpp:1651
constexpr uint32_t VIO_VDD_MASK
11-bit mask (bits 10:0)
Definition tle92466ed_registers.hpp:1576
constexpr uint32_t VBAT_MAX_COUNT
Maximum count (2^11 - 1)
Definition tle92466ed_registers.hpp:1581
constexpr uint32_t VBAT_MASK
11-bit mask (bits 10:0)
Definition tle92466ed_registers.hpp:1582
constexpr uint16_t DEFAULT
Default value.
Definition tle92466ed_registers.hpp:347
constexpr uint16_t WD_TIME_MASK
11-bit mask for WD_TIME field (bits 10:0)
Definition tle92466ed_registers.hpp:345
constexpr uint16_t WD_TIME_MAX
Maximum WD_TIME value (2047)
Definition tle92466ed_registers.hpp:346
constexpr uint16_t MaskValue(uint16_t value) noexcept
Mask WD_TIME value to valid 11-bit range.
Definition tle92466ed_registers.hpp:354
Definition tle92466ed.hpp:15
constexpr uint8_t ToIndex(Channel ch) noexcept
Convert channel to index.
Definition tle92466ed_registers.hpp:2175
constexpr uint16_t GetChannelRegister(Channel channel, uint16_t offset) noexcept
Get channel register address.
Definition tle92466ed_registers.hpp:2109
const char * ToString(ChannelMode mode) noexcept
Convert ChannelMode enum to string.
Definition tle92466ed_registers.hpp:2188
ChannelMode
Channel operation mode.
Definition tle92466ed_registers.hpp:2025
@ DIRECT_DRIVE_DRV0
Direct drive via DRV0 pin.
@ DIRECT_DRIVE_DRV1
Direct drive via DRV1 pin.
@ FREE_RUN_MEAS
Free running measurement mode.
@ DIRECT_DRIVE_SPI
Direct drive via SPI TON register.
@ ICC
Integrated Current Control.
bool VerifyFrameCrc(const tle92466ed::SPIFrame &frame) noexcept
Verify CRC in received frame.
Definition tle92466ed_registers.hpp:2357
constexpr uint16_t GetChannelBase(Channel channel) noexcept
Get channel base address.
Definition tle92466ed_registers.hpp:2084
constexpr bool IsValidChannel(Channel ch) noexcept
Validate channel number.
Definition tle92466ed_registers.hpp:2294
FastMeasureMode
Fast-measurement mode for dither-synchronous feedback.
Definition tle92466ed_registers.hpp:2406
@ QuarterPeriod
Measurement window = quarter dither period.
@ HalfPeriod
Measurement window = half dither period.
@ FullPeriod
Measurement window = full dither period.
MaskableFault
Maskable fault sources for SetFaultMask().
Definition tle92466ed_registers.hpp:2453
@ CentralOtError
Central OT error → FAULTN.
@ Ch1Warning
CH1 warning → FAULTN.
@ Ch5Error
CH5 error → FAULTN.
@ EnPin
EN pin fault → FAULTN.
@ Ch1Error
CH1 error → FAULTN.
@ Ch0Error
CH0 error → FAULTN.
@ Ch2Error
CH2 error → FAULTN.
@ SupplyNokExternal
External supply NOK → FAULTN.
@ DataErr
OTP/REG DATA_err → FAULTN (do not mask to hide LED)
@ Ch5Warning
CH5 warning → FAULTN.
@ VbatUv
VBAT undervoltage → FAULTN.
@ Ch0Warning
CH0 warning → FAULTN.
@ VddOv
VDD overvoltage → FAULTN.
@ Ch3Warning
CH3 warning → FAULTN.
@ ClockLow
Clock too slow → FAULTN.
@ VddUv
VDD undervoltage → FAULTN.
@ VbatOv
VBAT overvoltage → FAULTN.
@ Ch4Error
CH4 error → FAULTN.
@ CentralOtWarning
Central OT warning → FAULTN.
@ Ch3Error
CH3 error → FAULTN.
@ VioUv
VIO undervoltage → FAULTN.
@ SpiWatchdog
SPI watchdog → FAULTN.
@ Ch4Warning
CH4 warning → FAULTN.
@ SupplyNokInternal
Internal supply NOK → FAULTN.
@ Ch2Warning
CH2 warning → FAULTN.
@ VioOv
VIO overvoltage → FAULTN.
ExpectedReply
Reply-frame width a register is required to answer with.
Definition tle92466ed_registers.hpp:2117
@ Bits16
Reply mode 00B — 16-bit data plus a status field.
@ Bits22
Reply mode 01B — 22-bit data, no status field.
VioLevel
VIO voltage-level selection for SetVioLevel().
Definition tle92466ed_registers.hpp:2381
ClockSource
Clock source selection for ConfigureClockSource().
Definition tle92466ed_registers.hpp:2373
@ InternalOscillator
Use internal ring oscillator (fSYS \u2248 28 MHz \u00b1 10 %)
@ ExternalClockPll
Use external clock on DRV0 or dedicated pin, synth via PLL.
OperationState
Coarse operational state returned by GetOperationState().
Definition tle92466ed_registers.hpp:2396
@ CriticalFault
Critical-fault reply flag set; requires reset/clear.
@ Reset
Held in reset (RESN low)
@ Mission
Outputs operational.
@ Config
Powered and initialized, but not in mission mode.
constexpr uint8_t FaultMaskIndex(MaskableFault f) noexcept
Extract FAULT_MASK register index (0..2) from a MaskableFault value.
Definition tle92466ed_registers.hpp:2486
ParallelPair
Parallel operation pairs.
Definition tle92466ed_registers.hpp:2057
@ CH4_CH5
Channels 4 and 5 paralleled.
@ CH1_CH2
Channels 1 and 2 paralleled.
@ NONE
No parallel operation.
@ CH0_CH3
Channels 0 and 3 paralleled.
constexpr uint8_t CalculateCrc8J1850(const uint8_t *data, std::size_t length) noexcept
Calculate SAE J1850 CRC-8.
Definition tle92466ed_registers.hpp:2314
DiagCurrent
OFF-state diagnostic current.
Definition tle92466ed_registers.hpp:2047
constexpr ExpectedReply ExpectedReplyFor(uint16_t address) noexcept
Reply width the device must use when answering a read of address.
Definition tle92466ed_registers.hpp:2143
uint8_t CalculateFrameCrc(const tle92466ed::SPIFrame &frame) noexcept
Calculate CRC for SPI frame.
Definition tle92466ed_registers.hpp:2343
Channel
Channel enumeration.
Definition tle92466ed_registers.hpp:2011
@ COUNT
Number of channels (not a valid channel selector)
SlewRate
Slew rate enumeration.
Definition tle92466ed_registers.hpp:2037
@ FAST_5V0_US
5.0 V/µs
@ SLOW_1V0_US
1.0 V/µs
@ FASTEST_10V0_US
10.0 V/µs
@ MEDIUM_2V5_US
2.5 V/µs
constexpr uint16_t FaultMaskBit(MaskableFault f) noexcept
Extract the bit mask within the target FAULT_MASK register.
Definition tle92466ed_registers.hpp:2490
Result of RunSffBist().
Definition tle92466ed_registers.hpp:2427
bool uncorrectable_reg_err
Definition tle92466ed_registers.hpp:2430
bool pass
BIST passed (fail==0)
Definition tle92466ed_registers.hpp:2429
bool correctable_reg_err
Definition tle92466ed_registers.hpp:2431
bool done
BIST completed.
Definition tle92466ed_registers.hpp:2428
uint16_t raw
Raw SFF_BIST register value for debug.
Definition tle92466ed_registers.hpp:2432
Definition tle92466ed_registers.hpp:1141
uint32_t actual_f_sys_hz
Definition tle92466ed_registers.hpp:1141
uint8_t refdiv
Definition tle92466ed_registers.hpp:1141
uint16_t fbdiv
Definition tle92466ed_registers.hpp:1141
High-resolution per-channel feedback snapshot (Phase 6).
Definition tle92466ed_registers.hpp:2501
uint16_t duty_cycle_permyriad
Duty cycle 0..10000 (= 0.00..100.00 %)
Definition tle92466ed_registers.hpp:2503
int32_t imin_mA
Minimum current in measurement window (mA)
Definition tle92466ed_registers.hpp:2505
int32_t imax_mA
Maximum current in measurement window (mA)
Definition tle92466ed_registers.hpp:2506
uint8_t period_seq
Measurement exponent sequence (from FB_I_AVG EXP)
Definition tle92466ed_registers.hpp:2510
uint32_t avg_vbat_mV
Channel-referenced VBAT average (mV)
Definition tle92466ed_registers.hpp:2504
uint32_t period_min_us
Shortest PWM period observed (µs)
Definition tle92466ed_registers.hpp:2507
int16_t int_thresh_seed
Current ICC integrator threshold readback.
Definition tle92466ed_registers.hpp:2509
int32_t avg_current_mA
Average current from FB_I_AVG/FB_DC ratio (mA, signed)
Definition tle92466ed_registers.hpp:2502
uint8_t quad_seq
Quarter-period sequence counter (reserved)
Definition tle92466ed_registers.hpp:2511
uint32_t period_max_us
Longest PWM period observed (µs)
Definition tle92466ed_registers.hpp:2508
Dither configuration structure.
Definition tle92466ed_registers.hpp:1420
uint8_t flat_steps
Flat period steps at top/bottom (0-255)
Definition tle92466ed_registers.hpp:1423
constexpr float CalculateAmplitudeMa(bool parallel_mode=false) const noexcept
Calculate dither amplitude in mA.
Definition tle92466ed_registers.hpp:1430
uint8_t num_steps
Number of steps in quarter period (0-255)
Definition tle92466ed_registers.hpp:1422
constexpr float CalculatePeriodUs(float t_ref_clk_us=DEFAULT_T_REF_CLK_US) const noexcept
Calculate dither period in microseconds.
Definition tle92466ed_registers.hpp:1443
uint16_t step_size
Dither step size (0-4095)
Definition tle92466ed_registers.hpp:1421
Encoded DITHER_CLK_DIV configuration.
Definition tle92466ed_registers.hpp:1333
bool dither_pwm_sync_en
DITHER_PWM_SYNC_EN.
Definition tle92466ed_registers.hpp:1336
constexpr float CalculateTrefClkUs() const noexcept
Compute the resulting tref_clk in microseconds.
Definition tle92466ed_registers.hpp:1340
uint16_t mantissa
MANT field (0..1023)
Definition tle92466ed_registers.hpp:1334
bool dither_setpoint_sync_en
DITHER_SETPOINT_SYNC_EN.
Definition tle92466ed_registers.hpp:1337
constexpr uint16_t ToRegister() const noexcept
Pack into the raw 16-bit register value.
Definition tle92466ed_registers.hpp:1347
uint8_t exponent
EXP field (0..15)
Definition tle92466ed_registers.hpp:1335
High-level dither configuration (Phase 4 superset of ConfigureDither).
Definition tle92466ed_registers.hpp:2415
FastMeasureMode fast_measure
Feedback averaging window.
Definition tle92466ed_registers.hpp:2421
bool deep_dither
Enable deep-dither (extended amplitude range)
Definition tle92466ed_registers.hpp:2420
bool sync_with_pwm
Restart dither on each PWM rising edge.
Definition tle92466ed_registers.hpp:2418
float amplitude_mA
Peak-to-peak dither amplitude in mA.
Definition tle92466ed_registers.hpp:2416
bool sync_with_setpoint
Restart dither on setpoint change.
Definition tle92466ed_registers.hpp:2419
float frequency_Hz
Dither frequency in Hz.
Definition tle92466ed_registers.hpp:2417
Calculate PWM period register values from desired period in microseconds.
Definition tle92466ed_registers.hpp:751
bool low_freq_range
Low frequency range enabled.
Definition tle92466ed_registers.hpp:754
uint8_t exponent
Period exponent (0-7)
Definition tle92466ed_registers.hpp:753
constexpr float CalculatePeriodUs() const noexcept
Calculate actual period from register values.
Definition tle92466ed_registers.hpp:760
uint8_t mantissa
Period mantissa (0-255)
Definition tle92466ed_registers.hpp:752
Snapshot returned by ReadPinStatus().
Definition tle92466ed_registers.hpp:2438
uint16_t raw
Raw PIN_STAT register value.
Definition tle92466ed_registers.hpp:2444
bool faultn_driver
FAULTN output as driven by the IC (PIN_STAT bit 5)
Definition tle92466ed_registers.hpp:2442
bool faultn_fb
External FAULTN line feedback (PIN_STAT bit 6)
Definition tle92466ed_registers.hpp:2443
bool drv1
DRV1 input pin level (PIN_STAT bit 1)
Definition tle92466ed_registers.hpp:2440
bool drv0
DRV0 input pin level (PIN_STAT bit 0)
Definition tle92466ed_registers.hpp:2439
bool en
EN input pin level (PIN_STAT bit 4)
Definition tle92466ed_registers.hpp:2441
Result of RunSupplyMonitorSelfTest().
Definition tle92466ed_registers.hpp:2517
bool v1v5_ov_ok
Definition tle92466ed_registers.hpp:2520
bool overall_pass
Definition tle92466ed_registers.hpp:2522
bool uv_ov_swap_ok
Definition tle92466ed_registers.hpp:2518
bool v1v5_uv_ok
Definition tle92466ed_registers.hpp:2519
bool ot_test_ok
Definition tle92466ed_registers.hpp:2521
High-level supply-voltage snapshot returned by ReadAllSupplyVoltages().
Definition tle92466ed_registers.hpp:2386
uint16_t vdd_mV
Internal analog supply in millivolts.
Definition tle92466ed_registers.hpp:2389
uint16_t vbat_mV
Battery supply in millivolts.
Definition tle92466ed_registers.hpp:2387
uint16_t vio_mV
Logic supply in millivolts.
Definition tle92466ed_registers.hpp:2388
float temperature_c
Central die temperature in \u00b0C.
Definition tle92466ed_registers.hpp:2390
32-bit SPI frame structure for TLE92466ED communication
Definition tle92466ed_spi_interface.hpp:200
uint32_t crc
CRC-8 SAE J1850 [31:24].
Definition tle92466ed_spi_interface.hpp:208
struct tle92466ed::SPIFrame::@0 tx_fields
MOSI (Transmit) frame structure.