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

Driver for one MAX22200 or MAX22200A on a platform port. More...

#include <max22200.hpp>

Public Member Functions

 MAX22200 (Port &port, const Config &config={}) noexcept
 Bind the driver to a port and store the configuration. No I/O, cannot fail.
 
 MAX22200 (const MAX22200 &)=delete
 One driver object per chip.
 
MAX22200 & operator= (const MAX22200 &)=delete
 One driver object per chip.
 
Lifecycle
Result< void > EnsureInitialized () noexcept
 Start the chip, once: the only way to initialise the driver.
 
bool IsInitialized () const noexcept
 
Result< void > Deinitialize () noexcept
 Switch every channel off and the chip to sleep, and mark the driver uninitialised: one STATUS write with every ONCH 0 and ACTIVE = 0 (channels Hi-Z), then ENABLE low. The outputs are Hi-Z at the latest tDIS after ENABLE falls; the call does not wait for it.
 
Result< void > ApplyConfig (const Config &config) noexcept
 Replace the configuration.
 
const Config & GetConfig () const &noexcept
 
void GetConfig () const &&=delete
 Not on a temporary driver: the reference would dangle (KB-CPP20-044).
 
Switching channels (the hot path)
Result< void > SetChannelsOn (uint8_t mask, Verify verify=Verify::None) noexcept
 Switch every channel at once: one 8-bit write of STATUS[31:24] (ONCH). A channel with trigger_pin follows its TRIG pin instead.
 
Result< void > SetChannel (uint8_t channel, bool on, Verify verify=Verify::None) noexcept
 Switch one channel, keeping the others as the driver last wrote them: the same single write as SetChannelsOn(), with no read first. In a parallel pair both channels switch.
 
Result< void > SetBridge (uint8_t pair, BridgeState state, Verify verify=Verify::None) noexcept
 Set a full-bridge pair's state (Table 7): the same single write as SetChannelsOn().
 
bool IsMiscountDetectionDegraded () const noexcept
 
uint8_t GetChannelsOn () const noexcept
 
Result< uint8_t > ReadChannelsOn () noexcept
 Read ONCH from the chip: one 8-bit read, 2 transfers. Does not change GetChannelsOn(); a channel found on that the copy says is off counts as on for the ChannelsActive check.
 
Channel and chip settings
Result< void > ConfigureChannel (uint8_t channel, const ChannelConfig &config, Verify verify=Verify::None) noexcept
 Write one channel's CFG_CHn: 32 bits, 2 transfers. Everything but the drive mode and the side can change while the channel runs (Programming Procedure, step 5c).
 
Result< void > SetHoldCode (uint8_t channel, uint8_t code, Verify verify=Verify::None) noexcept
 Change a channel's HOLD code on the fly: one 8-bit write of CFG_CHn[31:24] (HFS and HOLD), 2 transfers (Programming Procedure, step 5b). HFS is kept.
 
Result< void > SetPairMode (uint8_t pair, PairMode mode, Verify verify=Verify::None) noexcept
 Change one pair's mode: a 32-bit STATUS write, 2 transfers. The chip takes CMxy only with both channels of the pair off.
 
Result< void > SetFaultMask (const FaultMask &mask, Verify verify=Verify::None) noexcept
 Change the fault masks: a 32-bit STATUS write, 2 transfers.
 
Result< void > SetDpm (const DpmConfig &dpm, Verify verify=Verify::None) noexcept
 Write the DPM settings, CFG_DPM: 32 bits, 2 transfers.
 
Result< ChannelConfig > ReadChannelConfig (uint8_t channel) noexcept
 Read one channel's CFG_CHn from the chip: 2 transfers.
 
Diagnostics
Result< Status > ReadStatus () noexcept
 Read STATUS: 2 transfers. The read clears OVT and UVM on the chip (Register Details: "Read Clears All") and releases FAULT for them; the returned Status has them as read, and the driver ORs them into GetLatchedFaults(), as it does for its own STATUS reads.
 
