HF-MAX22200 Driver 0.1.0-dev
HF-MAX22200 C++ Driver
Loading...
Searching...
No Matches
max22200_types.hpp File Reference

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

#include "max22200_registers.hpp"
#include <array>
#include <cstdint>
Include dependency graph for max22200_types.hpp:
This graph shows which files directly or indirectly include this file:

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 statistics structure. More...
 

Namespaces

namespace  max22200
 

Typedefs

using max22200::ChannelConfigArray = std::array<ChannelConfig, NUM_CHANNELS_>
 Array type for channel configurations.
 
using max22200::FaultCallback
 Callback function type for fault events.
 
using max22200::StateChangeCallback
 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 status enumeration. More...
 
enum class  max22200::ChannelState : uint8_t {
  max22200::DISABLED = 0 , max22200::ENABLED , max22200::HIT_PHASE , max22200::HOLD_PHASE ,
  max22200::FAULT
}
 Channel state enumeration. More...
 

Functions

uint32_t max22200::getChopFreqKhz (bool master_clock_80khz, ChopFreq cf)
 Get chopping frequency in kHz for conversion (FREQM + FREQ_CFG)
 
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::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 charmax22200::FaultTypeToStr (FaultType ft)
 Human-readable fault type name (for logging and tests)
 
const charmax22200::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):

  • IHIT = HIT[6:0] / 127 × IFS (for 1-126)
  • IHOLD = HOLD[6:0] / 127 × IFS (for 1-126)
  • HIT[6:0] = 0: High-side switch ON, low-side switch OFF
  • HIT[6:0] = 127: High-side switch OFF, low-side switch ON

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

  • IFS = KFS × 1V / RREF
  • KFS = 15k when HFS = 0 (full-scale, IFS up to 1A, RON = 0.2Ω)
  • KFS = 7.5k when HFS = 1 (half-scale, IFS up to 0.5A, RON = 0.4Ω)
  • RREF range: 15kΩ to 100kΩ recommended

VDR Mode (Voltage Drive Regulation)

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

  • Duty cycle = HIT[6:0]% (for 1-126, clamped to δMIN-δMAX per datasheet Table 2)
  • Duty cycle = 0% when HIT[6:0] = 0
  • Duty cycle = 100% when HIT[6:0] ≥ 100

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

HIT Time Calculation

The HIT excitation time is calculated as:

  • HIT_T[7:0] = 0: No HIT time (tHIT = 0)
  • HIT_T[7:0] = 1-254: tHIT = HIT_T[7:0] × 40 / fCHOP
  • HIT_T[7:0] = 255: Continuous IHIT (tHIT = ∞)

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.