TLE92466ED Driver 0.1.0
API reference
Loading...
Searching...
No Matches
tle92466ed_types.hpp
Go to the documentation of this file.
1
13#ifndef TLE92466ED_TYPES_HPP
14#define TLE92466ED_TYPES_HPP
15
16#include <array>
17#include <cstdint>
18
19#include "tle92466ed_detail.hpp"
20#include "tle92466ed_version.h"
21
23namespace tle92466ed {
24
37enum class [[nodiscard]] Error : uint8_t {
38 // Base set: the same names and values in every driver of the org (standards/driver.md).
39 Ok = 0,
40 NotInitialized = 1,
42 InvalidArgument = 2,
43 Bus = 3,
45 Timeout = 4,
48 Crc = 6,
50 Busy = 7,
51 DeviceFault = 8,
53 Unsupported = 9,
55 // Chip-specific values start at 16; each one is returned by some call (tests/test_errors.cpp).
56 NoDevice = 16,
58 CriticalFault = 17,
62 ReplyMismatch = 18,
65 FrameRejected = 19,
67 WrongState = 20,
71 MissionBlocked = 21,
74 WriteMismatch = 22,
76 NotReady = 23,
78 UnexpectedReset = 24,
80};
81
87constexpr const char* ToString(Error error) noexcept {
88 switch (error) {
89 case Error::Ok:
90 return "Ok";
92 return "NotInitialized";
94 return "InvalidArgument";
95 case Error::Bus:
96 return "Bus";
97 case Error::Timeout:
98 return "Timeout";
100 return "DeviceIdMismatch";
101 case Error::Crc:
102 return "Crc";
103 case Error::Busy:
104 return "Busy";
106 return "DeviceFault";
108 return "Unsupported";
109 case Error::NoDevice:
110 return "NoDevice";
112 return "CriticalFault";
114 return "ReplyMismatch";
116 return "FrameRejected";
118 return "WrongState";
120 return "MissionBlocked";
122 return "WriteMismatch";
123 case Error::NotReady:
124 return "NotReady";
126 return "UnexpectedReset";
127 default:
128 break;
129 }
130 return "Unknown";
131}
132
140template <typename T>
141struct [[nodiscard]] Result {
142 T value{};
143 Error error{Error::Ok};
144
146 [[nodiscard]] constexpr bool ok() const noexcept {
147 return error == Error::Ok;
148 }
150 constexpr explicit operator bool() const noexcept {
151 return ok();
152 }
153
159 static constexpr Result Success(T v) noexcept {
160 return {v, Error::Ok};
161 }
167 static constexpr Result Failure(Error e) noexcept {
168 return {T{}, e};
169 }
170};
171
173template <>
174struct [[nodiscard]] Result<void> {
175 Error error{Error::Ok};
176
178 [[nodiscard]] constexpr bool ok() const noexcept {
179 return error == Error::Ok;
180 }
182 constexpr explicit operator bool() const noexcept {
183 return ok();
184 }
185
187 static constexpr Result Success() noexcept {
188 return {Error::Ok};
189 }
195 static constexpr Result Failure(Error e) noexcept {
196 return {e};
197 }
198};
199
201enum class LogLevel : uint8_t {
202 Error = 0,
203 Warning,
204 Info,
205 Debug,
206};
207
211enum class Verify : uint8_t {
212 None = 0,
213 ReadBack = 1,
214};
215
217enum class Channel : uint8_t {
218 Ch0 = 0,
219 Ch1 = 1,
220 Ch2 = 2,
221 Ch3 = 3,
222 Ch4 = 4,
223 Ch5 = 5,
224};
226inline constexpr uint32_t kChannelCount = 6U;
227
229enum class ParallelPair : uint8_t {
230 Ch0Ch3 = 0,
231 Ch1Ch2 = 1,
232 Ch4Ch5 = 2,
233};
235inline constexpr uint32_t kPairCount = 3U;
236
238enum class ChannelMode : uint8_t {
239 Off = 0,
240 CurrentControl = 1,
241 DirectDriveSpi = 2,
242 DirectDriveDrv0 = 3,
243 DirectDriveDrv1 = 4,
244 Measurement = 5,
245};
246
248enum class SlewRate : uint8_t {
249 VPerUs1 = 0,
250 VPerUs2p5 = 1,
251 VPerUs5 = 2,
252 VPerUs10 = 3,
253};
254
256enum class DiagCurrent : uint8_t {
257 Ua80 = 0,
258 Ua190 = 1,
259 Ua720 = 2,
260 Ua1250 = 3,
261};
262
264enum class OffStateDiag : uint8_t {
265 Enabled = 0,
266 LowSideSource = 1,
267 HighSideSource = 2,
268 Disabled = 3,
269};
270
272enum class FastFeedback : uint8_t {
273 DitherPeriod = 0,
274 HalfPeriod = 1,
275 QuarterPeriod = 2,
276};
277
279enum class VioLevel : uint8_t {
280 V3V3 = 0,
281 V5V0 = 1,
282};
283
285enum class ClockSource : uint8_t {
286 Internal = 0,
287 External = 1,
288};
289
294struct IccConfig {
295 int8_t min_int_thresh{0};
298 uint8_t period_mant{0};
299 uint8_t period_exp{0};
300 bool low_freq_range{false};
301 uint8_t ki{0};
302 uint16_t limit{1023};
303 uint8_t auto_limit{16};
305 bool auto_limit_disable{false};
306 uint16_t int_thresh{3};
307};
308
316 uint16_t mant{0};
317 uint8_t exp{0};
318 bool pwm_sync{false};
319 bool setpoint_sync{false};
320 uint8_t steps{0};
321 uint8_t flat{0};
322 uint16_t step_size{0};
323 bool deep{false};
325};
326
343
357
364 uint8_t channel_errors{0x3FU};
365 uint8_t channel_warnings{0x3FU};
366 bool en_pin{false};
367 bool supply_internal{true};
368 bool supply_external{true};
370 bool central_ot_error{true};
371 bool clock_too_slow{true};
372 bool data_error{true};
373 bool spi_watchdog{true};
374};
375
382struct Config {
385 bool crc_check{true};
387 bool clock_watchdog{true};
388 bool spi_watchdog{false};
389 uint16_t watchdog_reload{1};
393 uint32_t external_clock_khz{0};
395 uint8_t vbat_uv_code{0x19U};
396 uint8_t vbat_ov_code{0xFFU};
398 std::array<bool, kPairCount> parallel{};
399 std::array<ChannelConfig, kChannelCount> channels{};
400 uint32_t init_timeout_us{10000};
402 uint8_t max_retries{2};
404};
405
408
410inline constexpr uint32_t kMaxSetpointUa = 1'500'000U;
412inline constexpr uint32_t kMaxSetpointWithDitherUa = 1'800'000U;
415inline constexpr uint32_t kParallelMeasurementRangeUa = 2'700'000U;
419inline constexpr uint32_t kMaxParallelSetpointUa = (kParallelMeasurementRangeUa / 10U) * 9U;
420static_assert(kMaxParallelSetpointUa == 2'430'000U);
422inline constexpr uint32_t kSetpointFullScaleUa = 2'000'000U;
424inline constexpr uint32_t kParallelFullScaleUa = 4'000'000U;
426inline constexpr uint32_t kTargetMax = 32767U;
428inline constexpr uint32_t kInternalClockHz = 28'000'000U;
430inline constexpr uint32_t kMinSystemClockHz = 27'500'000U;
432inline constexpr uint32_t kMaxSystemClockHz = 28'500'000U;
434inline constexpr uint32_t kMinPwmHz = 110U;
436inline constexpr uint32_t kMaxPwmHz = 4000U;
438inline constexpr uint16_t kMaxWatchdogReload = 2047U;
442inline constexpr uint16_t kMinWatchdogReload = 9U;
444inline constexpr uint32_t kWatchdogDivider = 16384U;
446inline constexpr uint32_t kMaxOcOnTimeUs = 300'000U;
448inline constexpr uint32_t kResetReleaseUs = 100U;
450inline constexpr uint32_t kPowerOnResetUs = 10'000U;
453inline constexpr uint32_t kResetPulseUs = 1000U;
455inline constexpr uint32_t kPollIntervalUs = 100U;
457inline constexpr uint32_t kMinInitTimeoutUs = 100U;
459inline constexpr uint32_t kMaxInitTimeoutUs = 100'000U;
462inline constexpr uint32_t kBistTimeoutUs = 10'000U;
464inline constexpr uint8_t kMaxRetries = 3U;
466inline constexpr uint8_t kManufacturerId = 0xC1U;
468inline constexpr uint8_t kVersionA11 = 0xFCU;
470inline constexpr uint8_t kVersionA13 = 0xFEU;
472
478enum class GlobalFault : uint8_t {
479 VbatUndervoltage = 0x00U,
480 VbatOvervoltage = 0x01U,
481 VioUndervoltage = 0x02U,
482 VioOvervoltage = 0x03U,
483 VddUndervoltage = 0x04U,
484 VddOvervoltage = 0x05U,
485 ClockFault = 0x06U,
486 CentralOtError = 0x07U,
487 CentralOtWarning = 0x08U,
488 SpiWatchdog = 0x0EU,
489 BiasCurrentLow = 0x10U,
490 BiasCurrentHigh = 0x11U,
491 Supply2v5Low = 0x12U,
492 Supply2v5High = 0x13U,
493 ReferenceLow = 0x14U,
494 ReferenceHigh = 0x15U,
495 PreRegulatorHigh = 0x16U,
496 MonitorAdc = 0x1FU,
497 RegisterEcc = 0x21U,
498 OtpEcc = 0x23U,
499 OtpVirgin = 0x24U,
500};
501
504 bool olsg{false};
505 bool open_load{false};
506 bool overcurrent{false};
507 bool short_to_ground{false};
508 bool overtemperature{false};
509 bool pwm_regulation{false};
510 bool current_regulation{false};
512 bool olsg_warning{false};
513 bool olsg_check_skipped{false};
514
516 [[nodiscard]] constexpr bool AnyError() const noexcept {
518 }
520 friend constexpr bool operator==(const ChannelFaults& lhs,
521 const ChannelFaults& rhs) noexcept = default;
522};
523
528struct Faults {
529 std::array<uint16_t, 3> global{};
530 std::array<uint16_t, 3> errors{};
531 std::array<uint16_t, 3> warnings{};
532
538 [[nodiscard]] constexpr bool Has(GlobalFault fault) const noexcept {
539 const auto code = static_cast<uint32_t>(detail::ToUnderlying(fault));
540 const uint32_t index = (code >> 4U) % 3U;
541 return ((static_cast<uint32_t>(global[index]) >> (code & 0x0FU)) & 1U) != 0U;
542 }
543
549 [[nodiscard]] constexpr ChannelFaults Of(Channel channel) const noexcept {
550 const auto ch = static_cast<uint32_t>(detail::ToUnderlying(channel)) % kChannelCount;
551 const uint32_t shift = 8U * (ch % 2U);
552 const uint32_t e = (static_cast<uint32_t>(errors[ch / 2U]) >> shift) & 0xFFU;
553 const uint32_t w = (static_cast<uint32_t>(warnings[ch / 2U]) >> shift) & 0xFFU;
554 ChannelFaults f{};
555 f.olsg = (e & 0x01U) != 0U;
556 f.open_load = (e & 0x02U) != 0U;
557 f.overcurrent = (e & 0x04U) != 0U;
558 f.short_to_ground = (e & 0x08U) != 0U;
559 f.overtemperature = (e & 0x10U) != 0U;
560 f.pwm_regulation = (w & 0x01U) != 0U;
561 f.current_regulation = (w & 0x02U) != 0U;
562 f.overtemperature_warning = (w & 0x04U) != 0U;
563 f.olsg_warning = (w & 0x08U) != 0U;
564 f.olsg_check_skipped = (w & 0x10U) != 0U;
565 return f;
566 }
567
572 [[nodiscard]] constexpr bool Any() const noexcept {
573 uint32_t bits = (static_cast<uint32_t>(global[0]) & 0x41FFU) |
574 (static_cast<uint32_t>(global[1]) & 0x807FU) |
575 (static_cast<uint32_t>(global[2]) & 0x001AU);
576 for (uint32_t g = 0U; g < 3U; ++g) {
577 bits |= static_cast<uint32_t>(errors[g]) & 0x1F1FU;
578 bits |= static_cast<uint32_t>(warnings[g]) & 0x0F0FU;
579 }
580 return bits != 0U;
581 }
582
584 friend constexpr bool operator==(const Faults& lhs, const Faults& rhs) noexcept = default;
585};
586
589 bool init_done{false};
590 bool spi_watchdog_error{false};
591 bool clock_fault{false};
592 bool central_ot_error{false};
593 bool central_ot_warning{false};
594 bool reset_event{false};
595 bool power_on_event{false};
596 bool data_error{false};
597 bool supply_external{false};
598 bool supply_internal{false};
599 uint8_t error_groups{0};
600 uint8_t warning_groups{0};
602 uint32_t raw{0};
603};
604
607 uint32_t vio_mv{0};
608 uint32_t vdd_mv{0};
609 uint32_t vbat_mv{0};
610 int32_t temperature_mc{0};
612};
613
615struct PinStatus {
616 bool drv0{false};
617 bool drv1{false};
618 bool enable{false};
619 bool fault{false};
620 bool faultn_high{false};
621};
622
625 bool passed{false};
627 bool correctable_tested{false};
628};
629
631struct ChipId {
632 std::array<uint16_t, 3> words{};
634 friend constexpr bool operator==(const ChipId& lhs, const ChipId& rhs) noexcept = default;
635};
636
644 uint32_t duty_permyriad{0};
645 uint32_t vbat_mv{0};
646 uint32_t period_us{0};
647 int32_t min_current_ua{0};
648 int32_t max_current_ua{0};
649 uint32_t min_pwm_period_ns{0};
650 uint32_t max_pwm_period_ns{0};
651 uint8_t period_count{0};
652 uint8_t quad_count{0};
653};
654
657 uint32_t frames{0};
658 uint32_t retries{0};
659 uint32_t rejected_replies{0};
660 uint32_t resyncs{0};
661};
662
665
672[[nodiscard]] constexpr uint32_t SystemClockHz(const Config& config) noexcept;
673
679[[nodiscard]] constexpr uint32_t PllRefDiv(uint32_t khz) noexcept {
680 return khz / 1000U;
681}
682
689[[nodiscard]] constexpr uint32_t PllFbDiv(uint32_t khz) noexcept {
690 return (khz == 0U) ? 0U : (((56'000U * PllRefDiv(khz)) + (khz / 2U)) / khz);
691}
692
693constexpr uint32_t SystemClockHz(const Config& config) noexcept {
694 if (config.clock == ClockSource::Internal) {
695 return kInternalClockHz;
696 }
697 const uint32_t khz = config.external_clock_khz;
698 if ((khz < 1000U) || (khz > 8000U)) {
699 return 0U;
700 }
701 return static_cast<uint32_t>((static_cast<uint64_t>(khz) * 1000U * PllFbDiv(khz)) /
702 (uint64_t{2} * PllRefDiv(khz)));
703}
704
711[[nodiscard]] constexpr uint32_t TargetFromMicroamps(uint32_t microamps, bool parallel) noexcept {
712 const uint64_t scale = parallel ? kParallelFullScaleUa : kSetpointFullScaleUa;
713 const uint64_t target = ((static_cast<uint64_t>(microamps) * kTargetMax) + (scale / 2U)) / scale;
714 return (target > kTargetMax) ? kTargetMax : static_cast<uint32_t>(target);
715}
716
723[[nodiscard]] constexpr uint32_t MicroampsFromTarget(uint32_t target, bool parallel) noexcept {
724 const uint64_t scale = parallel ? kParallelFullScaleUa : kSetpointFullScaleUa;
725 return static_cast<uint32_t>(
726 (((static_cast<uint64_t>(target) & kTargetMax) * scale) + (kTargetMax / 2U)) / kTargetMax);
727}
728
735[[nodiscard]] constexpr uint32_t DitherAmplitudeUa(const DitherConfig& dither,
736 bool parallel) noexcept {
737 const uint32_t counts = static_cast<uint32_t>(dither.steps) * dither.step_size;
738 return MicroampsFromTarget((counts > kTargetMax) ? kTargetMax : counts, parallel);
739}
740
748[[nodiscard]] constexpr uint32_t PwmFrequencyHz(const IccConfig& icc, uint32_t system_hz) noexcept {
749 if (icc.period_mant == 0U) {
750 return 0U;
751 }
752 const uint32_t cycles = (static_cast<uint32_t>(icc.period_mant) << (icc.period_exp & 0x07U)) *
753 (icc.low_freq_range ? 8U : 1U);
754 return system_hz / cycles;
755}
756
763[[nodiscard]] constexpr Result<uint16_t> WatchdogReloadCode(uint32_t timeout_ms,
764 uint32_t system_hz) noexcept {
765 const uint64_t code =
766 (static_cast<uint64_t>(timeout_ms) * system_hz) / (uint64_t{1000} * kWatchdogDivider);
767 if ((code == 0U) || (code > kMaxWatchdogReload)) {
769 }
770 return Result<uint16_t>::Success(static_cast<uint16_t>(code));
771}
772
779[[nodiscard]] constexpr Result<uint8_t> VbatThresholdCode(uint32_t millivolts) noexcept {
780 const uint64_t code = ((static_cast<uint64_t>(millivolts) * 100U) + 8104U) / 16208U;
781 if (code > 0xFFU) {
783 }
784 return Result<uint8_t>::Success(static_cast<uint8_t>(code));
785}
787
788// Table 10: every row's dividers and f_SYS within Table 6.
789static_assert((PllRefDiv(1500U) == 1U) && (PllFbDiv(1500U) == 37U));
790static_assert((PllRefDiv(2500U) == 2U) && (PllFbDiv(2500U) == 45U));
791static_assert((PllRefDiv(4500U) == 4U) && (PllFbDiv(4500U) == 50U));
792static_assert((PllRefDiv(6500U) == 6U) && (PllFbDiv(6500U) == 52U));
793static_assert((PllRefDiv(7500U) == 7U) && (PllFbDiv(7500U) == 52U));
794static_assert((PllRefDiv(8000U) == 8U) && (PllFbDiv(8000U) == 56U));
795// The reset value of CLK_DIV (0x0438) is REFDIV 2, FBDIV 56: the 2 MHz row.
796static_assert((PllRefDiv(2000U) == 2U) && (PllFbDiv(2000U) == 56U));
797// TARGET: the 0x6000 saturation limit is 1.5 A (5.3.3.3); 1 mA is 16 counts.
798static_assert(MicroampsFromTarget(0x6000U, false) == 1'500'046U);
799static_assert(TargetFromMicroamps(1'000U, false) == 16U);
800static_assert(TargetFromMicroamps(kSetpointFullScaleUa, false) == kTargetMax);
801static_assert(TargetFromMicroamps(2'000U, true) == 16U);
802// OL_TH_FIXED full scale 63 * 128 counts is 492 mA (Table 15).
803static_assert((MicroampsFromTarget(63U * 128U, false) / 1000U) == 492U);
804// The SPI watchdog: 0.585 ms per count at 28 MHz, so 100 ms is 170 counts and 1.2 s is too long.
805static_assert(WatchdogReloadCode(100U, kInternalClockHz).value == 170U);
806static_assert(!WatchdogReloadCode(1200U, kInternalClockHz).ok());
807// VBAT_TH reset codes: 25 is 4.05 V, 255 is 41.33 V.
808static_assert(VbatThresholdCode(4052U).value == 25U);
809static_assert(VbatThresholdCode(41330U).value == 255U);
810
811namespace detail {
813template <>
814struct EnumLast<Verify> {
815 static constexpr Verify kValue = Verify::ReadBack;
816};
818template <>
819struct EnumLast<Channel> {
820 static constexpr Channel kValue = Channel::Ch5;
821};
823template <>
824struct EnumLast<ParallelPair> {
825 static constexpr ParallelPair kValue = ParallelPair::Ch4Ch5;
826};
828template <>
829struct EnumLast<ChannelMode> {
830 static constexpr ChannelMode kValue = ChannelMode::Measurement;
831};
833template <>
834struct EnumLast<SlewRate> {
835 static constexpr SlewRate kValue = SlewRate::VPerUs10;
836};
838template <>
839struct EnumLast<DiagCurrent> {
840 static constexpr DiagCurrent kValue = DiagCurrent::Ua1250;
841};
843template <>
844struct EnumLast<OffStateDiag> {
845 static constexpr OffStateDiag kValue = OffStateDiag::Disabled;
846};
848template <>
849struct EnumLast<FastFeedback> {
850 static constexpr FastFeedback kValue = FastFeedback::QuarterPeriod;
851};
853template <>
854struct EnumLast<VioLevel> {
855 static constexpr VioLevel kValue = VioLevel::V5V0;
856};
858template <>
859struct EnumLast<ClockSource> {
860 static constexpr ClockSource kValue = ClockSource::External;
861};
862
864[[nodiscard]] constexpr Channel PairMaster(ParallelPair pair) noexcept {
865 constexpr std::array<Channel, kPairCount> kMasters = {Channel::Ch0, Channel::Ch1, Channel::Ch4};
866 return kMasters[static_cast<uint32_t>(ToUnderlying(pair)) % kPairCount];
867}
869[[nodiscard]] constexpr Channel PairSlave(ParallelPair pair) noexcept {
870 constexpr std::array<Channel, kPairCount> kSlaves = {Channel::Ch3, Channel::Ch2, Channel::Ch5};
871 return kSlaves[static_cast<uint32_t>(ToUnderlying(pair)) % kPairCount];
872}
874[[nodiscard]] constexpr ParallelPair PairOf(Channel channel) noexcept {
875 constexpr std::array<ParallelPair, kChannelCount> kPairs = {
878 return kPairs[static_cast<uint32_t>(ToUnderlying(channel)) % kChannelCount];
879}
881[[nodiscard]] constexpr bool IsActiveSlave(const Config& config, Channel channel) noexcept {
882 const ParallelPair pair = PairOf(channel);
883 return config.parallel[ToUnderlying(pair)] && (PairSlave(pair) == channel);
884}
886[[nodiscard]] constexpr bool IsActiveMaster(const Config& config, Channel channel) noexcept {
887 const ParallelPair pair = PairOf(channel);
888 return config.parallel[ToUnderlying(pair)] && (PairMaster(pair) == channel);
889}
890
892[[nodiscard]] constexpr bool ChannelEnumsValid(const ChannelConfig& c) noexcept {
893 return IsEnumerator(c.mode) && IsEnumerator(c.slew) && IsEnumerator(c.diag.current) &&
894 IsEnumerator(c.diag.off_state) && IsEnumerator(c.dither.fast);
895}
896
899[[nodiscard]] constexpr bool IccValid(const IccConfig& icc, uint32_t system_hz) noexcept {
900 if ((icc.period_exp > 7U) || (icc.ki > 15U) || (icc.limit > 1023U) || (icc.auto_limit > 31U) ||
901 (icc.int_thresh > 511U)) {
902 return false;
903 }
904 if (static_cast<int32_t>(icc.auto_limit) <= (static_cast<int32_t>(icc.min_int_thresh) + 3)) {
905 return false;
906 }
907 const uint32_t hz = PwmFrequencyHz(icc, system_hz);
908 return (icc.period_mant == 0U) || ((hz >= kMinPwmHz) && (hz <= kMaxPwmHz));
909}
910
912[[nodiscard]] constexpr bool DitherValid(const DitherConfig& dither) noexcept {
913 if ((dither.mant > 1023U) || (dither.exp > 15U) || (dither.step_size > 4095U)) {
914 return false;
915 }
916 return (dither.fast == FastFeedback::DitherPeriod) || (dither.flat > 2U);
917}
918
921[[nodiscard]] constexpr bool DiagValid(const DiagConfig& diag, ChannelMode mode) noexcept {
922 if ((diag.ol_relative_eighths > 7U) || (diag.ol_fixed > 63U) || (diag.olsg_warn_window > 31U) ||
923 (diag.olsg_timeout > 63U)) {
924 return false;
925 }
926 return (diag.ol_relative_eighths == 0U) || (mode == ChannelMode::CurrentControl);
927}
928
930[[nodiscard]] constexpr bool ChannelValid(const ChannelConfig& c, uint32_t system_hz) noexcept {
931 return ChannelEnumsValid(c) && (c.on_time_mant <= 1023U) && IccValid(c.icc, system_hz) &&
932 DitherValid(c.dither) && DiagValid(c.diag, c.mode);
933}
934
936[[nodiscard]] constexpr bool GlobalValid(const Config& config) noexcept {
937 if (!IsEnumerator(config.vio) || !IsEnumerator(config.clock)) {
938 return false;
939 }
940 const uint16_t min_reload = config.spi_watchdog ? kMinWatchdogReload : uint16_t{1};
941 if ((config.watchdog_reload < min_reload) || (config.watchdog_reload > kMaxWatchdogReload) ||
942 (config.vbat_uv_code >= config.vbat_ov_code) || (config.max_retries > kMaxRetries) ||
943 (config.init_timeout_us < kMinInitTimeoutUs) ||
944 (config.init_timeout_us > kMaxInitTimeoutUs)) {
945 return false;
946 }
947 if ((config.clock == ClockSource::External) && ((config.external_clock_khz % 500U) != 0U)) {
948 return false;
949 }
950 const uint32_t hz = SystemClockHz(config);
951 return (hz >= kMinSystemClockHz) && (hz <= kMaxSystemClockHz) &&
952 ((static_cast<uint32_t>(config.fault_pin.channel_errors) & ~0x3FU) == 0U) &&
953 ((static_cast<uint32_t>(config.fault_pin.channel_warnings) & ~0x3FU) == 0U);
954}
955} // namespace detail
956
971constexpr Error Validate(const Config& config) noexcept {
972 if (!detail::GlobalValid(config)) {
974 }
975 const uint32_t hz = SystemClockHz(config);
976 for (uint32_t ch = 0U; ch < kChannelCount; ++ch) {
977 const auto channel = static_cast<Channel>(ch);
978 if (!detail::ChannelValid(config.channels[ch], hz) ||
979 (detail::IsActiveSlave(config, channel) && config.channels[ch].loaded)) {
981 }
982 }
983 return Error::Ok;
984}
985
994 ChannelConfig c{};
995 c.loaded = true;
997 c.icc.min_int_thresh = 2;
998 c.icc.period_mant = 219U;
999 c.icc.period_exp = 7U;
1000 c.dither.mant = 875U; // 875 * 2^5 / 28 MHz = 1 ms
1001 c.dither.exp = 5U;
1002 return c;
1003}
1004
1005// Every preset is valid, proved at build time (KB-CPP20-012).
1006static_assert(Validate(Config{}) == Error::Ok);
1007static_assert(PwmFrequencyHz(CurrentControlChannel().icc, kInternalClockHz) == 998U);
1008namespace detail {
1010[[nodiscard]] constexpr Config PresetProof() noexcept {
1011 Config c{};
1013 return c;
1014}
1015} // namespace detail
1016static_assert(Validate(detail::PresetProof()) == Error::Ok);
1017
1022void ConfigIsInvalid() noexcept;
1023
1032public:
1037 consteval explicit CheckedConfig(const Config& config) noexcept : config_(config) {
1038 if (Validate(config) != Error::Ok) {
1040 }
1041 }
1043 [[nodiscard]] constexpr const Config& Get() const& noexcept {
1044 return config_;
1045 }
1047 void Get() const&& = delete;
1048
1049private:
1050 Config config_;
1051};
1052
1055constexpr const char* GetDriverVersion() noexcept {
1056 return TLE92466ED_VERSION_STRING;
1057}
1059constexpr uint32_t GetDriverVersionMajor() noexcept {
1060 return TLE92466ED_VERSION_MAJOR;
1061}
1063constexpr uint32_t GetDriverVersionMinor() noexcept {
1064 return TLE92466ED_VERSION_MINOR;
1065}
1067constexpr uint32_t GetDriverVersionPatch() noexcept {
1068 return TLE92466ED_VERSION_PATCH;
1069}
1070
1073} // namespace tle92466ed
1074
1075#endif // TLE92466ED_TYPES_HPP
A configuration proven valid at build time.
Definition tle92466ed_types.hpp:1031
void Get() const &&=delete
Not on a temporary: the reference would dangle (KB-CPP20-044).
consteval CheckedConfig(const Config &config) noexcept
Check config at build time.
Definition tle92466ed_types.hpp:1037
constexpr const Config & Get() const &noexcept
Definition tle92466ed_types.hpp:1043
constexpr uint32_t kResetPulseUs
Definition tle92466ed_types.hpp:453
constexpr uint32_t kMaxSetpointWithDitherUa
Highest setpoint plus dither amplitude of one channel (Table 14, I_set + I_Dither).
Definition tle92466ed_types.hpp:412
constexpr uint32_t kTargetMax
Largest TARGET value, 2^15 - 1.
Definition tle92466ed_types.hpp:426
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition tle92466ed_types.hpp:37
constexpr const char * GetDriverVersion() noexcept
Definition tle92466ed_types.hpp:1055
Verify
Extra traffic a setter may spend to confirm its write (handbook KB-ARCH-041).
Definition tle92466ed_types.hpp:211
constexpr uint32_t PllRefDiv(uint32_t khz) noexcept
PLL_REFDIV for an external clock: f_CLK / 1 MHz, rounded down as in Table 10.
Definition tle92466ed_types.hpp:679
constexpr Result< uint8_t > VbatThresholdCode(uint32_t millivolts) noexcept
VBAT_UV_TH or VBAT_OV_TH for a threshold voltage, 162.08 mV per count, rounded to the nearest (Equati...
Definition tle92466ed_types.hpp:779
constexpr uint32_t DitherAmplitudeUa(const DitherConfig &dither, bool parallel) noexcept
The dither amplitude I_Dither = STEPS * STEP_SIZE * full scale / (2^15 - 1) (Equation 6).
Definition tle92466ed_types.hpp:735
GlobalFault
Global faults, each named by its register (bits 7..4: 0 GLOBAL_DIAG0, 1 GLOBAL_DIAG1,...
Definition tle92466ed_types.hpp:478
constexpr uint32_t kMaxPwmHz
Highest PWM frequency, f_PWM max (Table 6).
Definition tle92466ed_types.hpp:436
constexpr uint32_t kWatchdogDivider
The SPI watchdog counts f_SYS / 2^14 (Table 18).
Definition tle92466ed_types.hpp:444
constexpr uint32_t kPollIntervalUs
Interval of the INIT_DONE and self-test polls.
Definition tle92466ed_types.hpp:455
constexpr uint16_t kMaxWatchdogReload
Largest WD_TIME, an 11-bit field (5.3.2.11).
Definition tle92466ed_types.hpp:438
ChannelMode
How a channel drives its output (MODE.CH_MODE, section 5.3.3.11).
Definition tle92466ed_types.hpp:238
constexpr uint32_t kBistTimeoutUs
Definition tle92466ed_types.hpp:462
constexpr uint32_t kPairCount
Number of parallel pairs.
Definition tle92466ed_types.hpp:235
constexpr uint32_t kParallelMeasurementRangeUa
Definition tle92466ed_types.hpp:415
constexpr uint32_t PllFbDiv(uint32_t khz) noexcept
PLL_FBDIV for an external clock: 56 MHz * PLL_REFDIV / f_CLK, rounded to the nearest as in Table 10 (...
Definition tle92466ed_types.hpp:689
constexpr uint32_t GetDriverVersionPatch() noexcept
Definition tle92466ed_types.hpp:1067
constexpr uint32_t kResetReleaseUs
Logic ready after RESN released, t_RESN max (Table 9).
Definition tle92466ed_types.hpp:448
constexpr uint32_t kParallelFullScaleUa
Full scale of TARGET in a parallel pair: the LSB doubles (4.5.2).
Definition tle92466ed_types.hpp:424
constexpr Result< uint16_t > WatchdogReloadCode(uint32_t timeout_ms, uint32_t system_hz) noexcept
WD_TIME for a watchdog timeout: rounddown(t_SPI_WD * f_SYS / 2^14) (5.3.2.11).
Definition tle92466ed_types.hpp:763
constexpr uint32_t kMaxSetpointUa
Highest DC setpoint of one channel, in microamps (Table 14, I_set).
Definition tle92466ed_types.hpp:410
VioLevel
The level of VIO, the SPI output supply (GLOBAL_CONFIG.VIO_SEL, section 4.1.1).
Definition tle92466ed_types.hpp:279
ClockSource
Where the PLL takes its reference (CLK_DIV.EXT_CLK, section 4.2.1).
Definition tle92466ed_types.hpp:285
constexpr uint32_t kMaxOcOnTimeUs
Longest OFF-state overcurrent on-time t_OCon (TON register note, 5.3.3.12), microseconds.
Definition tle92466ed_types.hpp:446
constexpr uint32_t kMinPwmHz
Lowest PWM frequency of the frequency controller, f_PWM min (Table 6).
Definition tle92466ed_types.hpp:434
FastFeedback
Feedback update interval (DITHER_CTRL.FAST_MEAS, section 4.10.3).
Definition tle92466ed_types.hpp:272
constexpr uint32_t kMaxParallelSetpointUa
Definition tle92466ed_types.hpp:419
void ConfigIsInvalid() noexcept
Reached only when a CheckedConfig is built from an invalid configuration: it is never defined,...
constexpr uint32_t kMinInitTimeoutUs
Shortest Config::init_timeout_us.
Definition tle92466ed_types.hpp:457
ParallelPair
The channel pairs that can drive one load together (section 4.5.2).
Definition tle92466ed_types.hpp:229
constexpr Error Validate(const Config &config) noexcept
Check a configuration without touching the chip.
Definition tle92466ed_types.hpp:971
constexpr uint32_t kChannelCount
Number of output channels (section 4.5.1).
Definition tle92466ed_types.hpp:226
constexpr uint32_t PwmFrequencyHz(const IccConfig &icc, uint32_t system_hz) noexcept
The PWM frequency the controller is set to: f_SYS / (PERIOD_MANT * 2^PERIOD_EXP), times 1/8 in the lo...
Definition tle92466ed_types.hpp:748
constexpr uint8_t kVersionA11
ICVID.VERSION of design step A11.
Definition tle92466ed_types.hpp:468
constexpr uint8_t kVersionA13
ICVID.VERSION of design step A13.
Definition tle92466ed_types.hpp:470
constexpr uint8_t kManufacturerId
ICVID.MANUFACTURER of every TLE92466ED (5.3.2.19).
Definition tle92466ed_types.hpp:466
constexpr uint32_t GetDriverVersionMajor() noexcept
Definition tle92466ed_types.hpp:1059
constexpr uint32_t kMaxInitTimeoutUs
Longest Config::init_timeout_us.
Definition tle92466ed_types.hpp:459
constexpr uint16_t kMinWatchdogReload
Definition tle92466ed_types.hpp:442
DiagCurrent
OFF-state diagnosis current I_HS, I_LS (CH_CONFIG.I_DIAG, Table 15).
Definition tle92466ed_types.hpp:256
constexpr ChannelConfig CurrentControlChannel() noexcept
A starting point for one current-controlled channel with feedback: ICC, a 1 kHz PWM target (PERIOD_MA...
Definition tle92466ed_types.hpp:993
constexpr uint32_t kInternalClockHz
f_SYS of the internal oscillator, typical (Table 6).
Definition tle92466ed_types.hpp:428
constexpr uint32_t MicroampsFromTarget(uint32_t target, bool parallel) noexcept
The current a TARGET count programs, rounded to the nearest microamp.
Definition tle92466ed_types.hpp:723
constexpr uint8_t kMaxRetries
Highest Config::max_retries.
Definition tle92466ed_types.hpp:464
constexpr uint32_t kMinSystemClockHz
Lowest f_SYS (Table 6).
Definition tle92466ed_types.hpp:430
Channel
One of the six output channels.
Definition tle92466ed_types.hpp:217
constexpr uint32_t kPowerOnResetUs
Logic ready after a power-on reset, t_POR max (Table 9).
Definition tle92466ed_types.hpp:450
constexpr uint32_t SystemClockHz(const Config &config) noexcept
f_SYS for a configuration: 28 MHz from the internal oscillator, else f_CLK * PLL_FBDIV / (2 * PLL_REF...
Definition tle92466ed_types.hpp:693
constexpr uint32_t TargetFromMicroamps(uint32_t microamps, bool parallel) noexcept
The TARGET count of a current, rounded to the nearest (section 5.3.3.3).
Definition tle92466ed_types.hpp:711
SlewRate
Output current slew rate (CH_CONFIG.SLEWR, Table 13).
Definition tle92466ed_types.hpp:248
constexpr uint32_t kMaxSystemClockHz
Highest f_SYS (Table 6).
Definition tle92466ed_types.hpp:432
LogLevel
Severity passed to the optional Log() hook.
Definition tle92466ed_types.hpp:201
constexpr uint32_t kSetpointFullScaleUa
Full scale of TARGET, one channel: I_set = 2 A * TARGET / (2^15 - 1) (5.3.3.3).
Definition tle92466ed_types.hpp:422
constexpr const char * ToString(Error error) noexcept
The name of an error, for logs.
Definition tle92466ed_types.hpp:87
OffStateDiag
OFF-state diagnosis current sources (CH_CONFIG.OFF_DIAG_CH, section 4.9.1).
Definition tle92466ed_types.hpp:264
constexpr uint32_t GetDriverVersionMinor() noexcept
Definition tle92466ed_types.hpp:1063
@ InvalidArgument
An argument or a Config field is out of range; nothing was sent.
@ DeviceIdMismatch
ICVID is not manufacturer 0xC1 with a known version (5.3.2.19).
@ Ok
The call succeeded.
@ Busy
Not returned by this driver: the chip is never busy to SPI.
@ None
No extra frame and no compare. The default.
@ ReadBack
Read the written register back (two more frames) and compare it.
@ CentralOtError
GLOBAL_DIAG0.COTERR.
@ ClockFault
GLOBAL_DIAG0.CLK_NOK.
@ RegisterEcc
GLOBAL_DIAG2.REG_ECC_ERR.
@ OtpEcc
GLOBAL_DIAG2.OTP_ECC_ERR.
@ ReferenceHigh
GLOBAL_DIAG1.REF_OV.
@ ReferenceLow
GLOBAL_DIAG1.REF_UV.
@ BiasCurrentLow
GLOBAL_DIAG1.VR_IREF_UV.
@ OtpVirgin
GLOBAL_DIAG2.OTP_VIRGIN.
@ VioUndervoltage
GLOBAL_DIAG0.VIO_UV.
@ VioOvervoltage
GLOBAL_DIAG0.VIO_OV.
@ PreRegulatorHigh
GLOBAL_DIAG1.VPRE_OV.
@ VbatOvervoltage
GLOBAL_DIAG0.VBAT_OV.
@ VddOvervoltage
GLOBAL_DIAG0.VDD_OV.
@ VbatUndervoltage
GLOBAL_DIAG0.VBAT_UV.
@ CentralOtWarning
GLOBAL_DIAG0.COTWARN.
@ SpiWatchdog
GLOBAL_DIAG0.SPI_WD_ERR.
@ MonitorAdc
GLOBAL_DIAG1.HVADC_ERR.
@ Supply2v5Low
GLOBAL_DIAG1.VDD2V5_UV.
@ VddUndervoltage
GLOBAL_DIAG0.VDD_UV.
@ BiasCurrentHigh
GLOBAL_DIAG1.VR_IREF_OV.
@ Supply2v5High
GLOBAL_DIAG1.VDD2V5_OV.
@ DirectDriveSpi
On-time on_time_mant per dither period, from SPI (4.8.1).
@ Measurement
Free-running measurement, switch off (4.4.3); CH_MODE = CH.
@ DirectDriveDrv1
The output follows the DRV1 pin (4.8.1).
@ CurrentControl
ICC: the integrating current controller holds the setpoint (4.6.2).
@ Off
Output off, no measurement. Reset value.
@ DirectDriveDrv0
The output follows the DRV0 pin (4.8.1).
@ V5V0
5.0 V. Reset value.
@ V3V3
3.3 V: VIO monitored against the 3.3 V thresholds (Table 9).
@ Internal
The internal oscillator; the dividers are ignored. Reset value.
@ External
The CLK pin, Config::external_clock_khz.
@ DitherPeriod
One update per dither period. Reset value.
@ QuarterPeriod
n_meas_sample = 4.
@ HalfPeriod
n_meas_sample = 2.
@ Ch1Ch2
CH1 master, CH2 slave (CH_CTRL.CH_PAR_1_2).
@ Ch0Ch3
CH0 master, CH3 slave (CH_CTRL.CH_PAR_0_3).
@ Ch4Ch5
CH4 master, CH5 slave (CH_CTRL.CH_PAR_4_5).
@ Ua80
80 uA typical. Reset value.
@ Ua190
190 uA typical.
@ Ua1250
1250 uA typical.
@ Ua720
720 uA typical.
@ Ch4
LOAD4. Master of the CH4/CH5 pair.
@ Ch5
LOAD5. Slave of the CH4/CH5 pair.
@ Ch0
LOAD0. Master of the CH0/CH3 pair.
@ Ch1
LOAD1. Master of the CH1/CH2 pair.
@ Ch3
LOAD3. Slave of the CH0/CH3 pair.
@ Ch2
LOAD2. Slave of the CH1/CH2 pair.
@ VPerUs1
1 V/us typical.
@ VPerUs5
5 V/us typical.
@ VPerUs2p5
2.5 V/us typical.
@ VPerUs10
10 V/us typical. Reset value.
@ Warning
Something unexpected that the driver recovered from.
@ Info
Lifecycle events: initialised, reset.
@ Debug
Detail for bring-up.
@ Enabled
The OL/SG sequence of Figure 15 runs. Reset value.
@ HighSideSource
Only I_HS on.
@ LowSideSource
Only I_LS on.
@ Disabled
No OFF-state diagnosis.
The TLE92466ED driver: everything it declares lives here; internals in detail.
Definition tle92466ed.hpp:26
The result of the safety flip-flop self-test (SFF_BIST, section 4.9.8).
Definition tle92466ed_types.hpp:624
bool passed
SMU_SLF_TST_FAIL = 0.
Definition tle92466ed_types.hpp:625
bool uncorrectable_tested
SMU_SLF_TST_UERR.
Definition tle92466ed_types.hpp:626
bool correctable_tested
SMU_SLF_TST_CERR.
Definition tle92466ed_types.hpp:627
Counters of the protocol layer (handbook KB-ARCH-044). No I/O to read them.
Definition tle92466ed_types.hpp:656
uint32_t rejected_replies
Replies that failed a check (CRC, width, echo, anchor).
Definition tle92466ed_types.hpp:659
uint32_t frames
32-bit frames sent.
Definition tle92466ed_types.hpp:657
uint32_t resyncs
Anchor frames sent alone to restore the pipeline.
Definition tle92466ed_types.hpp:660
uint32_t retries
Reads repeated after a reply failed its checks.
Definition tle92466ed_types.hpp:658
Everything the driver writes for one channel. Defaults are the reset values.
Definition tle92466ed_types.hpp:345
IccConfig icc
Current controller.
Definition tle92466ed_types.hpp:353
ChannelMode mode
MODE.CH_MODE (Config Mode only).
Definition tle92466ed_types.hpp:349
bool loaded
Definition tle92466ed_types.hpp:346
DiagConfig diag
Diagnosis.
Definition tle92466ed_types.hpp:355
SlewRate slew
CH_CONFIG.SLEWR.
Definition tle92466ed_types.hpp:350
DitherConfig dither
Dither and measurement period.
Definition tle92466ed_types.hpp:354
uint16_t on_time_mant
Definition tle92466ed_types.hpp:351
The faults and warnings of one channel, decoded (sections 5.3.2.12, 5.3.2.13).
Definition tle92466ed_types.hpp:503
bool open_load
OL: open load, OFF-state diagnosis (4.9.4).
Definition tle92466ed_types.hpp:505
bool pwm_regulation
PWM_REG_WARN (4.6.2.4).
Definition tle92466ed_types.hpp:509
bool current_regulation
I_REG_WARN (4.6.2.5).
Definition tle92466ed_types.hpp:510
bool olsg
OLSG: open load or short to ground in ON-state (4.9.2).
Definition tle92466ed_types.hpp:504
constexpr bool AnyError() const noexcept
Definition tle92466ed_types.hpp:516
bool short_to_ground
SG: OFF-state diagnosis (4.9.5).
Definition tle92466ed_types.hpp:507
bool overtemperature
OTE: the channel was switched off (4.11.1).
Definition tle92466ed_types.hpp:508
bool olsg_check_skipped
OLSG_WARN_CHK_NOK: no voltage check was possible.
Definition tle92466ed_types.hpp:513
bool olsg_warning
OLSG_WARN (4.9.3).
Definition tle92466ed_types.hpp:512
friend constexpr bool operator==(const ChannelFaults &lhs, const ChannelFaults &rhs) noexcept=default
Field-by-field equality (KB-CPP20-033: integral members only).
bool overcurrent
OC (4.9.6, 4.11.2).
Definition tle92466ed_types.hpp:506
bool overtemperature_warning
OTW.
Definition tle92466ed_types.hpp:511
One measurement period of a channel's feedback, read under the freeze of section 4....
Definition tle92466ed_types.hpp:641
uint32_t duty_permyriad
TO_MANT / TP_MANT, 0 to 10000.
Definition tle92466ed_types.hpp:644
uint8_t quad_count
DITHER_QUAD_CNT (fast feedback only).
Definition tle92466ed_types.hpp:652
uint32_t vbat_mv
VBAT = 41.47 V * VBAT_AVG_MANT / TP_MANT.
Definition tle92466ed_types.hpp:645
uint32_t max_pwm_period_ns
T_PWM_max = PMAX * 256 / f_SYS.
Definition tle92466ed_types.hpp:650
uint32_t min_pwm_period_ns
T_PWM_min = PMIN * 256 / f_SYS.
Definition tle92466ed_types.hpp:649
uint32_t period_us
T_meas = TP_MANT * 2^EXP / f_SYS.
Definition tle92466ed_types.hpp:646
int32_t min_current_ua
I_min = 4 A * IMIN / (2^9 - 1).
Definition tle92466ed_types.hpp:647
int32_t average_current_ua
Definition tle92466ed_types.hpp:642
int32_t max_current_ua
I_max = 4 A * IMAX / (2^9 - 1).
Definition tle92466ed_types.hpp:648
uint8_t period_count
DITHER_PERIOD_CNT (fast feedback only, 4.10.4).
Definition tle92466ed_types.hpp:651
The unique chip identification, CHIPID0..2 (sections 5.3.2.24 to 5.3.2.26).
Definition tle92466ed_types.hpp:631
friend constexpr bool operator==(const ChipId &lhs, const ChipId &rhs) noexcept=default
Word-by-word equality.
std::array< uint16_t, 3 > words
Definition tle92466ed_types.hpp:632
Everything EnsureInitialized() writes to the chip, and the driver's own settings.
Definition tle92466ed_types.hpp:382
bool clock_watchdog
GLOBAL_CONFIG.CLK_WD_EN (4.2.2).
Definition tle92466ed_types.hpp:387
FaultPinMask fault_pin
FAULT_MASK0..2.
Definition tle92466ed_types.hpp:397
uint32_t external_clock_khz
Definition tle92466ed_types.hpp:393
uint8_t vbat_uv_code
VBAT_TH.VBAT_UV_TH, 162.08 mV per count (4.05 V).
Definition tle92466ed_types.hpp:395
bool crc_check
Definition tle92466ed_types.hpp:385
uint32_t init_timeout_us
Definition tle92466ed_types.hpp:400
uint8_t vbat_ov_code
VBAT_TH.VBAT_OV_TH (41.3 V).
Definition tle92466ed_types.hpp:396
ClockSource clock
CLK_DIV.EXT_CLK.
Definition tle92466ed_types.hpp:392
bool spi_watchdog
GLOBAL_CONFIG.SPI_WD_EN (5.2.2).
Definition tle92466ed_types.hpp:388
std::array< ChannelConfig, kChannelCount > channels
Per channel, indexed by Channel.
Definition tle92466ed_types.hpp:399
uint16_t watchdog_reload
Definition tle92466ed_types.hpp:389
std::array< bool, kPairCount > parallel
CH_CTRL.CH_PAR_x_y, indexed by ParallelPair.
Definition tle92466ed_types.hpp:398
VioLevel vio
Definition tle92466ed_types.hpp:383
uint8_t max_retries
Definition tle92466ed_types.hpp:402
FB_STAT, the chip's one-word status summary, decoded (section 5.3.2.21).
Definition tle92466ed_types.hpp:588
bool spi_watchdog_error
SPI_WD_ERR.
Definition tle92466ed_types.hpp:590
bool power_on_event
POR_event: power-on reset since the flag was cleared.
Definition tle92466ed_types.hpp:595
bool data_error
DATA_err: OTP ECC, OTP virgin or monitor ADC error.
Definition tle92466ed_types.hpp:596
uint32_t raw
The 22-bit register.
Definition tle92466ed_types.hpp:602
bool init_done
INIT_DONE: clock and logic ready.
Definition tle92466ed_types.hpp:589
bool central_ot_error
COTERR.
Definition tle92466ed_types.hpp:592
uint8_t warning_groups
DIAG_WARN_CHGR0..2 summary, bit g.
Definition tle92466ed_types.hpp:600
bool supply_external
SUP_NOK_EXT: VIO, VDD or VBAT out of range.
Definition tle92466ed_types.hpp:597
bool supply_internal
SUP_NOK_INT: an internal supply out of range.
Definition tle92466ed_types.hpp:598
bool clock_fault
CLK_NOK.
Definition tle92466ed_types.hpp:591
uint8_t error_groups
ERR_CHGR0..2, bit g: a channel error in group g.
Definition tle92466ed_types.hpp:599
bool reset_event
RES_event: RESN reset since the flag was cleared.
Definition tle92466ed_types.hpp:594
bool central_ot_warning
COTWARN.
Definition tle92466ed_types.hpp:593
uint8_t check_skipped_groups
OLSG_WARN_CHK_NOK summary, bit g.
Definition tle92466ed_types.hpp:601
The diagnosis of one channel (CH_CONFIG, CTRL, TON; section 4.9). Defaults are the reset values....
Definition tle92466ed_types.hpp:332
DiagCurrent current
CH_CONFIG.I_DIAG.
Definition tle92466ed_types.hpp:333
OffStateDiag off_state
CH_CONFIG.OFF_DIAG_CH.
Definition tle92466ed_types.hpp:338
uint8_t olsg_timeout
TON.OLSG_TIMEOUT, 0 to 63 (Equation 15).
Definition tle92466ed_types.hpp:341
uint8_t ol_relative_eighths
Definition tle92466ed_types.hpp:334
uint8_t olsg_warn_window
CTRL.OLSG_WARN_WINDOW, 0 to 31.
Definition tle92466ed_types.hpp:340
uint8_t ol_fixed
Definition tle92466ed_types.hpp:336
bool olsg_warning
CTRL.OLSG_WARN_EN (4.9.3).
Definition tle92466ed_types.hpp:339
The dither generator of one channel (DITHER_CLK_DIV, DITHER_STEP, DITHER_CTRL; section 4....
Definition tle92466ed_types.hpp:315
bool setpoint_sync
DITHER_CLK_DIV.DITHER_SETPOINT_SYNC_EN (4.7.5).
Definition tle92466ed_types.hpp:319
uint8_t exp
DITHER_CLK_DIV.EXP, 0 to 15; also the TON exponent.
Definition tle92466ed_types.hpp:317
uint16_t mant
DITHER_CLK_DIV.MANT of t_ref_clk, 0 to 1023.
Definition tle92466ed_types.hpp:316
uint16_t step_size
DITHER_CTRL.STEP_SIZE, 0 to 4095, in TARGET counts.
Definition tle92466ed_types.hpp:322
uint8_t flat
DITHER_STEP.FLAT reference clocks at each plateau.
Definition tle92466ed_types.hpp:321
FastFeedback fast
DITHER_CTRL.FAST_MEAS (4.10.3).
Definition tle92466ed_types.hpp:324
bool pwm_sync
DITHER_CLK_DIV.DITHER_PWM_SYNC_EN (4.7.3).
Definition tle92466ed_types.hpp:318
bool deep
DITHER_CTRL.DEEP_DITHER (4.7.7).
Definition tle92466ed_types.hpp:323
uint8_t steps
DITHER_STEP.STEPS per quarter period.
Definition tle92466ed_types.hpp:320
Which faults pull FAULTN low (FAULT_MASK0..2, sections 5.3.2.14 to 5.3.2.16); true reports the fault ...
Definition tle92466ed_types.hpp:363
uint8_t channel_warnings
CHx_WARN_MASK, bit x: OTW, I_REG, PWM_REG, OLSG warnings.
Definition tle92466ed_types.hpp:365
bool supply_external
SUP_NOK_EXT_MASK.
Definition tle92466ed_types.hpp:368
bool supply_internal
SUP_NOK_INT_MASK.
Definition tle92466ed_types.hpp:367
bool clock_too_slow
CLK_LOW_MASK.
Definition tle92466ed_types.hpp:371
bool central_ot_warning
COTWARN_MASK.
Definition tle92466ed_types.hpp:369
bool central_ot_error
COTERR_MASK.
Definition tle92466ed_types.hpp:370
bool spi_watchdog
SPI_WD_MASK.
Definition tle92466ed_types.hpp:373
bool en_pin
EN_PIN_MASK: EN low.
Definition tle92466ed_types.hpp:366
bool data_error
DATA_ERR_MASK.
Definition tle92466ed_types.hpp:372
uint8_t channel_errors
CHx_ERR_MASK, bit x: OC, SG, OL, OTE, OLSG of channel x.
Definition tle92466ed_types.hpp:364
The diagnosis registers as read: GLOBAL_DIAG0..2, DIAG_ERR_CHGR0..2 and DIAG_WARN_CHGR0....
Definition tle92466ed_types.hpp:528
friend constexpr bool operator==(const Faults &lhs, const Faults &rhs) noexcept=default
Word-by-word equality (KB-CPP20-033: integral members only).
constexpr bool Any() const noexcept
Definition tle92466ed_types.hpp:572
constexpr bool Has(GlobalFault fault) const noexcept
Whether a global fault is set.
Definition tle92466ed_types.hpp:538
std::array< uint16_t, 3 > warnings
DIAG_WARN_CHGR0, 1, 2.
Definition tle92466ed_types.hpp:531
std::array< uint16_t, 3 > global
GLOBAL_DIAG0, 1, 2.
Definition tle92466ed_types.hpp:529
constexpr ChannelFaults Of(Channel channel) const noexcept
The faults of one channel.
Definition tle92466ed_types.hpp:549
std::array< uint16_t, 3 > errors
DIAG_ERR_CHGR0, 1, 2.
Definition tle92466ed_types.hpp:530
The integrating current controller of one channel (CTRL, PERIOD, INTEGRATOR_LIMIT,...
Definition tle92466ed_types.hpp:294
uint8_t period_exp
PERIOD.PERIOD_EXP, 0 to 7.
Definition tle92466ed_types.hpp:299
uint8_t auto_limit
Definition tle92466ed_types.hpp:303
int8_t min_int_thresh
Definition tle92466ed_types.hpp:295
bool auto_limit_disable
SETPOINT.AUTO_LIMIT_DIS (4.6.2.2).
Definition tle92466ed_types.hpp:305
bool low_freq_range
PERIOD.LOW_FREQ_RANGE_EN: the period times 8.
Definition tle92466ed_types.hpp:300
uint16_t int_thresh
CTRL_INT_THRESH.INT_THRESH, 0 to 511.
Definition tle92466ed_types.hpp:306
uint8_t ki
PERIOD.PWM_CTRL_PARAM, the controller gain, 0 to 15.
Definition tle92466ed_types.hpp:301
bool skip_falling_dither
CTRL.PWM_PERIOD_CALC_MODE (4.6.2.3).
Definition tle92466ed_types.hpp:297
uint16_t limit
INTEGRATOR_LIMIT.LIM_VALUE_ABS, 0 to 1023.
Definition tle92466ed_types.hpp:302
uint8_t period_mant
PERIOD.PERIOD_MANT; 0 turns the PWM controller off.
Definition tle92466ed_types.hpp:298
PIN_STAT, decoded (section 5.3.2.20).
Definition tle92466ed_types.hpp:615
bool enable
EN is high.
Definition tle92466ed_types.hpp:618
bool drv1
DRV1 is high.
Definition tle92466ed_types.hpp:617
bool drv0
DRV0 is high.
Definition tle92466ed_types.hpp:616
bool fault
An unmasked fault (FAULTN bit 0).
Definition tle92466ed_types.hpp:619
bool faultn_high
FAULTN_FB: the pin's level is high.
Definition tle92466ed_types.hpp:620
constexpr bool ok() const noexcept
Definition tle92466ed_types.hpp:178
static constexpr Result Success() noexcept
Definition tle92466ed_types.hpp:187
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition tle92466ed_types.hpp:195
The value of a call, or why there is none.
Definition tle92466ed_types.hpp:141
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition tle92466ed_types.hpp:167
constexpr bool ok() const noexcept
Definition tle92466ed_types.hpp:146
static constexpr Result Success(T v) noexcept
A successful result.
Definition tle92466ed_types.hpp:159
The supply and temperature feedback (FB_VOLTAGE1, FB_VOLTAGE2; 5.3.2.22, 5.3.2.23).
Definition tle92466ed_types.hpp:606
uint32_t vbat_mv
VBAT = 41.47 V * VBAT / (2^11 - 1).
Definition tle92466ed_types.hpp:609
uint32_t vdd_mv
VDD = 3.4534 mV * VDD.
Definition tle92466ed_types.hpp:608
int32_t temperature_mc
Definition tle92466ed_types.hpp:610
uint32_t vio_mv
VIO = 3.4534 mV * VIO.
Definition tle92466ed_types.hpp:607
Compile-time helpers of the TLE92466ED driver: typed integer literals, exact hook matching,...