MAX22200 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
max22200_types.hpp File Reference

Public types of the MAX22200 driver: errors, Result<T>, the channel and chip settings, the configuration, status and faults, and the unit conversions. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include "max22200_detail.hpp"
#include "max22200_registers.hpp"
#include "max22200_version.h"

Go to the source code of this file.

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

Namespaces

namespace  max22200
 The MAX22200 driver: everything it declares lives here; internals in detail.
 

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

Public types of the MAX22200 driver: errors, Result<T>, the channel and chip settings, the configuration, status and faults, and the unit conversions.

Everything here is plain data with no platform dependency, so handlers, tests and tools can include it without the driver template. Section, table and figure names refer to the datasheet, Analog Devices 19-100531 Rev 1 (3/25).