Result< Faults > ReadFaults () noexcept
 Read FAULT without clearing what can be kept: 2 transfers, SDI all 0.
 
Result< Faults > ClearFaults (const Faults &which=Faults::All()) noexcept
 Read FAULT and clear the flags in which: 2 transfers. On the MAX22200A only those flags clear (selective clear on read, Figure 8); the MAX22200 clears all, so it accepts only Faults::All(). OLF also clears when the channel is switched on, HHF when it starts a new cycle. An OCP channel stays off until it is switched off and on again.
 
Result< bool > ReadFaultPin () noexcept
 Read the FAULT pin through the optional GpioRead() hook. No SPI.
 
uint8_t GetLastStatusByte () const noexcept
 The fault byte, STATUS[7:0], the chip clocked out during the last command byte or the last 8-bit write's data byte (Figure 12). No I/O, no cost: every access returns one, the one-transfer ONCH write included. 0xFF before the first access.
 
LatchedFaults GetLatchedFaults () const noexcept
 The clear-on-read flags any read of the driver took from the chip since the last ClearLatchedFaults(), the driver's own reads included (handbook KB-CPP-119). No I/O.
 
void ClearLatchedFaults () noexcept
 Empty the latch of GetLatchedFaults(). No I/O; nothing is sent to the chip.
 
Faults GetStartupFaults () const noexcept
 The FAULT flags the last start-up found and cleared: faults latched before the start (the chip may keep them across an ENABLE cycle), ORed over every start-up attempt. No I/O. Empty before the first start and after a start that found none; kept until the next start.
 
Result< uint32_t > ReadRegister (uint8_t bank) noexcept
 Read one register once: one 32-bit read, 2 transfers, no retry, no decoding and no check (handbook KB-CPP-129). For bring-up and diagnostics.
 

Detailed Description

template<SpiPort Port>
class max22200::MAX22200< Port >

Driver for one MAX22200 or MAX22200A on a platform port.

Lifecycle: construct with the configuration (no I/O), then EnsureInitialized(), the one way to start (ENABLE, tEN, the programming procedure of Figure 6, tWU, read-back of every register), use, optionally Deinitialize(). Every call that touches the chip returns Error::NotInitialized until EnsureInitialized() has succeeded; no call starts the chip as a side effect.

The driver keeps a copy of what it wrote (STATUS, the eight CFG_CHn, CFG_DPM), so switching channels is one 8-bit write and never a read-modify-write: SetChannel() costs what SetChannelsOn() costs. An access is two transfers: the command byte with CMD high, then the data with CMD low. The command stays in force until it is rewritten (p25), so an ONCH write right after another ONCH write sends only its data byte: the hot path is one transfer.

Call Transfers With Verify::ReadBack
SetChannelsOn(), SetChannel(), SetBridge() 1 after an ONCH write with nothing in between, else 2 (8-bit write of ONCH) 3 or 4
SetHoldCode() 2 (8-bit write of HFS and HOLD) 4
ConfigureChannel(), SetPairMode(), SetFaultMask(), SetDpm() 2 (32-bit write) 4
ReadStatus(), ReadFaults(), ClearFaults(), ReadChannelConfig() 2 -
ReadChannelsOn() 2 (8-bit read of ONCH) -
EnsureInitialized() 48, plus 4 per extra wake poll, 2 per ENABLE cycle that clears a COMER the wake left; repeated on a new COMER -
ApplyConfig() 2 per register that changes -
Deinitialize() 2 -
ReadRegister() 2 (one 32-bit read, no retry) -
ReadFaultPin(), GetChannelsOn(), GetLastStatusByte(), GetLatchedFaults(), GetStartupFaults(), IsMiscountDetectionDegraded() 0 -

Optional port hooks, found at compile time:

