HardFOC Vortex V1 HAL
Unified HAL API for the HardFOC Vortex motor-control platform (ESP32-C6, TMC9660)
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions
Vortex.h File Reference

Unified API singleton for the HardFOC Vortex platform. More...

#include <array>
#include <atomic>
#include <cstdint>
#include <cstring>
#include <memory>
#include "handlers/logger/Logger.h"
#include "RtosMutex.h"
#include "VortexBootReport.h"
#include "VortexDiagnostics.h"
#include "VortexVersion.h"
Include dependency graph for Vortex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  VortexSystemDiagnostics
 Comprehensive system diagnostics for the Vortex platform. More...
 
struct  ManagerHealthEntry
 Per-manager health entry for unified error aggregation. More...
 
struct  ManagerHealthSnapshot
 Aggregated health snapshot across all Vortex managers. More...
 
class  Vortex
 Unified API singleton for the HardFOC Vortex platform. More...
 

Macros

#define VORTEX_API   Vortex::GetInstance()
 Global access macro for Vortex API.
 
#define VORTEX_API_INIT()   (Vortex::GetInstance().EnsureInitialized(), Vortex::GetInstance())
 Global access macro for Vortex API with initialization check.
 

Enumerations

enum class  VortexOnboardTmc9660Transport : std::uint8_t { Spi = 0 , Uart = 1 }
 Host physical layer used for the onboard TMC9660 during Vortex::InitializeMotors(). More...
 

Functions

Vortex & GetVortex () noexcept
 Convenience accessor — equivalent to Vortex::GetInstance().
 

Detailed Description

Unified API singleton for the HardFOC Vortex platform.

This class provides a beautiful, unified access point to all component handlers in the HardFOC Vortex system. It implements lazy initialization with proper dependency management and ensures all singletons are properly initialized in the correct order before exposing them to the user.

Author
HardFOC Team
Date
2025
Version
1.0

Key Features:

Architecture:

Initialization Order:

  1. NvsManager (flash key-value — before buses so config/cal is available early)
  2. CommChannelsManager (foundation - SPI, I2C, UART, CAN)
  3. GpioManager (depends on CommChannelsManager)
  4. LedManager (WS2812 / status — early so LED-only benches work without TMC9660)
  5. MotorController (depends on CommChannelsManager; onboard UART vs SPI via SetOnboardTmc9660Transport() before EnsureInitialized() — default is UART)
  6. AdcManager (depends on MotorController)
  7. ImuManager (depends on CommChannelsManager, GpioManager)
  8. EncoderManager (depends on CommChannelsManager, GpioManager)
  9. TemperatureManager (depends on AdcManager, MotorController)
Note
Steps 5–9 are best-effort: EnsureInitialized() succeeds when NVS, comms, GPIO, and LEDs are up; motor / sensor failures produce warnings and degraded diagnostics.

Usage Example:

// Get the Vortex API instance
// Ensure all systems are initialized
if (vortex.EnsureInitialized()) {
// Access communication channels
auto& comms = vortex.comms;
// Access GPIO management
auto& gpio = vortex.gpio;
// Access motor controllers
auto& motors = vortex.motors;
// Access IMU sensors
auto& imu = vortex.imu;
// Access encoders
auto& encoders = vortex.encoders;
// Access LED management
auto& leds = vortex.leds;
// Access temperature sensors
auto& temp = vortex.temp;
// Access ADC channels
auto& adc = vortex.adc;
// Use any of the systems
if (motors.EnsureInitialized()) {
auto* handler = motors.handler(0);
if (handler) {
// Use motor controller
}
}
}
static Vortex & GetInstance() noexcept
Get the singleton instance of Vortex API.
Definition Vortex.cpp:41
Definition Tmc9660DriveObservability.h:42
Note
This class is thread-safe and designed for concurrent access from multiple tasks.
All component handlers are accessed by reference for maximum performance.
The initialization order is carefully managed to handle dependencies correctly.

Macro Definition Documentation

◆ VORTEX_API

#define VORTEX_API   Vortex::GetInstance()

Global access macro for Vortex API.

Note
This provides a convenient way to access the Vortex API from anywhere

◆ VORTEX_API_INIT

#define VORTEX_API_INIT ( )    (Vortex::GetInstance().EnsureInitialized(), Vortex::GetInstance())

Global access macro for Vortex API with initialization check.

Note
This ensures initialization before access

Enumeration Type Documentation

◆ VortexOnboardTmc9660Transport

enum class VortexOnboardTmc9660Transport : std::uint8_t
strong

Host physical layer used for the onboard TMC9660 during Vortex::InitializeMotors().

Vortex always exposes a UART to the TMC9660. SPI to the motor IC is muxed (PCAL_TMC_SPI_COMM_EN); MotorController asserts it only for SPI handlers. Default is UART (bootloader/TMCL over UART, SPI mux released). Call SetOnboardTmc9660Transport(VortexOnboardTmc9660Transport::Spi) before EnsureInitialized() if you need TMCL over SPI instead.

Enumerator
Spi 
Uart 

Function Documentation

◆ GetVortex()

Vortex & GetVortex ( )
inlinenoexcept

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

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