HardFOC Flux V1 HAL
Unified HAL API for the HardFOC Flux valve-control platform (ESP32-S3)
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
ValveManager.h File Reference

Unified valve management system for the HardFOC Flux V1 platform. More...

#include <array>
#include <atomic>
#include <cstdint>
#include <optional>
#include <string_view>
#include "RtosMutex.h"
#include "flux_hal/flux_hal_types.hpp"
#include "handlers/max22200/Max22200Handler.h"
#include "handlers/tle92466ed/Tle92466edHandler.h"
Include dependency graph for ValveManager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ValveChannelInfo
 Compile-time channel metadata for the mapping table. More...
 
struct  ValveChannelState
 Per-channel runtime state tracked by the manager. More...
 
struct  ValveSystemDiagnostics
 Diagnostics snapshot for the entire valve subsystem. More...
 
class  ValveManager
 Unified singleton for controlling all valve channels on the Flux board. More...
 

Enumerations

enum class  hf_valve_err_t : uint8_t {
  VALVE_SUCCESS = 0 , VALVE_ERR_NOT_INITIALIZED = 1 , VALVE_ERR_DRIVER_NOT_AVAILABLE = 2 , VALVE_ERR_INVALID_CHANNEL = 3 ,
  VALVE_ERR_CHANNEL_TYPE_MISMATCH = 4 , VALVE_ERR_INVALID_PARAMETER = 5 , VALVE_ERR_NULL_POINTER = 6 , VALVE_ERR_SPI_BUS_ERROR = 10 ,
  VALVE_ERR_SPI_TIMEOUT = 11 , VALVE_ERR_SPI_TRANSFER_FAILED = 12 , VALVE_ERR_SPI_CRC_ERROR = 13 , VALVE_ERR_SPI_FRAME_ERROR = 14 ,
  VALVE_ERR_HARDWARE_FAULT = 20 , VALVE_ERR_DEVICE_NOT_RESPONDING = 21 , VALVE_ERR_WRONG_DEVICE_ID = 22 , VALVE_ERR_REGISTER_ERROR = 23 ,
  VALVE_ERR_CONFIGURATION_ERROR = 24 , VALVE_ERR_WRONG_MODE = 25 , VALVE_ERR_WRITE_TO_READ_ONLY = 26 , VALVE_ERR_TIMEOUT = 27 ,
  VALVE_ERR_MUTEX_TIMEOUT = 30 , VALVE_ERR_DEPENDENCY_NOT_READY = 31 , VALVE_ERR_UNKNOWN = 255
}
 Unified valve error codes for the HardFOC Flux V1 platform. More...
 
enum class  ValveDriverType : uint8_t { MAX22200 = 0 , TLE92466 = 1 , UNKNOWN = 0xFF }
 Identifies which driver IC backend a valve channel belongs to. More...
 
enum class  ValveChannel : uint8_t {
  SOL_CH0 = 0 , SOL_CH1 = 1 , SOL_CH2 = 2 , SOL_CH3 = 3 ,
  SOL_CH4 = 4 , SOL_CH5 = 5 , SOL_CH6 = 6 , SOL_CH7 = 7 ,
  PROP_CH0 = 8 , PROP_CH1 = 9 , PROP_CH2 = 10 , PROP_CH3 = 11 ,
  PROP_CH4 = 12 , PROP_CH5 = 13 , CHANNEL_COUNT = 14
}
 Unified valve channel identifier — covers all 14 channels. More...
 

Functions

constexpr const char * HfValveErrToString (hf_valve_err_t err) noexcept
 Convert hf_valve_err_t to a human-readable description string.
 
constexpr bool HfValveErrOk (hf_valve_err_t err) noexcept
 Check if a valve error code indicates success.
 
constexpr hf_valve_err_t TleDriverErrorToValveError (tle92466ed::DriverError e) noexcept
 Map TLE92466ED DriverError to the unified hf_valve_err_t domain.
 
constexpr hf_valve_err_t MaxDriverStatusToValveError (max22200::DriverStatus s) noexcept
 Map MAX22200 DriverStatus to the unified hf_valve_err_t domain.
 
ValveManager & GetValveManager () noexcept
 Convenience accessor — equivalent to ValveManager::GetInstance().
 

Variables

static constexpr ValveChannelInfo kValveChannelMap []
 Compile-time mapping table for all valve channels.
 
static constexpr size_t kValveChannelCount = sizeof(kValveChannelMap) / sizeof(kValveChannelMap[0])
 Total number of valve channels defined in the mapping table.
 

Detailed Description

Unified valve management system for the HardFOC Flux V1 platform.

Manages all valve outputs on the Flux board through two driver ICs:

  1. MAX22200 — 8-channel octal solenoid/motor driver
    • On/off solenoid control with CDR (current drive regulation)
    • HIT/HOLD current profiles for fast actuation
    • Best for: standard on/off solenoid valves
  2. TLE92466ED — 6-channel low-side driver with current regulation
    • Proportional current control per channel
    • PWM-based control for proportional valves
    • Best for: proportional solenoid valves, PWM-controlled actuators