Hook Used for Without it
bool GpioRead(CtrlPin, GpioSignal&) noexcept ReadFaultPin() (the FAULT pin) ReadFaultPin() returns Unsupported
void Log(LogLevel, const char* message) noexcept One line per lifecycle event or failure Nothing is logged

A hook declared with the wrong signature (for example void GpioRead(...), or DelayUs(uint16_t)) is a compile error. DelayUs(uint32_t) noexcept is required.

What every call of a running driver checks, at no extra I/O. Every command byte clocks out the fault byte STATUS[7:0] (Figure 7), and so does an 8-bit write's data byte (Figure 12):

Template Parameters
PortYour class derived from SpiInterface<Port>.

Constructor & Destructor Documentation

◆ MAX22200()

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

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

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

Member Function Documentation

◆ ApplyConfig()

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

Replace the configuration.

Before the start it only stores it, with no I/O. On a running driver it writes each register that differs (STATUS, a CFG_CHn, CFG_DPM), in that order, with the channels' on/off state kept. variant and rref_ohm are never sent.

Parameters
configChecked with Validate(). A register a miscounted write may have missed (see the class) is written even when the copy already holds the new value.
Returns
Ok, InvalidArgument (nothing sent), ChannelsActive (it changes a drive mode or side while a channel is on, or a pair mode while one of the pair is on; nothing sent), Bus, Pin, DeviceReset or CommunicationError. After a failure GetConfig() holds what was written before it.

◆ ClearFaults()

template<SpiPort Port>
Result< Faults > max22200::MAX22200< Port >::ClearFaults ( const Faults &  which = Faults::All())
noexcept

Read FAULT and clear the flags in which: 2 transfers. On the MAX22200A only those flags clear (selective clear on read, Figure 8); the MAX22200 clears all, so it accepts only Faults::All(). OLF also clears when the channel is switched on, HHF when it starts a new cycle. An OCP channel stays off until it is switched off and on again.

The flags it clears are also ORed into GetLatchedFaults(); that latch is emptied only by ClearLatchedFaults().

Parameters
whichThe flags to clear; Faults::All() (the default) for every one.
Returns
The flags as they were before the clear, or NotInitialized, Unsupported (a selective clear on the MAX22200; nothing sent), Bus, Pin, DeviceReset or CommunicationError.

◆ ConfigureChannel()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::ConfigureChannel ( uint8_t  channel,
const ChannelConfig &  config,
Verify  verify = Verify::None 
)
noexcept

Write one channel's CFG_CHn: 32 bits, 2 transfers. Everything but the drive mode and the side can change while the channel runs (Programming Procedure, step 5c).

With Verify::ReadBack, a 32-bit read of the register follows (2 transfers): it must equal what was written, the write must have echoed its command (Figure 10), and no fault byte may show COMER.

Parameters
channel0 to 7.
configChecked with ValidateChannel() and ValidLoadDiagnostics() against Config::loaded_channels.
verifyVerify::None (the default) or Verify::ReadBack.
Returns
Ok, NotInitialized, InvalidArgument (nothing sent), ChannelsActive (the drive mode or side changes while a channel is on; nothing sent), Bus, Pin, DeviceReset, CommunicationError, and with Verify::ReadBack WriteMismatch. The driver cannot see the TRIG pins: with one high the chip ignores a mode change, which only Verify::ReadBack reports. On a read-back mismatch the driver's copy takes the value read. After a failed write or a mismatch the channel may hold either mode: any further write to it waits, with ChannelsActive, until every channel is off.

◆ Deinitialize()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::Deinitialize ( )
noexcept

Switch every channel off and the chip to sleep, and mark the driver uninitialised: one STATUS write with every ONCH 0 and ACTIVE = 0 (channels Hi-Z), then ENABLE low. The outputs are Hi-Z at the latest tDIS after ENABLE falls; the call does not wait for it.

ENABLE is driven low even if the write failed, and the driver is uninitialised afterwards whatever happened; the next EnsureInitialized() configures the chip again. On an uninitialised driver it does nothing and returns Ok.

