HF-MAX22200 Driver 0.1.0-dev
HF-MAX22200 C++ Driver
Loading...
Searching...
No Matches
max22200::ChannelConfig Struct Reference

Channel configuration structure. More...

#include <max22200_types.hpp>

Public Member Functions

 ChannelConfig ()
 Default constructor — safe defaults.
 
void set_hit_ma (float ma)
 
void set_hold_ma (float ma)
 
void set_hit_duty_percent (float pct)
 
void set_hold_duty_percent (float pct)
 
float hit_ma () const
 
float hold_ma () const
 
float hit_duty_percent () const
 
float hold_duty_percent () const
 
uint32_t toRegister (uint32_t board_ifs_ma=0, bool master_clock_80khz=false) const
 Build 32-bit register value from user units.
 
void fromRegister (uint32_t val, uint32_t board_ifs_ma, bool master_clock_80khz_param)
 Parse a 32-bit register value into user units.
 
bool isCdr () const
 
bool isVdr () const
 
bool isLowSide () const
 
bool isHighSide () const
 
bool hasHitTime () const
 
bool isContinuousHit () const
 
bool isTriggeredBySpi () const
 
bool isTriggeredByPin () const
 
bool isHalfFullScale () const
 
bool isSlewRateControlEnabled () const
 
bool isOpenLoadDetectionEnabled () const
 
bool isPlungerMovementDetectionEnabled () const
 
bool isHitCurrentCheckEnabled () const
 
ChopFreq getChopFreq () const
 Chopping frequency config (FREQ_CFG); see ChopFreq enum.
 

Static Public Member Functions

static ChannelConfig makeSolenoidCdr (float hit_ma, float hold_ma, float hit_time_ms)
 Preset: solenoid in CDR mode (low-side, currents in mA)
 
static ChannelConfig makeSolenoidVdr (float hit_pct, float hold_pct, float hit_time_ms)
 Preset: solenoid in VDR mode (low-side, duty percent)
 

Public Attributes

float hit_setpoint
 HIT setpoint: CDR = mA, VDR = duty % (0–100)
 
float hold_setpoint
 HOLD setpoint: CDR = mA, VDR = duty % (0–100)
 
float hit_time_ms
 
bool half_full_scale
 
bool trigger_from_pin
 
DriveMode drive_mode
 Drive mode: CDR (current) or VDR (voltage)
 
SideMode side_mode
 Side mode: LOW_SIDE (CDR/VDR) or HIGH_SIDE (VDR only)
 
ChopFreq chop_freq
 Chopping frequency divider (FREQ_CFG[1:0])
 
bool slew_rate_control_enabled
 Slew rate control enable; reduces EMI; fCHOP < 50 kHz.
 
bool open_load_detection_enabled
 Open-load detection enable.
 
bool plunger_movement_detection_enabled
 Plunger movement detection enable (low-side only)
 
bool hit_current_check_enabled
 HIT current check enable (HHF fault if IHIT not reached)
 

Detailed Description

Channel configuration structure.

Stores configuration in user units (mA for CDR, % for VDR, ms for hit time) and automatically computes register values when toRegister() is called.

User Units (Primary Storage)

CDR Mode:

  • hit_setpoint and hold_setpoint are in milliamps (mA)
  • Use set_hit_ma() / set_hold_ma() or assign directly; hit_ma() / hold_ma() to read
  • Driver uses board IFS (SetBoardConfig) for mA → 7-bit in ConfigureChannel.

VDR Mode:

HIT Time:

  • hit_time_ms is in milliseconds
  • 0.0f = no HIT time
  • < 0.0f or >= 1000000.0f = continuous (infinite)
  • Requires master clock base (80 vs 100 kHz) and chop_freq for conversion to 8-bit register value. The driver supplies this from STATUS (FREQM) when calling toRegister/fromRegister; not stored on config.

