MAX22200 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
Driver types

Errors, results, settings and conversions. More...

Classes

struct  max22200::Result< T >
 The value of a call, or why there is none. More...
 
struct  max22200::Result< void >
 The result of a call that returns no value. More...
 
struct  max22200::ChannelConfig
 One channel's CFG_CHn register, as codes (Table 11). ChannelConfig{} is the reset value: CDR, low side, every code 0 (no current), 25 kHz, every diagnostic off. More...
 
struct  max22200::FaultMask
 The fault masks, STATUS[23:17]: a masked fault does not pull FAULT low (its flag is still set). FaultMask{} is the reset value: only COMER masked. More...
 
struct  max22200::DpmConfig
 The plunger-movement detection settings, CFG_DPM (global, for every channel with ChannelConfig::plunger_detect). DpmConfig{} is all zero. More...
 
struct  max22200::Config
 What the driver is told about the chip and the board. Config{} holds the reset values of STATUS and every CFG_CHn (Register Details, p36, p38-39), for a part declared as Max22200 (correct on both parts) and an RREF not given. CFG_DPM has no reset values in the datasheet (p40-41): dpm is 0, the value the driver writes at start-up, not a known reset state. More...
 
struct  max22200::Status
 STATUS as read (ReadStatus()): the channels that are on and the seven flags. More...
 
struct  max22200::Faults
 The FAULT register: one byte per fault type, bit n for channel n (Table 12). Also used to say which flags ClearFaults() clears. More...
 
struct  max22200::LatchedFaults
 The flags the driver has seen since the last ClearLatchedFaults() (handbook KB-CPP-119): OVT and UVM from every 32-bit STATUS read ("Read Clears All", Register Details), the FAULT flags every FAULT read clears ("Clearing the FAULT Register"), and the summary flags of every fault byte (STATUS[7:0]) any access clocks out, at no extra I/O: the chip clears OLF when a channel switches on (p21) and HHF when it starts a new cycle (p23), so a flag can come and go between two FAULT reads. GetLatchedFaults() returns it with no I/O. More...
 
struct  max22200::DutyLimits
 The duty-cycle limits the chip applies (Table 2), in percent. More...
 

Enumerations