Returns
Ok, Bus or Pin (the first failure).

◆ EnsureInitialized()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::EnsureInitialized ( )
noexcept

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

In order: Validate() the configuration (no I/O); bring the bus up; CMD high (its idle level), ENABLE high and tEN; then the programming procedure of Figure 6: read STATUS (clears UVM); wake the chip ("wake-up completed?"): a bare ACTIVE = 1 write, tWU, a STATUS read, repeated every kWakePollUs until ACTIVE reads 1 with UVM clear, for at most Config::wake_timeout_us; then write STATUS (masks, FREQM, pair modes, every channel off, ACTIVE = 1), CFG_CH0 to CFG_CH7 and CFG_DPM. Then the start-up checks: STATUS must hold what was written, and every 32-bit write must have echoed its command (Figure 10). Next FAULT is read and every flag cleared: the chip keeps its registers until a power-on reset ("Undervoltage Lockout (UVLO)", p22) and ENABLE low is not one ("Enable Logic Input", p14), so flags from before the start would hold the FAULT pin and look new (handbook KB-CPP-058); they are reported by GetStartupFaults() and in GetLatchedFaults(). Last, every CFG_CHn and CFG_DPM (bits 14:0) read back must equal what was written. COMER is read only and the datasheet does not say what clears it; a rejected wake write can set it, so it is armed only after the wake: if set then, ENABLE goes low for tDIS and high for tEN and STATUS is read again (2 transfers), kStartAttempts times at most, so that miscounts show in the session; if it still reads set the attempt relies on the read-back, and the session reads every switch-off back. A COMER in a later fault byte repeats the whole procedure, after ENABLE low for tDIS and high again for tEN (both waited in full after the pin write), kStartAttempts times at most. If every attempt fails, cycle VM. 48 transfers when the chip wakes at the first poll, 4 more per extra poll.

The start-up's STATUS reads feed the latch of GetLatchedFaults() like any other, except for UVM before the wake has completed (step 1 reads STATUS precisely to clear the power-on UVM, and the wake polls until it stays clear). The start-up does not empty the latch: a flag latched before it (the UVM of a DeviceReset, say) stays until ClearLatchedFaults().

At the wake timeout: Undervoltage with UVM still set, Timeout with UVM clear. The driver stays uninitialised with every channel off and ENABLE left high, so a retry continues the wake; retry later or report a supply fault, and cycle VM if it persists. On any other failure ENABLE is driven low again.

After it succeeds, later calls return Ok at once with no I/O; after it fails, the next call starts again from the beginning.

Returns
Ok, InvalidArgument (the configuration fails Validate(); no I/O), Bus, Pin, NoDevice, DeviceIdMismatch, WriteMismatch, Undervoltage, Timeout or CommunicationError.

◆ GetChannelsOn()

template<SpiPort Port>
uint8_t max22200::MAX22200< Port >::GetChannelsOn ( ) const
inlinenoexcept
Returns
ONCH as the driver last wrote it, bit n for channel n. No I/O.

◆ GetConfig()

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

◆ GetLastStatusByte()

template<SpiPort Port>
uint8_t max22200::MAX22200< Port >::GetLastStatusByte ( ) const
inlinenoexcept

The fault byte, STATUS[7:0], the chip clocked out during the last command byte or the last 8-bit write's data byte (Figure 12). No I/O, no cost: every access returns one, the one-transfer ONCH write included. 0xFF before the first access.

Returns
The byte; reg::kComer in it means a write since the last check was ignored.

◆ GetLatchedFaults()

template<SpiPort Port>
LatchedFaults max22200::MAX22200< Port >::GetLatchedFaults ( ) const
inlinenoexcept

The clear-on-read flags any read of the driver took from the chip since the last ClearLatchedFaults(), the driver's own reads included (handbook KB-CPP-119). No I/O.

