HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
Max22200Handler Class Reference

Unified handler for MAX22200 octal solenoid/motor driver. More...

#include <Max22200Handler.h>

Collaboration diagram for Max22200Handler:
[legend]

Public Types

using DriverType = max22200::MAX22200<HalSpiMax22200Comm>
 Driver type alias.
 

Public Member Functions

 Max22200Handler (BaseSpi &spi, BaseGpio &enable, BaseGpio &cmd, BaseGpio *fault=nullptr) noexcept
 Construct MAX22200 handler.
 
 ~Max22200Handler () noexcept
 
 Max22200Handler (const Max22200Handler &)=delete
 
Max22200Handleroperator= (const Max22200Handler &)=delete
 
 Max22200Handler (Max22200Handler &&)=delete
 
Max22200Handleroperator= (Max22200Handler &&)=delete
 
max22200::DriverStatus Initialize () noexcept
 Initialize driver (ENABLE HIGH, read/clear STATUS, set ACTIVE).
 
bool EnsureInitialized () noexcept
 Ensure driver is initialized (lazy init entrypoint).
 
max22200::DriverStatus Initialize (const max22200::BoardConfig &board_config) noexcept
 Initialize with board configuration.
 
max22200::DriverStatus Deinitialize () noexcept
 Deinitialize — disable all channels, ACTIVE=0, ENABLE LOW.
 
bool IsInitialized () const noexcept
 Check if initialized.
 
max22200::DriverStatus ConfigureChannel (uint8_t channel, const max22200::ChannelConfig &config) noexcept
 Configure a channel completely.
 
max22200::DriverStatus SetupCdrChannel (uint8_t channel, uint16_t hit_ma, uint16_t hold_ma, float hit_time_ms) noexcept
 Quick CDR setup with milliamp values.
 
max22200::DriverStatus SetupVdrChannel (uint8_t channel, float hit_duty_pct, float hold_duty_pct, float hit_time_ms) noexcept
 Quick VDR setup with duty cycle percentages.
 
max22200::DriverStatus EnableChannel (uint8_t channel) noexcept
 Enable a channel.
 
max22200::DriverStatus DisableChannel (uint8_t channel) noexcept
 Disable a channel.
 
max22200::DriverStatus EnableAllChannels () noexcept
 Enable all channels.
 
max22200::DriverStatus DisableAllChannels () noexcept
 Disable all channels.
 
bool IsChannelEnabled (uint8_t channel) noexcept
 Check if a channel is enabled.
 
max22200::DriverStatus SetChannelsMask (uint8_t mask) noexcept
 Set channels enabled by bitmask.
 
max22200::DriverStatus GetStatus (max22200::StatusConfig &status) noexcept
 Read the STATUS register.
 
max22200::DriverStatus GetChannelFaults (uint8_t channel, max22200::FaultStatus &faults) noexcept
 Read fault flags for a channel.
 
bool HasFault () noexcept
 Check if any fault is present.
 
max22200::DriverStatus ClearFaults () noexcept
 Clear all fault flags.
 
max22200::DriverStatus ReadFaultRegister (max22200::FaultStatus &faults) noexcept
 Read fault register into status.
 
DriverTypeGetDriver () noexcept
 Get the underlying driver for advanced operations.
 
const DriverTypeGetDriver () const noexcept
 
void DumpDiagnostics () noexcept
 Dump diagnostics to logger.
 

Static Public Attributes

static constexpr uint8_t kNumChannels = 8
 

Private Member Functions

bool EnsureInitializedLocked () noexcept
 
template<typename Fn >
auto withDriver (Fn &&fn) noexcept
 Execute a lambda with a locked, initialized driver.
 

Private Attributes

bool initialized_ {false}
 
RtosMutex mutex_
 
std::unique_ptr< HalSpiMax22200Commcomm_
 
std::unique_ptr< DriverTypedriver_
 

Detailed Description

Unified handler for MAX22200 octal solenoid/motor driver.