enum class  max22200::Error : uint8_t {
  max22200::Error::Ok = 0 , max22200::Error::NotInitialized = 1 , max22200::Error::InvalidArgument = 2 , max22200::Error::Bus = 3 ,
  max22200::Error::Timeout = 4 , max22200::Error::DeviceIdMismatch = 5 , max22200::Error::Crc = 6 , max22200::Error::Busy = 7 ,
  max22200::Error::DeviceFault = 8 , max22200::Error::Unsupported = 9 , max22200::Error::NoDevice = 16 , max22200::Error::Pin = 17 ,
  max22200::Error::CommunicationError = 18 , max22200::Error::WriteMismatch = 19 , max22200::Error::Undervoltage = 20 , max22200::Error::ChannelsActive = 21 ,
  max22200::Error::DeviceReset = 22 , max22200::Error::Uncertain = 23
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  max22200::LogLevel : uint8_t { max22200::LogLevel::Error = 0 , max22200::LogLevel::Warning , max22200::LogLevel::Info , max22200::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  max22200::Verify : uint8_t { max22200::Verify::None = 0 , max22200::Verify::ReadBack = 1 }
 Extra verification for one call, chosen per call (handbook KB-ARCH-041). More...
 
enum class  max22200::Variant : uint8_t { max22200::Variant::Max22200A = 0 , max22200::Variant::Max22200 = 1 }
 Which part is fitted. The chip cannot tell, so it is configured: the two differ only in how a FAULT read clears the flags ("Clearing the FAULT Register", Ordering Information). More...
 
enum class  max22200::MasterClock : uint8_t { max22200::MasterClock::Khz100 = 0 , max22200::MasterClock::Khz80 = 1 }
 The oscillator, STATUS.FREQM (global): the time base of every channel. More...
 
enum class  max22200::ChopDivider : uint8_t { max22200::ChopDivider::Div4 = 0 , max22200::ChopDivider::Div3 = 1 , max22200::ChopDivider::Div2 = 2 , max22200::ChopDivider::Div1 = 3 }
 A channel's chopping frequency as a division of the oscillator, FREQ_CFG (Table 1). More...
 
enum class  max22200::DriveMode : uint8_t { max22200::DriveMode::Cdr = 0 , max22200::DriveMode::Vdr = 1 }
 How a channel regulates, VDRnCDR. More...
 
enum class  max22200::Side : uint8_t { max22200::Side::Low = 0 , max22200::Side::High = 1 }
 Where the load is tied, HSnLS. More...
 
enum class  max22200::PairMode : uint8_t { max22200::PairMode::Independent = 0 , max22200::PairMode::Parallel = 1 , max22200::PairMode::FullBridge = 2 }
 What a channel pair does, CMxy in STATUS ("Supported Driver Configurations"). More...
 
enum class  max22200::BridgeState : uint8_t { max22200::BridgeState::HiZ = 0 , max22200::BridgeState::Forward = 1 , max22200::BridgeState::Reverse = 2 , max22200::BridgeState::Brake = 3 }
 The state of a pair in PairMode::FullBridge (Table 7). More...
 

Functions

constexpr const char * max22200::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr uint32_t max22200::EncodeChannel (const ChannelConfig &c) noexcept
 Encode a channel configuration as its CFG_CHn value (Table 11).
 
constexpr ChannelConfig max22200::DecodeChannel (uint32_t v) noexcept
 Decode a CFG_CHn value (Table 11).
 
constexpr uint32_t max22200::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.
 
constexpr Status max22200::DecodeStatus (uint32_t v) noexcept
 Decode a STATUS value.
 
constexpr Result< PairMode > max22200::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 (Register Details); 3 is refused, never stored as a PairMode (KB-CPP20-025).
 
constexpr Faults max22200::DecodeFaults (uint32_t v) noexcept
 Decode a FAULT value (Table 12).
 
constexpr uint32_t max22200::EncodeDpm (const DpmConfig &d) noexcept
 Encode the DPM settings as the CFG_DPM value; bits 31:15 stay 0.
 
constexpr DpmConfig max22200::DecodeDpm (uint32_t v) noexcept
 Decode a CFG_DPM value.
 
constexpr uint32_t max22200::ChopPeriodNs (MasterClock clock, ChopDivider chop) noexcept
 One chopping period, in nanoseconds: divider / fMAIN (Table 1). Exact.
 
constexpr DutyLimits max22200::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; the driver never moves a code into these limits, so 0 % and 100 % stay reachable.
 
constexpr Result< uint32_t > max22200::HitTimeUs (uint8_t code, MasterClock clock, ChopDivider chop) noexcept
 The HIT time of a code: code x 40 / fCHOP (Table 5). Exact.
 
constexpr Result< uint8_t > max22200::HitTimeCode (uint32_t us, MasterClock clock, ChopDivider chop) noexcept
 The HIT_T code nearest to a HIT time (Table 5).
 
constexpr uint32_t max22200::DebounceUs (uint8_t code, MasterClock clock, ChopDivider chop) noexcept
 The DPM debounce time of a code: code / fCHOP (CFG_DPM). Exact.
 
constexpr Result< uint32_t > max22200::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.
 
constexpr Result< uint32_t > max22200::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").
 
constexpr Result< uint8_t > max22200::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).
 
constexpr Result< uint8_t > max22200::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, 128 in Table 4). IFS with HFS = 0: the datasheet does not say that HFS scales DPM.
 
constexpr bool max22200::ValidCode (uint8_t code, DriveMode drive) noexcept
 Check a HIT or HOLD code against its channel's drive mode.
 
constexpr bool max22200::ValidHighSide (const ChannelConfig &c) noexcept
 Check what the high side lacks ("Low-Side/High-Side Operations (HSnLS)").
 
constexpr Error max22200::ValidateChannel (const ChannelConfig &c, MasterClock clock) noexcept
 Check one channel's configuration without touching the chip.
 
constexpr bool max22200::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 KB-CPP-131).
 
constexpr Error max22200::Validate (const Config &config) noexcept
 Check a configuration without touching the chip.
 
constexpr const char * max22200::GetDriverVersion () noexcept
 
constexpr uint32_t max22200::GetDriverVersionMajor () noexcept
 
constexpr uint32_t max22200::GetDriverVersionMinor () noexcept
 