Register Conversion

  • toRegister(board_ifs_ma, master_clock_80khz) computes raw from user units. Driver passes board IFS and cached STATUS master clock in ConfigureChannel.
  • fromRegister(val, board_ifs_ma, master_clock_80khz) converts raw → user units; IFS and master clock are not stored on config.

Restrictions

  • drive_mode and side_mode can only be changed when:
    • All channels are OFF (ONCHx = 0 for all channels)
    • Both TRIGA and TRIGB inputs are logic-low
  • CDR mode (drive_mode = CDR) is only supported in low-side mode (side_mode = LOW_SIDE)
  • High-side mode (side_mode = HIGH_SIDE) only supports VDR mode
  • half_full_scale is only available for low-side applications. When HFS=1, effective IFS for that channel is half of board IFS (datasheet KFS 7.5k vs 15k). toRegister/fromRegister use this effective IFS for CDR mA ↔ raw conversion so setpoints stay in real mA.
Note
See max22200_registers.hpp for detailed bit field definitions.
The driver's GetChannelConfig() passes board IFS into fromRegister(); IFS is not stored on ChannelConfig.

Constructor & Destructor Documentation

◆ ChannelConfig()

max22200::ChannelConfig::ChannelConfig ( )
inline

Member Function Documentation

◆ fromRegister()

void max22200::ChannelConfig::fromRegister ( uint32_t val,
uint32_t board_ifs_ma,
bool master_clock_80khz_param )
inline

Parse a 32-bit register value into user units.

Converts raw to mA (CDR) or % (VDR) and hit_time_ms. IFS is not stored on config.

Parameters
val32-bit register value from CFG_CHx
board_ifs_maBoard IFS in mA (for CDR raw→mA conversion)
master_clock_80khz_paramMaster clock 80 kHz base (for hit_time conversion)
Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ getChopFreq()

ChopFreq max22200::ChannelConfig::getChopFreq ( ) const
inline

Chopping frequency config (FREQ_CFG); see ChopFreq enum.

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ hasHitTime()

bool max22200::ChannelConfig::hasHitTime ( ) const
inline

◆ hit_duty_percent()

float max22200::ChannelConfig::hit_duty_percent ( ) const
inline

◆ hit_ma()

float max22200::ChannelConfig::hit_ma ( ) const
inline

◆ hold_duty_percent()

float max22200::ChannelConfig::hold_duty_percent ( ) const
inline

◆ hold_ma()

float max22200::ChannelConfig::hold_ma ( ) const
inline

◆ isCdr()

bool max22200::ChannelConfig::isCdr ( ) const
inline

◆ isContinuousHit()

bool max22200::ChannelConfig::isContinuousHit ( ) const
inline

◆ isHalfFullScale()

bool max22200::ChannelConfig::isHalfFullScale ( ) const
inline

◆ isHighSide()

bool max22200::ChannelConfig::isHighSide ( ) const
inline

◆ isHitCurrentCheckEnabled()

bool max22200::ChannelConfig::isHitCurrentCheckEnabled ( ) const
inline

◆ isLowSide()

bool max22200::ChannelConfig::isLowSide ( ) const
inline

◆ isOpenLoadDetectionEnabled()

bool max22200::ChannelConfig::isOpenLoadDetectionEnabled ( ) const
inline

◆ isPlungerMovementDetectionEnabled()

bool max22200::ChannelConfig::isPlungerMovementDetectionEnabled ( ) const
inline

◆ isSlewRateControlEnabled()

bool max22200::ChannelConfig::isSlewRateControlEnabled ( ) const
inline

◆ isTriggeredByPin()

bool max22200::ChannelConfig::isTriggeredByPin ( ) const
inline

◆ isTriggeredBySpi()

bool max22200::ChannelConfig::isTriggeredBySpi ( ) const
inline

◆ isVdr()

bool max22200::ChannelConfig::isVdr ( ) const
inline

◆ makeSolenoidCdr()

static ChannelConfig max22200::ChannelConfig::makeSolenoidCdr ( float hit_ma,
float hold_ma,
float hit_time_ms )
inlinestatic