The ValveManager provides a unified, type-safe API to configure and control all 14 valve channels through a single interface. Each channel is identified by a compile-time enum and its driver type is resolved at registration.

Design principles:

Author
HardFOC Team
Date
2026
Version
1.0

Enumeration Type Documentation

◆ hf_valve_err_t

enum class hf_valve_err_t : uint8_t
strong

Unified valve error codes for the HardFOC Flux V1 platform.

Captures errors from two driver ICs (MAX22200 and TLE92466ED) plus handler-level and manager-level errors through a single enumeration.

Enumerator
VALVE_SUCCESS 
VALVE_ERR_NOT_INITIALIZED 
VALVE_ERR_DRIVER_NOT_AVAILABLE 
VALVE_ERR_INVALID_CHANNEL 
VALVE_ERR_CHANNEL_TYPE_MISMATCH 
VALVE_ERR_INVALID_PARAMETER 
VALVE_ERR_NULL_POINTER 
VALVE_ERR_SPI_BUS_ERROR 
VALVE_ERR_SPI_TIMEOUT 
VALVE_ERR_SPI_TRANSFER_FAILED 
VALVE_ERR_SPI_CRC_ERROR 
VALVE_ERR_SPI_FRAME_ERROR 
VALVE_ERR_HARDWARE_FAULT 
VALVE_ERR_DEVICE_NOT_RESPONDING 
VALVE_ERR_WRONG_DEVICE_ID 
VALVE_ERR_REGISTER_ERROR 
VALVE_ERR_CONFIGURATION_ERROR 
VALVE_ERR_WRONG_MODE 
VALVE_ERR_WRITE_TO_READ_ONLY 
VALVE_ERR_TIMEOUT 
VALVE_ERR_MUTEX_TIMEOUT 
VALVE_ERR_DEPENDENCY_NOT_READY 
VALVE_ERR_UNKNOWN 

◆ ValveChannel

enum class ValveChannel : uint8_t
strong

Unified valve channel identifier — covers all 14 channels.

Channels 0‒7 → MAX22200 (octal solenoid driver) Channels 8‒13 → TLE92466ED (six-channel proportional driver)

Enumerator
SOL_CH0 
SOL_CH1 
SOL_CH2 
SOL_CH3 
SOL_CH4 
SOL_CH5 
SOL_CH6 
SOL_CH7 
PROP_CH0 
PROP_CH1 
PROP_CH2 
PROP_CH3 
PROP_CH4 
PROP_CH5 
CHANNEL_COUNT 

◆ ValveDriverType

enum class ValveDriverType : uint8_t
strong

Identifies which driver IC backend a valve channel belongs to.

Enumerator
MAX22200 

MAX22200 octal solenoid driver.

TLE92466 

TLE92466ED six-channel proportional driver.

UNKNOWN 

Function Documentation

◆ GetValveManager()

ValveManager & GetValveManager ( )
inlinenoexcept

Convenience accessor — equivalent to ValveManager::GetInstance().

Returns
Reference to the singleton ValveManager.
Here is the call graph for this function:

◆ HfValveErrOk()

constexpr bool HfValveErrOk ( hf_valve_err_t  err)
constexprnoexcept

Check if a valve error code indicates success.

Parameters
errError code to test.
Returns
true if err == VALVE_SUCCESS.
Here is the caller graph for this function:

◆ HfValveErrToString()

constexpr const char * HfValveErrToString ( hf_valve_err_t  err)
constexprnoexcept

Convert hf_valve_err_t to a human-readable description string.

Parameters
errError code to convert.
Returns
Null-terminated string representation.
Here is the caller graph for this function:

◆ MaxDriverStatusToValveError()

constexpr hf_valve_err_t MaxDriverStatusToValveError ( max22200::DriverStatus  s)
constexprnoexcept

Map MAX22200 DriverStatus to the unified hf_valve_err_t domain.

Parameters
sMAX22200 driver status.
Returns
Corresponding hf_valve_err_t.
Here is the caller graph for this function:

◆ TleDriverErrorToValveError()

constexpr hf_valve_err_t TleDriverErrorToValveError ( tle92466ed::DriverError  e)
constexprnoexcept

Map TLE92466ED DriverError to the unified hf_valve_err_t domain.

Parameters
eTLE92466ED driver error.
Returns
Corresponding hf_valve_err_t.
Here is the caller graph for this function:

Variable Documentation

◆ kValveChannelCount

constexpr size_t kValveChannelCount = sizeof(kValveChannelMap) / sizeof(kValveChannelMap[0])
staticconstexpr

Total number of valve channels defined in the mapping table.

◆ kValveChannelMap

constexpr ValveChannelInfo kValveChannelMap[]
staticconstexpr
Initial value:
= {
}
@ MAX22200
MAX22200 octal solenoid driver.
@ TLE92466
TLE92466ED six-channel proportional driver.

Compile-time mapping table for all valve channels.