constexpr uint32_t max22200::GetDriverVersionPatch () noexcept
 

Variables

constexpr uint8_t max22200::kChannels = 8
 Channels of the chip.
 
constexpr uint8_t max22200::kPairs = 4
 Channel pairs (0-1, 2-3, 4-5, 6-7).
 
constexpr uint8_t max22200::kMaxCdrCode = 126
 
constexpr uint8_t max22200::kMaxVdrCode = 100
 Highest VDR duty code: 100 is 100 % (Table 3); 101 to 127 mean the same and are refused.
 
constexpr uint8_t max22200::kHitTimeNone = 0
 HIT_T code for no HIT phase (Table 5).
 
constexpr uint8_t max22200::kMaxHitTimeCode = 254
 Highest finite HIT_T code (Table 5).
 
constexpr uint8_t max22200::kHitTimeContinuous = 255
 
constexpr uint32_t max22200::kMinRrefOhm = 15000
 Smallest RREF of the recommended range, in ohms ("Full-Scale Current Setting").
 
constexpr uint32_t max22200::kMaxRrefOhm = 100000
 Largest RREF of the recommended range, in ohms.
 
constexpr uint32_t max22200::kNoRref = 0
 
constexpr uint32_t max22200::kKfs = 15000
 KFS with HFS = 0, in A/A (Electrical Characteristics, KFS0): IFS = KFS x 1 V / RREF.
 
constexpr uint8_t max22200::kStartAttempts = 3
 Start-up attempts when the chip reports COMER (Figure 6: "repeat the procedure").
 
constexpr uint32_t max22200::kDefaultWakeTimeoutUs = 100000
 
constexpr uint32_t max22200::kMinWakeTimeoutUs = reg::kWakeUpUs
 Shortest Config::wake_timeout_us: one tWU.
 
constexpr uint32_t max22200::kMaxWakeTimeoutUs = 10000000
 Longest Config::wake_timeout_us: 10 s.
 
constexpr uint32_t max22200::kWakePollUs = 10000
 

Detailed Description

Errors, results, settings and conversions.

Enumeration Type Documentation

◆ BridgeState

enum class max22200::BridgeState : uint8_t
strong

The state of a pair in PairMode::FullBridge (Table 7).

Enumerator
HiZ 

ONCHy = 0, ONCHx = 0: both outputs Hi-Z.

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.

◆ ChopDivider

enum class max22200::ChopDivider : uint8_t
strong

A channel's chopping frequency as a division of the oscillator, FREQ_CFG (Table 1).

Enumerator
Div4 

fMAIN / 4: 25 kHz (20 kHz at 80 kHz). The reset value.

Div3 

fMAIN / 3: 33.3 kHz (26.7 kHz).

Div2 

fMAIN / 2: 50 kHz (40 kHz).

Div1 

fMAIN: 100 kHz (80 kHz).

◆ DriveMode

enum class max22200::DriveMode : uint8_t
strong

How a channel regulates, VDRnCDR.

Enumerator
Cdr 

Current drive regulation: HIT and HOLD are peak currents (Table 4). Low side only. The reset value.

Vdr 

Voltage drive regulation: HIT and HOLD are PWM duty cycles in percent (Table 3).

◆ Error

enum class max22200::Error : uint8_t
strong

Why a call failed. Every call of the driver returns one of these in its Result.

Values 0 to 9 are the shared base set; chip-specific values start at 16. The type is [[nodiscard]]: a call that returns a bare Error and is used as a statement is a warning (handbook KB-CPP20-037).

Enumerator
Ok 

The call succeeded.

NotInitialized 

EnsureInitialized() has not succeeded, Deinitialize() ran since, or a call found the chip reset (DeviceReset).

InvalidArgument 

An argument or a Config field is out of range; nothing was sent.

Bus 

The port's Transfer() (or EnsureInitialized()) returned false.

Timeout 

At start-up, ACTIVE did not read 1 within Config::wake_timeout_us with UVM clear (Figure 6, "wake-up completed?"). If it persists, cycle VM: ENABLE low is not a reset (p14, p22).

DeviceIdMismatch 

At start-up, STATUS read back differs from what was written, or the command echo of a 32-bit write is wrong: not a MAX22200 answering, or SDO or SDI broken.