OVT and UVM come from every 32-bit STATUS read: ReadStatus(), the read-back of SetPairMode() and SetFaultMask(), ReadRegister(reg::kStatus) and the start-up's reads. The FAULT flags come from every FAULT read, for the flags it clears: all of them on the MAX22200 (Variant::Max22200), those in which for ClearFaults() on the MAX22200A, and every flag the start-up clears. The summary flags (OVT, UVM, OCP, OLF, HHF, DPM) of every fault byte any access clocks out, the one-transfer ONCH write included, at no cost. Only ClearLatchedFaults() empties it, a restart included; the start-up does not keep the power-on UVM it clears (see EnsureInitialized()). A reply a floating SDO produces (all ones with a 0xFF fault byte) is never taken as flags: a FAULT or STATUS read that clears flags and gets one, or fails, sets lost instead (what the chip held is unknown; a genuine FAULT of 0xFFFFFFFF with a 0xFF fault byte reads the same way). An 8-bit read (ONCH, HOLD) returns neither OVT nor UVM, and the datasheet does not say it clears them; the driver assumes it does not.

Returns
The latched flags.

◆ GetStartupFaults()

template<SpiPort Port>
Faults max22200::MAX22200< Port >::GetStartupFaults ( ) const
inlinenoexcept

The FAULT flags the last start-up found and cleared: faults latched before the start (the chip may keep them across an ENABLE cycle), ORed over every start-up attempt. No I/O. Empty before the first start and after a start that found none; kept until the next start.

Returns
The flags.

◆ IsInitialized()

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

◆ IsMiscountDetectionDegraded()

template<SpiPort Port>
bool max22200::MAX22200< Port >::IsMiscountDetectionDegraded ( ) const
inlinenoexcept
Returns
true while a running driver cannot see a miscounted write: COMER read set in the last fault byte that is data (p36: it may stay set), so a new miscount would not change it. Every switch-off is then read back (2 more transfers each); use Verify::ReadBack for the other writes that must be known to land, or restart (Deinitialize(), EnsureInitialized()), which tries to clear COMER with ENABLE low (it stays degraded on a chip that keeps COMER until a power-on reset). No I/O.

◆ ReadChannelConfig()

template<SpiPort Port>
Result< ChannelConfig > max22200::MAX22200< Port >::ReadChannelConfig ( uint8_t  channel)
noexcept

Read one channel's CFG_CHn from the chip: 2 transfers.

Parameters
channel0 to 7.
Returns
The configuration, or NotInitialized, InvalidArgument, Bus, Pin, DeviceReset or CommunicationError.

◆ ReadChannelsOn()

template<SpiPort Port>
Result< uint8_t > max22200::MAX22200< Port >::ReadChannelsOn ( )
noexcept

Read ONCH from the chip: one 8-bit read, 2 transfers. Does not change GetChannelsOn(); a channel found on that the copy says is off counts as on for the ChannelsActive check.

Returns
The mask, or NotInitialized, Bus, Pin, DeviceReset or CommunicationError.

◆ ReadFaultPin()

template<SpiPort Port>
Result< bool > max22200::MAX22200< Port >::ReadFaultPin ( )
noexcept

Read the FAULT pin through the optional GpioRead() hook. No SPI.

Returns
true while the pin is asserted (an unmasked fault), or NotInitialized, Unsupported (no hook) or Pin (the hook failed).

◆ ReadFaults()

template<SpiPort Port>
Result< Faults > max22200::MAX22200< Port >::ReadFaults ( )
noexcept

Read FAULT without clearing what can be kept: 2 transfers, SDI all 0.

On the MAX22200A this clears nothing. On the MAX22200 every FAULT read clears every flag ("Clearing the FAULT Register"): a fault that arrives during the read is lost. The flags the read clears are also ORed into GetLatchedFaults().

Returns
The flags, or NotInitialized, Bus, Pin, DeviceReset or CommunicationError (the flags read are latched all the same). A failed read that clears flags sets LatchedFaults::lost.

