12#ifndef MAX22200_TYPES_HPP
13#define MAX22200_TYPES_HPP
21#include "max22200_version.h"
39enum class [[nodiscard]]
Error : uint8_t {
103 return "NotInitialized";
105 return "InvalidArgument";
111 return "DeviceIdMismatch";
117 return "DeviceFault";
119 return "Unsupported";
125 return "CommunicationError";
127 return "WriteMismatch";
129 return "Undervoltage";
131 return "ChannelsActive";
133 return "DeviceReset";
155 [[nodiscard]]
constexpr bool ok() const noexcept {
156 return error == Error::Ok;
159 constexpr explicit operator bool() const noexcept {
169 return {v, Error::Ok};
187 [[nodiscard]]
constexpr bool ok() const noexcept {
188 return error == Error::Ok;
191 constexpr explicit operator bool() const noexcept {
314struct EnumLast<
Side> {
330static_assert(detail::ToUnderlying(
ChopDivider::Div1) == 3U,
"Table 1: FREQ_CFG 0 to 3");
331static_assert(detail::ToUnderlying(
PairMode::FullBridge) == 2U,
"Register Details: CMxy 0 to 2");
358inline constexpr uint32_t
kKfs = 15000;
426 const FaultMask& rhs)
noexcept =
default;
444 const DpmConfig& rhs)
noexcept =
default;
472 std::array<PairMode, kPairs>
pairs{};
491 [[nodiscard]]
constexpr bool AnyFlag() const noexcept {
508 return {.
overcurrent = 0xFF, .hit_not_reached = 0xFF, .open_load = 0xFF, .plunger = 0xFF};
511 [[nodiscard]]
constexpr bool Any() const noexcept {
515 [[nodiscard]]
constexpr uint8_t
Channels() const noexcept {
516 return static_cast<uint8_t
>(
static_cast<uint32_t
>(
overcurrent) |
526 static_cast<uint32_t
>(other.overcurrent)),
528 static_cast<uint32_t
>(other.hit_not_reached)),
529 .open_load =
static_cast<uint8_t
>(
static_cast<uint32_t
>(
open_load) |
530 static_cast<uint32_t
>(other.open_load)),
532 static_cast<uint32_t
>(other.plunger))};
540 static_cast<uint32_t
>(mask.overcurrent)),
542 static_cast<uint32_t
>(mask.hit_not_reached)),
543 .open_load =
static_cast<uint8_t
>(
static_cast<uint32_t
>(
open_load) &
544 static_cast<uint32_t
>(mask.open_load)),
546 static_cast<uint32_t
>(mask.plunger))};
554 const Faults& rhs)
noexcept =
default;
580 [[nodiscard]]
constexpr bool Any() const noexcept {
617 v |= (
static_cast<uint32_t
>(detail::ToUnderlying(c.chop)) & 0x03U) <<
reg::kFreqCfgShift;
618 v |= c.slew_rate_control ?
reg::kSrc : 0U;
640 c.slew_rate_control = (v &
reg::kSrc) != 0U;
665 for (uint8_t p = 0; p <
kPairs; ++p) {
666 v |= (
static_cast<uint32_t
>(detail::ToUnderlying(config.pairs[p])) & 0x03U)
681 s.overtemperature = (v &
reg::kOvt) != 0U;
684 s.hit_not_reached = (v &
reg::kHhf) != 0U;
755 return main_period_ns * (4U - (
static_cast<uint32_t
>(detail::ToUnderlying(chop)) & 0x03U));
766 if (slew_rate_control) {
805 const uint64_t step_ns = 40ULL *
ChopPeriodNs(clock, chop);
806 const uint64_t code = ((
static_cast<uint64_t
>(us) * 1000U) + (step_ns / 2U)) / step_ns;
836 const uint64_t ua = (
static_cast<uint64_t
>(
kKfs) * 1000000ULL) / rref_ohm;
849 const auto ifs =
FullScaleUa(rref_ohm, half_scale);
854 static_cast<uint32_t
>((
static_cast<uint64_t
>(code) * ifs.value) / 128U));
867 const auto ifs =
FullScaleUa(rref_ohm, half_scale);
871 const uint32_t ifs_ua = ifs.value;
875 const uint64_t code = ((
static_cast<uint64_t
>(ma) * 128000U) + (ifs_ua / 2U)) / ifs_ua;
891 uint8_t max_code)
noexcept {
896 const uint32_t ifs_ua = ifs.value;
897 const uint64_t code = ((
static_cast<uint64_t
>(ma) * 127000U) + (ifs_ua / 2U)) / ifs_ua;
898 if (code > max_code) {
925 !c.half_scale && !c.plunger_detect);
938 if (!detail::IsEnumerator(c.drive) || !detail::IsEnumerator(c.side) ||
939 !detail::IsEnumerator(c.chop) || !detail::IsEnumerator(clock)) {
948 if (c.slew_rate_control && (
ChopPeriodNs(clock, c.chop) <= 20000U)) {
967 uint8_t channel)
noexcept {
968 const bool diagnostics = c.open_load_detect || c.plunger_detect || c.hit_current_check;
970 ((
static_cast<uint32_t
>(loaded_channels) >> (
static_cast<uint32_t
>(channel) & 0x07U)) & 1U) !=
972 return !diagnostics || loaded;
981constexpr bool ValidTimings(
const Config& config)
noexcept {
982 const bool rref_ok = (config.rref_ohm ==
kNoRref) ||
1001 if (!detail::IsEnumerator(config.variant) || !detail::IsEnumerator(config.clock)) {
1004 if (!detail::ValidTimings(config)) {
1007 for (
const PairMode p : config.pairs) {
1008 if (!detail::IsEnumerator(p)) {
1012 for (uint8_t ch = 0; ch <
kChannels; ++ch) {
1031static_assert(
EncodeChannel(ChannelConfig{}) == 0U,
"Register Details: CFG_CHn resets to 0");
1033 "Register Details: STATUS resets with only M_COMF set among the writable bits");
1034static_assert(
Validate(Config{}) ==
Error::Ok,
"Config{} is a valid configuration");
1042 .trigger_pin =
true,
1043 .open_load_detect =
true})) ==
1050 .trigger_pin =
true,
1051 .open_load_detect =
true});
1057 .slew_rate_control =
true,
1058 .plunger_detect =
true,
1059 .hit_current_check =
true})) ==
1060 ChannelConfig{.
hit = 126,
1065 .slew_rate_control =
true,
1066 .plunger_detect =
true,
1067 .hit_current_check =
true});
1068static_assert(
DecodeDpm(
EncodeDpm({.start = 127, .debounce = 15, .threshold = 15})) ==
1069 DpmConfig{.
start = 127, .debounce = 15, .threshold = 15});
1077static_assert(!
DecodePairMode(0x0000'C000_u32, 3_u8).ok(),
"CMxy = 3 is not a mode");
1079 .hit_not_reached = 0x02,
1084static_assert(
CurrentCode(250_u32, 30000_u32,
false).ok() &&
1088 (
FullScaleUa(15000_u32,
false).value == 1000000U));
1094 return MAX22200_VERSION_STRING;
1098 return MAX22200_VERSION_MAJOR;
1102 return MAX22200_VERSION_MINOR;
1106 return MAX22200_VERSION_PATCH;
constexpr uint32_t kFaultOcpShift
OCP[7:0]; channel 0 is the LSB of each byte.
Definition max22200_registers.hpp:132
constexpr uint32_t kOlEn
OL_EN: open-load detection.
Definition max22200_registers.hpp:125
constexpr uint32_t kMaskOlf
M_OLF.
Definition max22200_registers.hpp:75
constexpr uint32_t kHoldShift
HOLD[6:0] at bits 30:24.
Definition max22200_registers.hpp:115
constexpr uint32_t kDpmEn
DPM_EN: plunger-movement detection.
Definition max22200_registers.hpp:126
constexpr uint32_t kHhf
HHF flag: some channel has an HHF bit in FAULT.
Definition max22200_registers.hpp:89
constexpr uint32_t kHfs
HFS: half full-scale (KFS 7.5k instead of 15k).
Definition max22200_registers.hpp:113
constexpr uint32_t kTrgnspi
TRGnSPI: the TRIGA/TRIGB pin switches it.
Definition max22200_registers.hpp:116
constexpr uint32_t kMaskOvt
M_OVT: OVT does not assert FAULT.
Definition max22200_registers.hpp:73
constexpr uint32_t kStatusReset
0x00040002 after power-up.
Definition max22200_registers.hpp:101
constexpr uint32_t kFlagsMask
The seven read-only flags, bits 7:1.
Definition max22200_registers.hpp:99
constexpr uint32_t kDpm
DPM flag: some channel has a DPM bit in FAULT.
Definition max22200_registers.hpp:91
constexpr uint32_t kFaultDpmShift
DPM[7:0].
Definition max22200_registers.hpp:135
constexpr uint32_t kOnchShift
ONCH[7:0]: bit 24 + n switches channel n on.
Definition max22200_registers.hpp:72
constexpr uint32_t kHitTimeShift
HIT_T[7:0] at bits 15:8.
Definition max22200_registers.hpp:119
constexpr uint32_t kDpmIpthMask
DPM_IPTH width.
Definition max22200_registers.hpp:163
constexpr uint32_t kOvt
OVT flag; a STATUS read clears it.
Definition max22200_registers.hpp:84
constexpr uint32_t PairModeShift(uint8_t pair) noexcept
Shift of a channel pair's CMxy field in STATUS.
Definition max22200_registers.hpp:108
constexpr uint32_t kVdrncdr
VDRnCDR: 1 = voltage drive, 0 = current drive.
Definition max22200_registers.hpp:120
constexpr uint32_t kWritableMask
Every bit a write sets.
Definition max22200_registers.hpp:100
constexpr uint32_t kDpmIstartMask
DPM_ISTART width.
Definition max22200_registers.hpp:159
constexpr uint32_t kHitShift
HIT[6:0] at bits 22:16.
Definition max22200_registers.hpp:118
constexpr uint32_t kSrc
SRC: slew-rate controlled edges.
Definition max22200_registers.hpp:124
constexpr uint32_t kDpmUsedMask
Bits 31:15 "must be set at zero".
Definition max22200_registers.hpp:164
constexpr uint32_t kComer
COMER: a write had the wrong number of clocks.
Definition max22200_registers.hpp:93
constexpr uint32_t kDpmIpthShift
DPM_IPTH[3:0] at bits 3:0.
Definition max22200_registers.hpp:162
constexpr uint32_t kActive
ACTIVE: 0 = low-power, channels Hi-Z (reset).
Definition max22200_registers.hpp:97
constexpr uint32_t kHhfEn
HHF_EN: HIT-current check.
Definition max22200_registers.hpp:127
constexpr uint32_t kDpmTdebShift
DPM_TDEB[3:0] at bits 7:4.
Definition max22200_registers.hpp:160
constexpr uint32_t kMaskUvm
M_UVM.
Definition max22200_registers.hpp:79
constexpr uint32_t kMaskOcp
M_OCP.
Definition max22200_registers.hpp:74
constexpr uint32_t kFreqm
FREQM: 0 = 100 kHz, 1 = 80 kHz oscillator.
Definition max22200_registers.hpp:80
constexpr uint32_t kDpmIstartShift
DPM_ISTART[6:0] at bits 14:8.
Definition max22200_registers.hpp:158
constexpr uint32_t kOlf
OLF flag: some channel has an OLF bit in FAULT.
Definition max22200_registers.hpp:87
constexpr uint32_t kFaultHhfShift
HHF[7:0].
Definition max22200_registers.hpp:133
constexpr uint32_t kMaskComf
M_COMF; 1 at reset (COMER masked).
Definition max22200_registers.hpp:78
constexpr uint32_t kDpmTdebMask
DPM_TDEB width.
Definition max22200_registers.hpp:161
constexpr uint32_t kFreqCfgShift
FREQ_CFG[1:0] at bits 5:4.
Definition max22200_registers.hpp:123
constexpr uint32_t kWakeUpUs
tWU max: ACTIVE = 1 to outputs active.
Definition max22200_registers.hpp:168
constexpr uint32_t kOcp
OCP flag: some channel has an OCP bit in FAULT.
Definition max22200_registers.hpp:85
constexpr uint32_t kMaskDpm
M_DPM.
Definition max22200_registers.hpp:77
constexpr uint32_t kUvm
Definition max22200_registers.hpp:95
constexpr uint32_t kFaultOlfShift
OLF[7:0].
Definition max22200_registers.hpp:134
constexpr uint32_t kCodeMask
Width of HIT and HOLD.
Definition max22200_registers.hpp:128
constexpr uint32_t kHsnls
HSnLS: 1 = high side (VDR only).
Definition max22200_registers.hpp:122
constexpr uint32_t kMaskHhf
M_HHF.
Definition max22200_registers.hpp:76
constexpr const char * GetDriverVersion() noexcept
Definition max22200_types.hpp:1093
constexpr bool ValidLoadDiagnostics(const ChannelConfig &c, uint8_t loaded_channels, uint8_t channel) noexcept
Check that a channel enables a load-dependent diagnostic only when a load is declared on it (handbook...
Definition max22200_types.hpp:966
constexpr uint8_t kChannels
Channels of the chip.
Definition max22200_types.hpp:334
constexpr uint32_t EncodeChannel(const ChannelConfig &c) noexcept
Encode a channel configuration as its CFG_CHn value (Table 11).
Definition max22200_types.hpp:608
constexpr bool ValidCode(uint8_t code, DriveMode drive) noexcept
Check a HIT or HOLD code against its channel's drive mode.
Definition max22200_types.hpp:914
constexpr uint8_t kPairs
Channel pairs (0-1, 2-3, 4-5, 6-7).
Definition max22200_types.hpp:336
constexpr Result< PairMode > DecodePairMode(uint32_t status, uint8_t pair) noexcept
Decode one pair's CMxy field of a STATUS value. The field is two bits wide but only 0 to 2 are modes ...
Definition max22200_types.hpp:701
constexpr uint32_t kDefaultWakeTimeoutUs
Definition max22200_types.hpp:364
BridgeState
The state of a pair in PairMode::FullBridge (Table 7).
Definition max22200_types.hpp:279
constexpr uint32_t EncodeStatus(const Config &config, uint8_t on_mask, bool active) noexcept
The STATUS value the driver writes (Table 10): ONCH, the masks, FREQM, CMxy and ACTIVE.
Definition max22200_types.hpp:654
constexpr uint8_t kHitTimeNone
HIT_T code for no HIT phase (Table 5).
Definition max22200_types.hpp:343
constexpr const char * ToString(Error error) noexcept
The name of an error, for logs.
Definition max22200_types.hpp:96
constexpr uint32_t kKfs
KFS with HFS = 0, in A/A (Electrical Characteristics, KFS0): IFS = KFS x 1 V / RREF.
Definition max22200_types.hpp:358
constexpr ChannelConfig DecodeChannel(uint32_t v) noexcept
Decode a CFG_CHn value (Table 11).
Definition max22200_types.hpp:630
constexpr Status DecodeStatus(uint32_t v) noexcept
Decode a STATUS value.
Definition max22200_types.hpp:678
constexpr uint8_t kHitTimeContinuous
Definition max22200_types.hpp:348
DriveMode
How a channel regulates, VDRnCDR.
Definition max22200_types.hpp:259
constexpr DpmConfig DecodeDpm(uint32_t v) noexcept
Decode a CFG_DPM value.
Definition max22200_types.hpp:737
constexpr Result< uint32_t > HitTimeUs(uint8_t code, MasterClock clock, ChopDivider chop) noexcept
The HIT time of a code: code x 40 / fCHOP (Table 5). Exact.
Definition max22200_types.hpp:781
constexpr uint32_t kNoRref
Definition max22200_types.hpp:356
constexpr Result< uint8_t > HitTimeCode(uint32_t us, MasterClock clock, ChopDivider chop) noexcept
The HIT_T code nearest to a HIT time (Table 5).
Definition max22200_types.hpp:801
constexpr Result< uint32_t > FullScaleUa(uint32_t rref_ohm, bool half_scale) noexcept
The full-scale current IFS = KFS x 1 V / RREF ("Full-Scale Current Setting"); HFS halves KFS.
Definition max22200_types.hpp:832
constexpr Error ValidateChannel(const ChannelConfig &c, MasterClock clock) noexcept
Check one channel's configuration without touching the chip.
Definition max22200_types.hpp:937
constexpr uint32_t DebounceUs(uint8_t code, MasterClock clock, ChopDivider chop) noexcept
The DPM debounce time of a code: code / fCHOP (CFG_DPM). Exact.
Definition max22200_types.hpp:820
MasterClock
The oscillator, STATUS.FREQM (global): the time base of every channel.
Definition max22200_types.hpp:245
constexpr uint32_t GetDriverVersionMajor() noexcept
Definition max22200_types.hpp:1097
constexpr uint32_t kMaxRrefOhm
Largest RREF of the recommended range, in ohms.
Definition max22200_types.hpp:352
Verify
Extra verification for one call, chosen per call (handbook KB-ARCH-041).
Definition max22200_types.hpp:224
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition max22200_types.hpp:39
constexpr uint32_t kMaxWakeTimeoutUs
Longest Config::wake_timeout_us: 10 s.
Definition max22200_types.hpp:368
Variant
Which part is fitted. The chip cannot tell, so it is configured: the two differ only in how a FAULT r...
Definition max22200_types.hpp:239
constexpr uint32_t GetDriverVersionPatch() noexcept
Definition max22200_types.hpp:1105
constexpr uint32_t kWakePollUs
Definition max22200_types.hpp:371
constexpr uint8_t kMaxVdrCode
Highest VDR duty code: 100 is 100 % (Table 3); 101 to 127 mean the same and are refused.
Definition max22200_types.hpp:341
PairMode
What a channel pair does, CMxy in STATUS ("Supported Driver Configurations").
Definition max22200_types.hpp:272
constexpr Result< uint8_t > DpmCurrentCode(uint32_t ma, uint32_t rref_ohm, uint8_t max_code) noexcept
The DPM_ISTART or DPM_IPTH code nearest to a current: current x 127 / IFS (CFG_DPM; note 127 here,...
Definition max22200_types.hpp:890
constexpr uint32_t EncodeDpm(const DpmConfig &d) noexcept
Encode the DPM settings as the CFG_DPM value; bits 31:15 stay 0.
Definition max22200_types.hpp:726
constexpr uint32_t ChopPeriodNs(MasterClock clock, ChopDivider chop) noexcept
One chopping period, in nanoseconds: divider / fMAIN (Table 1). Exact.
Definition max22200_types.hpp:753
constexpr uint32_t GetDriverVersionMinor() noexcept
Definition max22200_types.hpp:1101
constexpr DutyLimits DutyLimitsOf(ChopDivider chop, bool slew_rate_control) noexcept
The duty-cycle limits the chip applies to a channel (Table 2). The chip clamps the codes by itself; t...
Definition max22200_types.hpp:765
constexpr bool ValidHighSide(const ChannelConfig &c) noexcept
Check what the high side lacks ("Low-Side/High-Side Operations (HSnLS)").
Definition max22200_types.hpp:923
constexpr Result< uint32_t > CurrentUa(uint8_t code, uint32_t rref_ohm, bool half_scale) noexcept
The CDR peak current of a code: code / 128 x IFS (Table 4, "/ 2^7").
Definition max22200_types.hpp:848
ChopDivider
A channel's chopping frequency as a division of the oscillator, FREQ_CFG (Table 1).
Definition max22200_types.hpp:251
Side
Where the load is tied, HSnLS.
Definition max22200_types.hpp:266
LogLevel
Severity passed to the optional Log() hook.
Definition max22200_types.hpp:210
constexpr uint32_t kMinRrefOhm
Smallest RREF of the recommended range, in ohms ("Full-Scale Current Setting").
Definition max22200_types.hpp:350
constexpr uint8_t kMaxCdrCode
Definition max22200_types.hpp:339
constexpr uint32_t kMinWakeTimeoutUs
Shortest Config::wake_timeout_us: one tWU.
Definition max22200_types.hpp:366
constexpr Result< uint8_t > CurrentCode(uint32_t ma, uint32_t rref_ohm, bool half_scale) noexcept
The CDR code nearest to a peak current: current x 128 / IFS (Table 4).
Definition max22200_types.hpp:866
constexpr uint8_t kMaxHitTimeCode
Highest finite HIT_T code (Table 5).
Definition max22200_types.hpp:345
constexpr Faults DecodeFaults(uint32_t v) noexcept
Decode a FAULT value (Table 12).
Definition max22200_types.hpp:714
constexpr uint8_t kStartAttempts
Start-up attempts when the chip reports COMER (Figure 6: "repeat the procedure").
Definition max22200_types.hpp:360
constexpr Error Validate(const Config &config) noexcept
Check a configuration without touching the chip.
Definition max22200_types.hpp:1000
@ Forward
ONCHy = 0, ONCHx = 1: OUTx at VM, OUTy regulated with CFG_CHy.
@ Reverse
ONCHy = 1, ONCHx = 0: OUTy at VM, OUTx regulated with CFG_CHx.
@ Brake
ONCHy = 1, ONCHx = 1: both outputs at ground.
@ HiZ
ONCHy = 0, ONCHx = 0: both outputs Hi-Z.
@ Vdr
Voltage drive regulation: HIT and HOLD are PWM duty cycles in percent (Table 3).
@ Khz100
100 kHz. The reset value.
@ None
No extra transfer and no compare. The default.
@ ReadBack
Read the register back and compare it; check COMER.
@ InvalidArgument
An argument or a Config field is out of range; nothing was sent.
@ Crc
Not returned by this driver (the chip sends no CRC).
@ Bus
The port's Transfer() (or EnsureInitialized()) returned false.
@ Busy
Not returned by this driver (the chip is never busy to SPI).
@ Max22200A
Selective clear on read: only the flags whose SDI bit is high clear.
@ Max22200
Every FAULT read clears every flag, whatever SDI carries. The default.
@ Parallel
OUTx and OUTy tied together; the lower channel's CFG_CH drives both.
@ FullBridge
An H-bridge: ONCHy and ONCHx choose the state (Table 7).
@ Independent
Two half-bridges. The reset value.
@ Div1
fMAIN: 100 kHz (80 kHz).
@ Div3
fMAIN / 3: 33.3 kHz (26.7 kHz).
@ Div4
fMAIN / 4: 25 kHz (20 kHz at 80 kHz). The reset value.
@ Div2
fMAIN / 2: 50 kHz (40 kHz).
@ Low
Load from OUTn to VM. The reset value.
@ High
Load from OUTn to ground: VDR only, no SRC, HFS or DPM.
@ Warning
Something unexpected that the driver recovered from.
@ Info
Lifecycle events: initialised.
@ Debug
Detail for bring-up.
Compile-time helpers of the MAX22200 driver: exact hook matching, typed register fields and enumerati...
MAX22200 register map: the Command Register, the 32-bit register banks, their fields,...
The MAX22200 driver: everything it declares lives here; internals in detail.
Definition max22200.hpp:27
One channel's CFG_CHn register, as codes (Table 11). ChannelConfig{} is the reset value: CDR,...
Definition max22200_types.hpp:381
bool plunger_detect
DPM_EN: low side only; settings in DpmConfig.
Definition max22200_types.hpp:395
uint8_t hold
HOLD[6:0], as hit. Can change on the fly (SetHoldCode()).
Definition max22200_types.hpp:388
bool half_scale
HFS: IFS halved, RON doubled; low side only.
Definition max22200_types.hpp:391
uint8_t hit_time
HIT_T[7:0]: 0 none, 1 to 254 (HitTimeUs()), 255 continuous (Table 5).
Definition max22200_types.hpp:389
bool hit_current_check
HHF_EN: CDR only.
Definition max22200_types.hpp:396
uint8_t hit
Definition max22200_types.hpp:387
bool slew_rate_control
SRC: low side, fCHOP below 50 kHz only.
Definition max22200_types.hpp:393
friend constexpr bool operator==(const ChannelConfig &lhs, const ChannelConfig &rhs) noexcept=default
ChopDivider chop
FREQ_CFG.
Definition max22200_types.hpp:390
DriveMode drive
VDRnCDR. Changes only with every channel off.
Definition max22200_types.hpp:382
Side side
Definition max22200_types.hpp:383
bool trigger_pin
TRGnSPI: switched by TRIGA (even) or TRIGB (odd), not ONCH.
Definition max22200_types.hpp:392
bool open_load_detect
OL_EN.
Definition max22200_types.hpp:394
What the driver is told about the chip and the board. Config{} holds the reset values of STATUS and e...
Definition max22200_types.hpp:456
FaultMask fault_mask
M_OVT to M_UVM.
Definition max22200_types.hpp:471
MasterClock clock
FREQM.
Definition max22200_types.hpp:470
std::array< ChannelConfig, kChannels > channels
CFG_CH0 to CFG_CH7; index = channel.
Definition max22200_types.hpp:473
Variant variant
Definition max22200_types.hpp:457
DpmConfig dpm
CFG_DPM.
Definition max22200_types.hpp:474
uint8_t loaded_channels
Definition max22200_types.hpp:469
std::array< PairMode, kPairs > pairs
CM10, CM32, CM54, CM76; index = pair.
Definition max22200_types.hpp:472
uint32_t wake_timeout_us
Definition max22200_types.hpp:464
uint32_t rref_ohm
Definition max22200_types.hpp:461
The plunger-movement detection settings, CFG_DPM (global, for every channel with ChannelConfig::plung...
Definition max22200_types.hpp:433
uint8_t threshold
DPM_IPTH, 0 to 15: dip threshold = code x IFS / 127.
Definition max22200_types.hpp:436
friend constexpr bool operator==(const DpmConfig &lhs, const DpmConfig &rhs) noexcept=default
uint8_t debounce
DPM_TDEB, 0 to 15: chopping periods (DebounceUs()).
Definition max22200_types.hpp:435
uint8_t start
DPM_ISTART, 0 to 127: ISTART = code x IFS / 127 (DpmCurrentCode()).
Definition max22200_types.hpp:434
The duty-cycle limits the chip applies (Table 2), in percent.
Definition max22200_types.hpp:594
uint8_t max_percent
δMAX.
Definition max22200_types.hpp:596
uint8_t min_percent
δMIN.
Definition max22200_types.hpp:595
The fault masks, STATUS[23:17]: a masked fault does not pull FAULT low (its flag is still set)....
Definition max22200_types.hpp:411
bool hit_not_reached
M_HHF.
Definition max22200_types.hpp:415
bool overcurrent
M_OCP.
Definition max22200_types.hpp:413
bool open_load
M_OLF.
Definition max22200_types.hpp:414
bool overtemperature
M_OVT.
Definition max22200_types.hpp:412
bool undervoltage
M_UVM.
Definition max22200_types.hpp:418
friend constexpr bool operator==(const FaultMask &lhs, const FaultMask &rhs) noexcept=default
bool plunger
M_DPM.
Definition max22200_types.hpp:416
bool communication
M_COMF; masked at reset.
Definition max22200_types.hpp:417
The FAULT register: one byte per fault type, bit n for channel n (Table 12). Also used to say which f...
Definition max22200_types.hpp:500
static constexpr Faults All() noexcept
Definition max22200_types.hpp:507
uint8_t plunger
DPM[7:0]: no valid current dip during HIT.
Definition max22200_types.hpp:504
uint8_t hit_not_reached
HHF[7:0]: IHIT not reached by the end of tHIT.
Definition max22200_types.hpp:502
friend constexpr bool operator==(const Faults &lhs, const Faults &rhs) noexcept=default
constexpr Faults Or(const Faults &other) const noexcept
Definition max22200_types.hpp:524
uint8_t overcurrent
OCP[7:0]: the channel was switched off (turn it off, then on).
Definition max22200_types.hpp:501
constexpr bool Any() const noexcept
Definition max22200_types.hpp:511
uint8_t open_load
OLF[7:0].
Definition max22200_types.hpp:503
constexpr uint8_t Channels() const noexcept
Definition max22200_types.hpp:515
constexpr Faults And(const Faults &mask) const noexcept
Definition max22200_types.hpp:538
The flags the driver has seen since the last ClearLatchedFaults() (handbook KB-CPP-119): OVT and UVM ...
Definition max22200_types.hpp:565
bool open_load
OLF in a fault byte: some channel had an OLF flag.
Definition max22200_types.hpp:570
bool undervoltage
Definition max22200_types.hpp:567
Faults faults
Definition max22200_types.hpp:576
bool hit_not_reached
HHF in a fault byte: some channel had an HHF flag.
Definition max22200_types.hpp:571
bool plunger
DPM in a fault byte: some channel had a DPM flag.
Definition max22200_types.hpp:572
bool lost
Definition max22200_types.hpp:573
constexpr bool Any() const noexcept
Definition max22200_types.hpp:580
friend constexpr bool operator==(const LatchedFaults &lhs, const LatchedFaults &rhs) noexcept=default
bool overcurrent
OCP in a fault byte: some channel had an OCP flag.
Definition max22200_types.hpp:569
bool overtemperature
OVT seen by a STATUS read or in a fault byte.
Definition max22200_types.hpp:566
static constexpr Result Success() noexcept
Definition max22200_types.hpp:196
constexpr bool ok() const noexcept
Definition max22200_types.hpp:187
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition max22200_types.hpp:204
The value of a call, or why there is none.
Definition max22200_types.hpp:150
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition max22200_types.hpp:176
constexpr bool ok() const noexcept
Definition max22200_types.hpp:155
static constexpr Result Success(T v) noexcept
A successful result.
Definition max22200_types.hpp:168
STATUS as read (ReadStatus()): the channels that are on and the seven flags.
Definition max22200_types.hpp:478
bool overcurrent
OCP: some channel has an OCP flag in FAULT.
Definition max22200_types.hpp:481
uint8_t on_mask
ONCH[7:0]: bit n = channel n on.
Definition max22200_types.hpp:479
bool hit_not_reached
HHF: some channel has an HHF flag in FAULT.
Definition max22200_types.hpp:483
uint32_t raw
The whole register.
Definition max22200_types.hpp:488
bool active
ACTIVE.
Definition max22200_types.hpp:487
bool undervoltage
UVM: VM fell below UVLO (cleared by this read).
Definition max22200_types.hpp:486
bool plunger
DPM: some channel has a DPM flag in FAULT.
Definition max22200_types.hpp:484
bool communication
COMER: a write was ignored for its clock count.
Definition max22200_types.hpp:485
bool open_load
OLF: some channel has an OLF flag in FAULT.
Definition max22200_types.hpp:482
constexpr bool AnyFlag() const noexcept
Definition max22200_types.hpp:491
bool overtemperature
OVT (cleared by this read).
Definition max22200_types.hpp:480