Crc 

Not returned by this driver (the chip sends no CRC).

Busy 

Not returned by this driver (the chip is never busy to SPI).

DeviceFault 

Not returned by this driver: faults are data (ReadStatus(), ReadFaults()), never a failed call.

Unsupported 

The port lacks the optional hook (ReadFaultPin()), or a selective fault clear asked of a MAX22200 (only the MAX22200A has it).

NoDevice 

At start-up, STATUS read as 0xFFFFFFFF with a 0xFF fault byte: nothing drives SDO (no chip, no supply, ENABLE not reaching it).

Pin 

The port's GpioSet() could not drive CMD or ENABLE. A CMD that cannot go high would turn the command into data: nothing was sent.

CommunicationError 

COMER: the chip counted the wrong number of clocks in a write and ignored it. At start-up after kStartAttempts tries (Figure 6), each after ENABLE low and high: if it persists, cycle VM. On a running driver: the first call that sees COMER go from 0 to 1 (the write may have been an earlier call's), or a read-back that differs with COMER set.

WriteMismatch 

A register read back differs from what was written: at start-up, or with Verify::ReadBack. The chip did not take the write (a frame lost on a shared bus, a channel still on, a TRIG pin high).

Undervoltage 

At start-up, UVM was still set at Config::wake_timeout_us (the chip needs UVM cleared to enable operations, p27). VM is low, rises slowly, or UVM is stuck: the driver stays uninitialised, so retry later or treat it as a warning; a VM power cycle clears a stuck UVM.

ChannelsActive 

A setting the chip takes only with the channels off (VDRnCDR, HSnLS: every channel; CMxy: both of the pair) asked while one is on. Nothing was sent.

DeviceReset 

Any call of a running driver saw ACTIVE = 0 in a fault byte or in STATUS: a power-on reset cleared every register. Nothing more was sent to the chip; the driver is uninitialised; call EnsureInitialized() to configure the chip again.

Uncertain 

The call depends on a setting a failed write left unknown (the reply failed, so the chip may hold the old or the new value): a pair mode for a switch-on in that pair (a switch-off is never refused). Nothing was sent. Write the setting again (SetPairMode(), ApplyConfig()) or read it back with Verify::ReadBack, or switch the pair off with SetChannelsOn().

◆ LogLevel

enum class max22200::LogLevel : uint8_t
strong

Severity passed to the optional Log() hook.

Enumerator
Error 

A call failed.

Warning 

Something unexpected that the driver recovered from.

Info 

Lifecycle events: initialised.

Debug 

Detail for bring-up.

◆ MasterClock

enum class max22200::MasterClock : uint8_t
strong

The oscillator, STATUS.FREQM (global): the time base of every channel.

Enumerator
Khz100 

100 kHz. The reset value.

Khz80 

80 kHz.

◆ PairMode

enum class max22200::PairMode : uint8_t
strong

What a channel pair does, CMxy in STATUS ("Supported Driver Configurations").

Enumerator
Independent 

Two half-bridges. The reset value.

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).

◆ Side

enum class max22200::Side : uint8_t
strong

Where the load is tied, HSnLS.

Enumerator
Low 

Load from OUTn to VM. The reset value.

High 

Load from OUTn to ground: VDR only, no SRC, HFS or DPM.

◆ Variant

enum class max22200::Variant : uint8_t
strong

Which part is fitted. The chip cannot tell, so it is configured: the two differ only in how a FAULT read clears the flags ("Clearing the FAULT Register", Ordering Information).

Max22200, the default, is correct on both parts: ClearFaults() clears every flag on either, and a selective clear is refused; the two parts cannot be told apart over SPI. Choose Max22200A only when the bill of materials says the MAX22200A is fitted and a bench check shows a zero-SDI read keeps a latched flag: a selective clear sent to a MAX22200 clears every flag.

Enumerator
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.

◆ Verify

enum class max22200::Verify : uint8_t
strong

Extra verification for one call, chosen per call (handbook KB-ARCH-041).

The datasheet needs none of it: Verify::None, the default, sends only the transfers the chip needs. Verify::ReadBack reads the register back, compares it and checks the COMER flag of the read's fault byte; each call that takes it says how many transfers it adds.