◆ ReadRegister()

template<SpiPort Port>
Result< uint32_t > max22200::MAX22200< Port >::ReadRegister ( uint8_t  bank)
noexcept

Read one register once: one 32-bit read, 2 transfers, no retry, no decoding and no check (handbook KB-CPP-129). For bring-up and diagnostics.

SDI carries 0. Side effects are the chip's own: reading STATUS clears OVT and UVM (the driver latches them, see GetLatchedFaults()); reading FAULT clears every flag on the MAX22200 (the driver latches them when Config::variant is Variant::Max22200) and none on the MAX22200A. The fault byte the command clocked out is kept in GetLastStatusByte(). A fault byte or a STATUS that shows ACTIVE = 0 is a reset, as for every call: DeviceReset.

Parameters
bankreg::kStatus, reg::CfgChannel(n), reg::kFault or reg::kCfgDpm.
Returns
The register, MSB byte first as read, or NotInitialized, InvalidArgument (no such bank; nothing sent), Bus, Pin, DeviceReset or CommunicationError.

◆ ReadStatus()

template<SpiPort Port>
Result< Status > max22200::MAX22200< Port >::ReadStatus ( )
noexcept

Read STATUS: 2 transfers. The read clears OVT and UVM on the chip (Register Details: "Read Clears All") and releases FAULT for them; the returned Status has them as read, and the driver ORs them into GetLatchedFaults(), as it does for its own STATUS reads.

ACTIVE = 0 on a running driver, in the command's fault byte or in the register, means a power-on reset cleared every register: the driver marks itself uninitialised and returns DeviceReset (UVLO, "requires reconfiguration"), as every other call does.

Returns
The status, or NotInitialized, Bus, Pin, DeviceReset or CommunicationError.

◆ SetBridge()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetBridge ( uint8_t  pair,
BridgeState  state,
Verify  verify = Verify::None 
)
noexcept

Set a full-bridge pair's state (Table 7): the same single write as SetChannelsOn().

Parameters
pair0 to 3, in PairMode::FullBridge.
stateThe state.
verifyAs SetChannelsOn().
Returns
As SetChannelsOn(); InvalidArgument for a pair not in full-bridge mode. HiZ in a pair whose mode is in doubt is sent (both bits 0, off in every mode); any other state there returns Uncertain.

◆ SetChannel()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetChannel ( uint8_t  channel,
bool  on,
Verify  verify = Verify::None 
)
noexcept

Switch one channel, keeping the others as the driver last wrote them: the same single write as SetChannelsOn(), with no read first. In a parallel pair both channels switch.

In a pair whose mode is in doubt, on = false switches both channels of the pair off (the partner too: the one state that is off in every mode), whatever mode the copy records, and on = true returns Uncertain.

In a full-bridge pair on = false sets HiZ (both bits 0, Table 7): the partner goes off too.

Parameters
channel0 to 7; in a full-bridge pair only to switch off (use SetBridge()).
ontrue to switch it on.
verifyAs SetChannelsOn().
Returns
As SetChannelsOn().

◆ SetChannelsOn()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetChannelsOn ( uint8_t  mask,
Verify  verify = Verify::None 
)
noexcept

Switch every channel at once: one 8-bit write of STATUS[31:24] (ONCH). A channel with trigger_pin follows its TRIG pin instead.

2 transfers (command, data), or 1 (the data byte alone, CMD low) when the last access was an ONCH write without Verify::ReadBack and nothing has happened since: no other register access, no failed transfer or pin write, no ENABLE change, no COMER in a fault byte. The data byte's SDO carries STATUS[7:0] (Figure 12), kept in GetLastStatusByte() at no cost. When that byte is 0xFF (no answer: a chip that lost the command in a reset clocks nothing out) the write goes out again with its command, 2 more transfers, so the command byte shows whether the chip was reset.