Provides thread-safe access to all MAX22200 driver features:

  • 8-channel output control (enable/disable)
  • CDR (Current Drive Regulation) and VDR (Voltage Drive Regulation) modes
  • HIT/HOLD current and timing configuration
  • Channel-pair modes (independent, parallel, half-bridge, full-bridge)
  • Fault monitoring and diagnostics
  • DPM (Detect Plunger Movement) configuration
  • Convenience APIs with real-unit parameters

Member Typedef Documentation

◆ DriverType

using Max22200Handler::DriverType = max22200::MAX22200<HalSpiMax22200Comm>

Driver type alias.

Constructor & Destructor Documentation

◆ Max22200Handler() [1/3]

Max22200Handler::Max22200Handler ( BaseSpi & spi,
BaseGpio & enable,
BaseGpio & cmd,
BaseGpio * fault = nullptr )
noexcept

Construct MAX22200 handler.

Parameters
spiReference to pre-configured BaseSpi (Mode 0).
enableBaseGpio for ENABLE pin (active HIGH).
cmdBaseGpio for CMD pin.
faultOptional BaseGpio for nFAULT (active LOW).
Here is the call graph for this function:

◆ ~Max22200Handler()

Max22200Handler::~Max22200Handler ( )
noexcept
Here is the call graph for this function:

◆ Max22200Handler() [2/3]

Max22200Handler::Max22200Handler ( const Max22200Handler & )
delete

◆ Max22200Handler() [3/3]

Max22200Handler::Max22200Handler ( Max22200Handler && )
delete

Member Function Documentation

◆ ClearFaults()

max22200::DriverStatus Max22200Handler::ClearFaults ( )
noexcept

Clear all fault flags.

Here is the call graph for this function:

◆ ConfigureChannel()

max22200::DriverStatus Max22200Handler::ConfigureChannel ( uint8_t channel,
const max22200::ChannelConfig & config )
noexcept

Configure a channel completely.

Parameters
channelChannel number (0-7).
configFull channel configuration.
Returns
DriverStatus::OK on success, specific error code on failure.

◆ Deinitialize()

max22200::DriverStatus Max22200Handler::Deinitialize ( )
noexcept

Deinitialize — disable all channels, ACTIVE=0, ENABLE LOW.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DisableAllChannels()

max22200::DriverStatus Max22200Handler::DisableAllChannels ( )
noexcept

Disable all channels.

Here is the call graph for this function:

◆ DisableChannel()

max22200::DriverStatus Max22200Handler::DisableChannel ( uint8_t channel)
noexcept

Disable a channel.

◆ DumpDiagnostics()

void Max22200Handler::DumpDiagnostics ( )
noexcept

Dump diagnostics to logger.

Here is the call graph for this function:

◆ EnableAllChannels()

max22200::DriverStatus Max22200Handler::EnableAllChannels ( )
noexcept

Enable all channels.

Here is the call graph for this function:

◆ EnableChannel()

max22200::DriverStatus Max22200Handler::EnableChannel ( uint8_t channel)
noexcept

Enable a channel.

◆ EnsureInitialized()

bool Max22200Handler::EnsureInitialized ( )
noexcept

Ensure driver is initialized (lazy init entrypoint).

Returns
true if initialized and ready.
Here is the call graph for this function:

◆ EnsureInitializedLocked()

bool Max22200Handler::EnsureInitializedLocked ( )
privatenoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChannelFaults()

max22200::DriverStatus Max22200Handler::GetChannelFaults ( uint8_t channel,
max22200::FaultStatus & faults )
noexcept

Read fault flags for a channel.

Parameters
channelChannel number (0-7).
[out]faultsFault status structure.
Returns
DriverStatus::OK on success.

◆ GetDriver() [1/2]

const Max22200Handler::DriverType * Max22200Handler::GetDriver ( ) const
noexcept
Here is the call graph for this function:

◆ GetDriver() [2/2]