Enumerator
None 

No extra transfer and no compare. The default.

ReadBack 

Read the register back and compare it; check COMER.

Function Documentation

◆ ChopPeriodNs()

constexpr uint32_t max22200::ChopPeriodNs ( MasterClock  clock,
ChopDivider  chop 
)
constexprnoexcept

One chopping period, in nanoseconds: divider / fMAIN (Table 1). Exact.

Parameters
clockFREQM.
chopFREQ_CFG.
Returns
10000 to 40000 ns at 100 kHz, 12500 to 50000 ns at 80 kHz.

◆ CurrentCode()

constexpr Result< uint8_t > max22200::CurrentCode ( uint32_t  ma,
uint32_t  rref_ohm,
bool  half_scale 
)
constexprnoexcept

The CDR code nearest to a peak current: current x 128 / IFS (Table 4).

Parameters
maThe current in milliamps; 0 for no current (code 0).
rref_ohmRREF.
half_scaleHFS of the channel.
Returns
1 to kMaxCdrCode for a non-zero current; InvalidArgument for an RREF out of range, a current that rounds to 0 (below the resolution), or one above 126/128 x IFS (code 127 is the unregulated full-on state, never a current).

◆ CurrentUa()

constexpr Result< uint32_t > max22200::CurrentUa ( uint8_t  code,
uint32_t  rref_ohm,
bool  half_scale 
)
constexprnoexcept

The CDR peak current of a code: code / 128 x IFS (Table 4, "/ 2^7").

Parameters
codeHIT or HOLD, 0 to 126.
rref_ohmRREF.
half_scaleHFS of the channel.
Returns
Microamps, rounded down (0 for code 0); InvalidArgument for code 127 (the unregulated full-on state, not a current) or an RREF out of range, kNoRref included.

◆ DebounceUs()

constexpr uint32_t max22200::DebounceUs ( uint8_t  code,
MasterClock  clock,
ChopDivider  chop 
)
constexprnoexcept

The DPM debounce time of a code: code / fCHOP (CFG_DPM). Exact.

Parameters
codeDPM_TDEB, 0 to 15.
clockFREQM.
chopFREQ_CFG of the channels that use DPM.
Returns
Microseconds, rounded down.

◆ DecodeChannel()

constexpr ChannelConfig max22200::DecodeChannel ( uint32_t  v)
constexprnoexcept

Decode a CFG_CHn value (Table 11).

Parameters
vThe register value.
Returns
The configuration it holds.

◆ DecodeDpm()

constexpr DpmConfig max22200::DecodeDpm ( uint32_t  v)
constexprnoexcept

Decode a CFG_DPM value.

Parameters
vThe register value.
Returns
The settings.

◆ DecodeFaults()

constexpr Faults max22200::DecodeFaults ( uint32_t  v)
constexprnoexcept

Decode a FAULT value (Table 12).

Parameters
vThe register value.
Returns
One byte per fault type.

◆ DecodePairMode()

constexpr Result< PairMode > max22200::DecodePairMode ( uint32_t  status,
uint8_t  pair 
)
constexprnoexcept

Decode one pair's CMxy field of a STATUS value. The field is two bits wide but only 0 to 2 are modes (Register Details); 3 is refused, never stored as a PairMode (KB-CPP20-025).

Parameters
statusThe STATUS value.
pair0 to 3.
Returns
The mode, or WriteMismatch for the reserved value 3 (a STATUS that does not hold what the driver can have written).

◆ DecodeStatus()

constexpr Status max22200::DecodeStatus ( uint32_t  v)
constexprnoexcept

Decode a STATUS value.

Parameters
vThe register value.
Returns
ONCH, the flags and ACTIVE.

◆ DpmCurrentCode()

constexpr Result< uint8_t > max22200::DpmCurrentCode ( uint32_t  ma,
uint32_t  rref_ohm,
uint8_t  max_code 
)
constexprnoexcept

The DPM_ISTART or DPM_IPTH code nearest to a current: current x 127 / IFS (CFG_DPM; note 127 here, 128 in Table 4). IFS with HFS = 0: the datasheet does not say that HFS scales DPM.

Parameters
maThe current in milliamps.
rref_ohmRREF.
max_code127 for ISTART, 15 for IPTH.
Returns
The code; InvalidArgument for an RREF out of range or a code above max_code.

