|
HardFOC Flux V1 HAL
Unified HAL API for the HardFOC Flux valve-control platform (ESP32-S3)
|
Unified singleton entry point for the HardFOC Flux V1 platform. More...
#include <Flux.h>
Public Member Functions | |
| Flux (const Flux &)=delete | |
| Flux & | operator= (const Flux &)=delete |
| Flux (Flux &&)=delete | |
| Flux & | operator= (Flux &&)=delete |
| bool | EnsureInitialized () noexcept |
| Ensure all Flux subsystems are properly initialized. | |
| bool | IsInitialized () const noexcept |
| Check whether the system is fully initialised. | |
| bool | Shutdown () noexcept |
| Shut down all subsystems in reverse initialisation order. | |
| bool | GetSystemDiagnostics (FluxSystemDiagnostics &diagnostics) const noexcept |
| Populate a full system diagnostics snapshot. | |
| std::array< bool, kFluxManagerCount > | GetComponentInitializationStatus () const noexcept |
| Per-component init status as a bool array. | |
| size_t | GetFailedComponents (const char *out[], size_t max_count) const noexcept |
| Get the list of components that failed initialization. | |
| size_t | GetSystemWarnings (const char *out[], size_t max_count) const noexcept |
| Get accumulated system warnings. | |
| bool | CollectManagerHealth (ManagerHealthSnapshot &snapshot) noexcept |
| Collect per-manager error health into a unified snapshot. | |
| bool | CollectDiagnostics (FluxHalDiagnostics &out) const noexcept |
| Fill the board-level bring-up snapshot (managers in init order, part readiness). | |
| flux::hal::ManagerError | GetLastError () const noexcept |
| Why the last EnsureInitialized() failed: the error of the first required manager that did not come up, or ManagerError::None. | |
| uint64_t | GetSystemUptimeMs () const noexcept |
| Milliseconds elapsed since EnsureInitialized() completed. | |
| uint64_t | GetInitializationTimeMs () const noexcept |
| Time in ms that the initialisation sequence took to complete. | |
| uint32_t | GetLastResetReason () const noexcept |
| Reset reason of the previous boot, opaque to callers. | |
| uint32_t | GetFreeHeapBytes () const noexcept |
| Free bytes available in the default heap. | |
| uint32_t | GetLargestFreeHeapBlock () const noexcept |
| Largest contiguous free block in the default heap. | |
| void | SystemRestart () const noexcept |
| Trigger a software reset of the MCU. Does not return on success. | |
| void | DumpSystemStatistics () const noexcept |
| Log a comprehensive system summary to the console. | |
| bool | PerformHealthCheck () noexcept |
| Run a quick health check across all managers. | |
| const char * | GetSystemVersion () const noexcept |
| Get the Flux HAL semantic version string. | |
Static Public Member Functions | |
| static Flux & | GetInstance () noexcept |
| Access the singleton instance (Meyers singleton, thread-safe). | |
Public Attributes | |
| CommChannelsManager & | comms |
| SPI, CAN, UART (I²C not used on Flux V1) | |
| NvsManager & | nvs |
NVS (flux / flux_cal / flux_cfg) | |
| GpioManager & | gpio |
| ESP32 GPIO pins. | |
| ValveManager & | valves |
| Solenoid + proportional valve control. | |
| AdcManager & | adc |
| ADC channels (NTC, VBUS) | |
| LedManager & | leds |
| WS2812 status LED. | |
| TemperatureManager & | temp |
| Temperature sensors. | |
Private Member Functions | |
| Flux () noexcept | |
| ~Flux ()=default | |
| bool | InitializeAllComponents () noexcept |
| bool | InitializeNvs () noexcept |
| bool | InitializeComms () noexcept |
| bool | InitializeGpio () noexcept |
| bool | InitializeValves () noexcept |
| bool | InitializeAdc () noexcept |
| bool | InitializeLeds () noexcept |
| bool | InitializeTemperature () noexcept |
| void | UpdateSystemDiagnostics () noexcept |
| void | AddSystemWarning (const char *warning) noexcept |
Private Attributes | |
| std::atomic< bool > | initialized_ {false} |
| std::atomic< flux::hal::ManagerError > | last_error_ {flux::hal::ManagerError::None} |
| std::atomic< uint64_t > | initialization_start_time_ {0} |
| std::atomic< uint64_t > | initialization_end_time_ {0} |
| std::atomic< bool > | nvs_initialized_ {false} |
| std::atomic< bool > | comms_initialized_ {false} |
| std::atomic< bool > | gpio_initialized_ {false} |
| std::atomic< bool > | valves_initialized_ {false} |
| std::atomic< bool > | adc_initialized_ {false} |
| std::atomic< bool > | leds_initialized_ {false} |
| std::atomic< bool > | temp_initialized_ {false} |
| FluxSystemDiagnostics | diagnostics_ |
| const char * | failed_components_ [kMaxFailedComponents] {} |
| size_t | failed_components_count_ {0} |
| const char * | system_warnings_ [kMaxSystemWarnings] {} |
| size_t | system_warnings_count_ {0} |
Static Private Attributes | |
| static constexpr size_t | kMaxFailedComponents = kFluxManagerCount |
| static constexpr size_t | kMaxSystemWarnings = 16 |
Unified singleton entry point for the HardFOC Flux V1 platform.
Orchestrates initialisation of all subsystem managers (NVS, Comms, GPIO, Valves, ADC, LED, Temperature) in deterministic order and exposes them as public reference members for direct access. Provides system-level diagnostics, health checking, graceful shutdown, and runtime warning collection.
|
delete |
|
delete |
|
privatenoexcept |
|
privatedefault |
|
inlineprivatenoexcept |
|
noexcept |
Fill the board-level bring-up snapshot (managers in init order, part readiness).
Works before, during and after initialisation and never fails closed: it reports what is up and why the rest is not. Uses the shared flux::hal::ManagerError catalog, so codes from different managers compare.
| [out] | out | Overwritten. |
|
noexcept |
Collect per-manager error health into a unified snapshot.
| snapshot | Reference to snapshot structure to fill |
|
noexcept |
Log a comprehensive system summary to the console.
|
noexcept |
Ensure all Flux subsystems are properly initialized.
|
noexcept |
Per-component init status as a bool array.
|
noexcept |
Get the list of components that failed initialization.
| out | Output array of const char* pointers (filled with string literals) |
| max_count | Maximum entries to write |
|
noexcept |
Free bytes available in the default heap.
Wraps heap_caps_get_free_size(MALLOC_CAP_DEFAULT) on ESP32. Useful for diagnostic logging on thread-start failures (e.g. xTaskCreate returning false often correlates with heap exhaustion). Returns 0 on the unsupported test stub.
|
noexcept |
Time in ms that the initialisation sequence took to complete.
|
staticnoexcept |
Access the singleton instance (Meyers singleton, thread-safe).
|
noexcept |
Largest contiguous free block in the default heap.
Wraps heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) on ESP32. Combined with GetFreeHeapBytes() it tells you whether the heap is fragmented (free total >> largest block) or simply exhausted.
|
inlinenoexcept |
Why the last EnsureInitialized() failed: the error of the first required manager that did not come up, or ManagerError::None.
|
noexcept |
Reset reason of the previous boot, opaque to callers.
Wraps esp_reset_reason() on ESP32 today; on other MCUs an equivalent vendor enum will back this. Apps treat the return as an opaque uint32_t they can persist to NVS or print verbatim; decoding is platform-specific and lives in HAL utilities.
esp_reset_reason_t-shaped on ESP32; 0 on the unsupported test stub).
|
noexcept |
Populate a full system diagnostics snapshot.
| [out] | diagnostics | Struct filled with per-component status. |
|
noexcept |
Milliseconds elapsed since EnsureInitialized() completed.
|
noexcept |
Get the Flux HAL semantic version string.
|
noexcept |
Get accumulated system warnings.
| out | Output array of const char* pointers |
| max_count | Maximum entries to write |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
privatenoexcept |
|
inlinenoexcept |
Check whether the system is fully initialised.
|
noexcept |
Run a quick health check across all managers.
|
noexcept |
Shut down all subsystems in reverse initialisation order.
|
noexcept |
Trigger a software reset of the MCU. Does not return on success.
Wraps esp_restart() on ESP32. Apps call this from supervisor paths (e.g. app_main's recovery loop) when something has gone unrecoverably wrong. The HAL closes/flushes nothing here — the caller is responsible for any pre-reboot logging or NVS commit.
|
privatenoexcept |
| AdcManager& Flux::adc |
ADC channels (NTC, VBUS)
|
private |
| CommChannelsManager& Flux::comms |
SPI, CAN, UART (I²C not used on Flux V1)
|
private |
|
mutableprivate |
|
private |
|
private |
| GpioManager& Flux::gpio |
ESP32 GPIO pins.
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
| LedManager& Flux::leds |
WS2812 status LED.
|
private |
| NvsManager& Flux::nvs |
NVS (flux / flux_cal / flux_cfg)
|
private |
|
private |
|
private |
| TemperatureManager& Flux::temp |
Temperature sensors.
|
private |
| ValveManager& Flux::valves |
Solenoid + proportional valve control.
|
private |