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

Type definitions and structures for MAX22200 driver. More...

#include "max22200_registers.hpp"
#include <array>
#include <cstdint>

Go to the source code of this file.

Classes

struct  max22200::ChannelConfig
 Channel configuration structure. More...
 
struct  max22200::StatusConfig
 STATUS register structure. More...
 
struct  max22200::FaultStatus
 Per-channel fault information from FAULT register (0x09) More...
 
struct  max22200::DpmConfig
 DPM (Detection of Plunger Movement) algorithm configuration. More...
 
struct  max22200::BoardConfig
 Board/scale configuration for unit-based APIs. More...
 
struct  max22200::DutyLimits
 Duty cycle limits (δMIN, δMAX) for a given configuration. More...
 
struct  max22200::DriverStatistics
 Driver runtime statistics. More...
 

Namespaces

namespace  max22200
 

Typedefs

using max22200::ChannelConfigArray = std::array< ChannelConfig, NUM_CHANNELS_ >
 Array type for channel configurations.
 
using max22200::FaultCallback = void(*)(uint8_t channel, FaultType fault_type, void *user_data)
 Callback function type for fault events.
 
using max22200::StateChangeCallback = void(*)(uint8_t channel, ChannelState old_state, ChannelState new_state, void *user_data)
 Callback function type for channel state changes.
 

Enumerations

enum class  max22200::DriveMode : uint8_t { max22200::CDR = 0 , max22200::VDR = 1 }
 Drive mode enumeration (VDRnCDR bit in CFG_CHx[7]) More...
 
enum class  max22200::SideMode : uint8_t { max22200::LOW_SIDE = 0 , max22200::HIGH_SIDE = 1 }
 High-side / Low-side selection (HSnLS bit in CFG_CHx[6]) More...
 
enum class  max22200::ChannelMode : uint8_t { max22200::INDEPENDENT = 0 , max22200::PARALLEL = 1 , max22200::HBRIDGE = 2 }
 Channel-pair mode (CMxy bits in STATUS[15:8]) More...
 
enum class  max22200::ChopFreq : uint8_t { max22200::FMAIN_DIV4 = 0 , max22200::FMAIN_DIV3 = 1 , max22200::FMAIN_DIV2 = 2 , max22200::FMAIN = 3 }
 Chopping frequency setting (FREQ_CFG bits in CFG_CHx[5:4]) More...
 
enum class  max22200::FaultType : uint8_t {
  max22200::OCP = 0 , max22200::HHF = 1 , max22200::OLF = 2 , max22200::DPM = 3 ,
  max22200::OVT = 4 , max22200::UVM = 5 , max22200::COMER = 6
}
 Fault type enumeration. More...
 
enum class  max22200::FullBridgeState : uint8_t { max22200::HiZ = 0 , max22200::Forward = 1 , max22200::Reverse = 2 , max22200::Brake = 3 }
 Full-bridge state for a channel pair (datasheet Table 7) More...
 
enum class  max22200::DriverStatus : uint8_t {
  max22200::OK = 0 , max22200::INITIALIZATION_ERROR , max22200::COMMUNICATION_ERROR , max22200::INVALID_PARAMETER ,
  max22200::HARDWARE_FAULT , max22200::TIMEOUT
}
 Driver operation result codes. More...
 
enum class  max22200::ChannelState : uint8_t {
  max22200::DISABLED = 0 , max22200::ENABLED , max22200::HIT_PHASE , max22200::HOLD_PHASE ,
  max22200::FAULT
}
 Logical channel state for application callbacks. More...
 

Functions

uint32_t max22200::getChopFreqKhz (bool master_clock_80khz, ChopFreq cf)
 Get chopping frequency in kHz for conversion (FREQM + FREQ_CFG)
 
float max22200::getChopFreqKhzExact (bool master_clock_80khz, ChopFreq cf)
 Exact chopping frequency in kHz (FREQM + FREQ_CFG, datasheet Table 1)
 
uint8_t max22200::currentMaToRaw (uint32_t full_scale_current_ma, uint32_t ma)
 Convert current in mA to 7-bit raw value (0–127) for CDR.
 
uint8_t max22200::dutyPercentToRaw (float percent)
 Convert a VDR duty cycle in percent to the 7-bit HIT/HOLD field.
 
float max22200::dutyRawToPercent (uint8_t raw)
 Convert the 7-bit VDR HIT/HOLD field to a duty cycle in percent (datasheet Table 3)
 
uint8_t max22200::hitTimeMsToRaw (float ms, bool master_clock_80khz, ChopFreq cf)
 Convert HIT time in ms to 8-bit raw value (0–255)
 
float max22200::getMaxHitTimeMs (bool master_clock_80khz, ChopFreq cf)
 Maximum representable HIT time in ms for raw values 1–254 (255 = continuous).
 
const char * max22200::FaultTypeToStr (FaultType ft)
 Human-readable fault type name (for logging and tests)
 
const char * max22200::DriverStatusToStr (DriverStatus s)
 Return a human-readable string for DriverStatus (for logging and tests)
 

Detailed Description

Type definitions and structures for MAX22200 driver.

This file defines all data structures, enumerations, and type aliases used by the MAX22200 driver. All types match the MAX22200 datasheet register layout (Rev 1, 3/25, Document 19-100531).

Current Programming Details

CDR Mode (Current Drive Regulation)

In CDR mode, currents are programmed as fractions of the full-scale current (IFS):

The full-scale current IFS is set by an external resistor RREF on the IREF pin:

VDR Mode (Voltage Drive Regulation)

In VDR mode, HIT and HOLD values represent PWM duty cycle percentages:

Duty cycle limits (δMIN, δMAX) depend on FREQM, FREQ_CFG, and SRC settings.

HIT Time Calculation

The HIT excitation time is calculated as:

Where fCHOP is the chopping frequency (depends on FREQM and FREQ_CFG).

Chopping Frequency

The chopping frequency fCHOP depends on FREQM (STATUS[16]) and FREQ_CFG[1:0]:

FREQM FREQ_CFG fCHOP (kHz)
0 00 25
0 01 33.33
0 10 50
0 11 100
1 00 20
1 01 26.66
1 10 40
1 11 80
Note
CDR mode is only supported in low-side operation (HSnLS = 0).
High-side mode (HSnLS = 1) only supports VDR mode.
VDRnCDR and HSnLS bits can only be modified when all channels are OFF and both TRIGA and TRIGB inputs are logic-low.