◆ DutyLimitsOf()

constexpr DutyLimits max22200::DutyLimitsOf ( ChopDivider  chop,
bool  slew_rate_control 
)
constexprnoexcept

The duty-cycle limits the chip applies to a channel (Table 2). The chip clamps the codes by itself; the driver never moves a code into these limits, so 0 % and 100 % stay reachable.

Parameters
chopFREQ_CFG.
slew_rate_controlSRC.
Returns
8 to 92 % at fMAIN, 7 to 93 % with SRC, 4 to 96 % otherwise.

◆ EncodeChannel()

constexpr uint32_t max22200::EncodeChannel ( const ChannelConfig &  c)
constexprnoexcept

Encode a channel configuration as its CFG_CHn value (Table 11).

Parameters
cThe configuration; the codes are masked to their width.
Returns
The 32-bit register value.

◆ EncodeDpm()

constexpr uint32_t max22200::EncodeDpm ( const DpmConfig &  d)
constexprnoexcept

Encode the DPM settings as the CFG_DPM value; bits 31:15 stay 0.

Parameters
dThe settings; each field is masked to its width.
Returns
The register value.

◆ EncodeStatus()

constexpr uint32_t max22200::EncodeStatus ( const Config &  config,
uint8_t  on_mask,
bool  active 
)
constexprnoexcept

The STATUS value the driver writes (Table 10): ONCH, the masks, FREQM, CMxy and ACTIVE.

Parameters
configThe masks, clock and pair modes.
on_maskONCH[7:0].
activeACTIVE.
Returns
The 32-bit register value; the read-only flags are 0.

◆ FullScaleUa()

constexpr Result< uint32_t > max22200::FullScaleUa ( uint32_t  rref_ohm,
bool  half_scale 
)
constexprnoexcept

The full-scale current IFS = KFS x 1 V / RREF ("Full-Scale Current Setting"); HFS halves KFS.

Parameters
rref_ohmRREF, kMinRrefOhm to kMaxRrefOhm.
half_scaleHFS.
Returns
IFS in microamps (1000000 for 15 kohm and HFS = 0), or InvalidArgument for an RREF out of range, kNoRref included (KB-CPP-126: no sentinel value).

◆ GetDriverVersion()

constexpr const char * max22200::GetDriverVersion ( )
constexprnoexcept
Returns
The driver version, e.g. "0.1.0", from the generated max22200_version.h. No I/O.

◆ GetDriverVersionMajor()

constexpr uint32_t max22200::GetDriverVersionMajor ( )
constexprnoexcept
Returns
The major version. No I/O.

◆ GetDriverVersionMinor()

constexpr uint32_t max22200::GetDriverVersionMinor ( )
constexprnoexcept
Returns
The minor version. No I/O.

◆ GetDriverVersionPatch()

constexpr uint32_t max22200::GetDriverVersionPatch ( )
constexprnoexcept
Returns
The patch version. No I/O.

◆ HitTimeCode()

constexpr Result< uint8_t > max22200::HitTimeCode ( uint32_t  us,
MasterClock  clock,
ChopDivider  chop 
)
constexprnoexcept

The HIT_T code nearest to a HIT time (Table 5).

A time beyond the longest finite one is refused: the code above it, 255, is a HIT phase that never ends, which a rounding must never produce. For it use kHitTimeContinuous directly.

Parameters
usThe HIT time in microseconds; 0 for no HIT phase.
clockFREQM.
chopFREQ_CFG.
Returns
The code (1 to 254 for a non-zero time, never 0), or InvalidArgument above 254.5 steps.

◆ HitTimeUs()

constexpr Result< uint32_t > max22200::HitTimeUs ( uint8_t  code,
MasterClock  clock,
ChopDivider  chop 
)
constexprnoexcept

The HIT time of a code: code x 40 / fCHOP (Table 5). Exact.

Parameters
codeHIT_T, 0 to 255.
clockFREQM.
chopFREQ_CFG.
Returns
Microseconds (0 for code 0); InvalidArgument for kHitTimeContinuous, a HIT phase that never ends and so has no time (KB-CPP-126: no sentinel value).

◆ ToString()