Preset: solenoid in CDR mode (low-side, currents in mA)

Sets drive_mode=CDR, side_mode=LOW_SIDE, chop_freq=FMAIN_DIV4 and common defaults. Call SetBoardConfig() before ConfigureChannel(); driver supplies IFS and FREQM.

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ makeSolenoidVdr()

static ChannelConfig max22200::ChannelConfig::makeSolenoidVdr ( float hit_pct,
float hold_pct,
float hit_time_ms )
inlinestatic

Preset: solenoid in VDR mode (low-side, duty percent)

Sets drive_mode=VDR, side_mode=LOW_SIDE, chop_freq=FMAIN_DIV4 and common defaults. hit_pct and hold_pct are 0–100. Call SetBoardConfig() before ConfigureChannel().

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ set_hit_duty_percent()

void max22200::ChannelConfig::set_hit_duty_percent ( float pct)
inline

◆ set_hit_ma()

void max22200::ChannelConfig::set_hit_ma ( float ma)
inline

◆ set_hold_duty_percent()

void max22200::ChannelConfig::set_hold_duty_percent ( float pct)
inline

◆ set_hold_ma()

void max22200::ChannelConfig::set_hold_ma ( float ma)
inline

◆ toRegister()

uint32_t max22200::ChannelConfig::toRegister ( uint32_t board_ifs_ma = 0,
bool master_clock_80khz = false ) const
inline

Build 32-bit register value from user units.

For CDR, pass board IFS in mA (from SetBoardConfig). Driver calls this with board IFS and master clock from cached STATUS in ConfigureChannel.

Parameters
board_ifs_maBoard IFS in mA (required for CDR when > 0; 0 yields raw 0 in CDR).
master_clock_80khzMaster clock base from STATUS FREQM (false = 100 kHz, true = 80 kHz); used for hit_time conversion.
Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

Member Data Documentation

◆ chop_freq

ChopFreq max22200::ChannelConfig::chop_freq

Chopping frequency divider (FREQ_CFG[1:0])

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ drive_mode

DriveMode max22200::ChannelConfig::drive_mode

Drive mode: CDR (current) or VDR (voltage)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ half_full_scale

bool max22200::ChannelConfig::half_full_scale

Half full-scale (false=1x, true=0.5x IFS) When true: IFS halved, RON doubled; low-side only

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ hit_current_check_enabled

bool max22200::ChannelConfig::hit_current_check_enabled

HIT current check enable (HHF fault if IHIT not reached)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ hit_setpoint

float max22200::ChannelConfig::hit_setpoint

HIT setpoint: CDR = mA, VDR = duty % (0–100)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ hit_time_ms

float max22200::ChannelConfig::hit_time_ms

HIT time in milliseconds 0.0 = no HIT time < 0.0 or >= 1000000.0 = continuous (infinite)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ hold_setpoint

float max22200::ChannelConfig::hold_setpoint

HOLD setpoint: CDR = mA, VDR = duty % (0–100)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ open_load_detection_enabled

bool max22200::ChannelConfig::open_load_detection_enabled

◆ plunger_movement_detection_enabled

bool max22200::ChannelConfig::plunger_movement_detection_enabled

Plunger movement detection enable (low-side only)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ side_mode

SideMode max22200::ChannelConfig::side_mode

Side mode: LOW_SIDE (CDR/VDR) or HIGH_SIDE (VDR only)

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ slew_rate_control_enabled

bool max22200::ChannelConfig::slew_rate_control_enabled

Slew rate control enable; reduces EMI; fCHOP < 50 kHz.

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

◆ trigger_from_pin

bool max22200::ChannelConfig::trigger_from_pin

Trigger source (false=SPI ONCH, true=TRIG pin) When true: Channel controlled by TRIGA/TRIGB pins

Examples
/home/runner/work/hf-max22200-driver/hf-max22200-driver/inc/max22200_types.hpp.

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