Max22200Handler::DriverType * Max22200Handler::GetDriver ( )
noexcept

Get the underlying driver for advanced operations.

Returns
Pointer to driver, or nullptr if not initialized.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStatus()

max22200::DriverStatus Max22200Handler::GetStatus ( max22200::StatusConfig & status)
noexcept

Read the STATUS register.

Parameters
[out]statusStatus structure to fill.
Returns
DriverStatus::OK on success.

◆ HasFault()

bool Max22200Handler::HasFault ( )
noexcept

Check if any fault is present.

Here is the call graph for this function:

◆ Initialize() [1/2]

max22200::DriverStatus Max22200Handler::Initialize ( )
noexcept

Initialize driver (ENABLE HIGH, read/clear STATUS, set ACTIVE).

Returns
DriverStatus::OK on success, specific error code on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialize() [2/2]

max22200::DriverStatus Max22200Handler::Initialize ( const max22200::BoardConfig & board_config)
noexcept

Initialize with board configuration.

Parameters
board_configBoard-specific IFS and safety limits.
Returns
DriverStatus::OK on success, specific error code on failure.
Here is the call graph for this function:

◆ IsChannelEnabled()

bool Max22200Handler::IsChannelEnabled ( uint8_t channel)
noexcept

Check if a channel is enabled.

◆ IsInitialized()

bool Max22200Handler::IsInitialized ( ) const
inlinenoexcept

Check if initialized.

◆ operator=() [1/2]

Max22200Handler & Max22200Handler::operator= ( const Max22200Handler & )
delete

◆ operator=() [2/2]

Max22200Handler & Max22200Handler::operator= ( Max22200Handler && )
delete

◆ ReadFaultRegister()

max22200::DriverStatus Max22200Handler::ReadFaultRegister ( max22200::FaultStatus & faults)
noexcept

Read fault register into status.

Parameters
[out]faultsFault status.
Returns
DriverStatus::OK on success.

◆ SetChannelsMask()

max22200::DriverStatus Max22200Handler::SetChannelsMask ( uint8_t mask)
noexcept

Set channels enabled by bitmask.

Parameters
maskBitmask of channels to enable (bit 0 = CH0, etc.).

◆ SetupCdrChannel()

max22200::DriverStatus Max22200Handler::SetupCdrChannel ( uint8_t channel,
uint16_t hit_ma,
uint16_t hold_ma,
float hit_time_ms )
noexcept

Quick CDR setup with milliamp values.

Parameters
channelChannel number (0-7).
hit_maHIT current in milliamps.
hold_maHOLD current in milliamps.
hit_time_msHIT time in milliseconds.
Returns
DriverStatus::OK on success, first failing operation's error code.

◆ SetupVdrChannel()

max22200::DriverStatus Max22200Handler::SetupVdrChannel ( uint8_t channel,
float hit_duty_pct,
float hold_duty_pct,
float hit_time_ms )
noexcept

Quick VDR setup with duty cycle percentages.

Parameters
channelChannel number (0-7).
hit_duty_pctHIT duty cycle percentage.
hold_duty_pctHOLD duty cycle percentage.
hit_time_msHIT time in milliseconds.
Returns
DriverStatus::OK on success, first failing operation's error code.

◆ withDriver()

template<typename Fn >
auto Max22200Handler::withDriver ( Fn && fn)
inlineprivatenoexcept

Execute a lambda with a locked, initialized driver.

Acquires the mutex, ensures initialization, and invokes fn(*driver_). Returns a default-constructed R on failure.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ comm_

std::unique_ptr<HalSpiMax22200Comm> Max22200Handler::comm_
private

◆ driver_

std::unique_ptr<DriverType> Max22200Handler::driver_
private

◆ initialized_

bool Max22200Handler::initialized_ {false}
private

◆ kNumChannels

constexpr uint8_t Max22200Handler::kNumChannels = 8
staticconstexpr

◆ mutex_

RtosMutex Max22200Handler::mutex_
mutableprivate

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