constexpr const char * max22200::ToString ( Error  error)
constexprnoexcept

The name of an error, for logs.

Parameters
errorThe error.
Returns
A static string such as "Bus"; "Unknown" for a value that is not an enumerator.

◆ Validate()

constexpr Error max22200::Validate ( const Config &  config)
constexprnoexcept

Check a configuration without touching the chip.

Parameters
configThe configuration.
Returns
Ok, or InvalidArgument for a value that is not an enumerator, an RREF that is neither kNoRref nor in the recommended range, a wake timeout out of range, a pair mode 3, a channel ValidateChannel() refuses, a load-dependent diagnostic on a channel loaded_channels does not declare (ValidLoadDiagnostics()), or a DPM code above its width. kNoRref (RREF not given) passes: the driver works in codes, and only the milliamp conversions need RREF (they return InvalidArgument without it).

◆ ValidateChannel()

constexpr Error max22200::ValidateChannel ( const ChannelConfig &  c,
MasterClock  clock 
)
constexprnoexcept

Check one channel's configuration without touching the chip.

Parameters
cThe channel's configuration.
clockFREQM, which sets whether SRC is allowed at c.chop.
Returns
Ok, or InvalidArgument for: a value that is not an enumerator; a code out of ValidCode(); CDR on the high side (the chip ignores HSnLS in CDR); SRC, HFS or DPM on the high side; SRC at 50 kHz or above ("Slew-Rate Controlled Mode"); HHF in VDR (the check is CDR only).

◆ ValidCode()

constexpr bool max22200::ValidCode ( uint8_t  code,
DriveMode  drive 
)
constexprnoexcept

Check a HIT or HOLD code against its channel's drive mode.

Parameters
codeThe code.
driveThe channel's mode.
Returns
true for 0 to kMaxCdrCode in CDR, 0 to kMaxVdrCode in VDR.

◆ ValidHighSide()

constexpr bool max22200::ValidHighSide ( const ChannelConfig &  c)
constexprnoexcept

Check what the high side lacks ("Low-Side/High-Side Operations (HSnLS)").

Parameters
cThe channel's configuration.
Returns
true on the low side, or on the high side in VDR with no SRC, HFS or DPM.

◆ ValidLoadDiagnostics()

constexpr bool max22200::ValidLoadDiagnostics ( const ChannelConfig &  c,
uint8_t  loaded_channels,
uint8_t  channel 
)
constexprnoexcept

Check that a channel enables a load-dependent diagnostic only when a load is declared on it (handbook KB-CPP-131).

Parameters
cThe channel's configuration.
loaded_channelsConfig::loaded_channels.
channel0 to 7.
Returns
true when none of open load, plunger movement and HIT current check is on, or the channel's bit is set in loaded_channels.

Variable Documentation

◆ kDefaultWakeTimeoutUs

constexpr uint32_t max22200::kDefaultWakeTimeoutUs = 100000
inlineconstexpr

Config::wake_timeout_us by default: 100 ms. tWU is 2.5 ms at most once ACTIVE is taken, but UVM clears only once VM is above UVLO (p22), so the wake also waits for the supply ramp; the default allows a rail that settles within tens of milliseconds. Raise it for a slow supply.

◆ kHitTimeContinuous

constexpr uint8_t max22200::kHitTimeContinuous = 255
inlineconstexpr

HIT_T code for a HIT phase that never ends, "continuous IHIT" (Table 5): not a time, so HitTimeUs() refuses it.

◆ kMaxCdrCode

constexpr uint8_t max22200::kMaxCdrCode = 126
inlineconstexpr

Highest CDR current code: 127 is "HS off, LS on", the coil at full VM with no regulation (Table 4), which the driver never sends in CDR.

◆ kNoRref

constexpr uint32_t max22200::kNoRref = 0
inlineconstexpr

Config::rref_ohm when the board's RREF is not given (the default): the code-level API works, the current conversions (FullScaleUa(), CurrentCode(), CurrentUa(), DpmCurrentCode()) return InvalidArgument for it.

◆ kWakePollUs

constexpr uint32_t max22200::kWakePollUs = 10000
inlineconstexpr

Period of the wake loop (Figure 6, "wake-up completed?"): an ACTIVE write, tWU, a STATUS read, then a pause to this period.