With Verify::ReadBack, an 8-bit read of ONCH follows (2 more transfers): it must equal mask, and its fault byte must not show COMER. On WriteMismatch the driver's copy takes the value read.

In a pair whose mode is in doubt (see the class), a mask that changes the pair's bits switches both of its channels off; if it set a bit there, the call returns Uncertain after sending the rest of the mask, so every switch-off in it goes out. Nothing is sent when nothing changes and no channel that may still be on is asked off: one a failed write may have switched on, or one whose switch-off no fault byte with COMER clear has vouched for yet.

Parameters
maskBit n switches channel n on. Both bits of a parallel pair must be equal (Table 6).
verifyVerify::None (the default) or Verify::ReadBack.
Returns
Ok, NotInitialized, InvalidArgument (nothing sent), Bus, Pin, DeviceReset, CommunicationError (a new COMER, see the class), and with Verify::ReadBack WriteMismatch. The copy the driver keeps (GetChannelsOn()) changes only when the write went out (on a read-back mismatch it becomes what was read); after Bus the channels it would have changed count as on for the ChannelsActive check until a write succeeds.

◆ SetDpm()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetDpm ( const DpmConfig &  dpm,
Verify  verify = Verify::None 
)
noexcept

Write the DPM settings, CFG_DPM: 32 bits, 2 transfers.

Parameters
dpmThe settings.
verifyVerify::ReadBack adds a 32-bit read (2 transfers).
Returns
Ok, NotInitialized, InvalidArgument (nothing sent), Bus, Pin, DeviceReset, WriteMismatch or CommunicationError (the copy then takes the value read). Only bits 14:0 are compared: bits 31:15 are reserved, some read only with no reset value.

◆ SetFaultMask()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetFaultMask ( const FaultMask &  mask,
Verify  verify = Verify::None 
)
noexcept

Change the fault masks: a 32-bit STATUS write, 2 transfers.

Parameters
maskThe masks.
verifyAs SetPairMode().
Returns
Ok, NotInitialized, Bus, Pin, DeviceReset, WriteMismatch or CommunicationError.

◆ SetHoldCode()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetHoldCode ( uint8_t  channel,
uint8_t  code,
Verify  verify = Verify::None 
)
noexcept

Change a channel's HOLD code on the fly: one 8-bit write of CFG_CHn[31:24] (HFS and HOLD), 2 transfers (Programming Procedure, step 5b). HFS is kept.

With Verify::ReadBack, an 8-bit read of the same byte follows (2 transfers).

Parameters
channel0 to 7.
code0 to kMaxCdrCode in CDR, 0 to kMaxVdrCode in VDR; 0 to kMaxVdrCode while the channel's last ConfigureChannel() failed or read back different (either mode may apply).
verifyVerify::None (the default) or Verify::ReadBack.
Returns
Ok, NotInitialized, InvalidArgument (nothing sent), Bus, Pin, DeviceReset, CommunicationError, and with Verify::ReadBack WriteMismatch (the driver's copy of HFS and HOLD then takes the value read).

◆ SetPairMode()

template<SpiPort Port>
Result< void > max22200::MAX22200< Port >::SetPairMode ( uint8_t  pair,
PairMode  mode,
Verify  verify = Verify::None 
)
noexcept

Change one pair's mode: a 32-bit STATUS write, 2 transfers. The chip takes CMxy only with both channels of the pair off.

Parameters
pair0 to 3.
modeThe mode.
verifyVerify::ReadBack adds a 32-bit STATUS read (2 transfers; it also clears OVT and UVM on the chip, as every STATUS read does: the driver keeps them in GetLatchedFaults()).
Returns
Ok, NotInitialized, InvalidArgument, ChannelsActive (nothing sent), Bus, Pin, DeviceReset, WriteMismatch or CommunicationError (the driver's copy of STATUS then takes the value read; a pair field that reads as the reserved value 3 keeps the copy's mode).

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