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

Singleton class for managing multiple TMC9660 motor controllers and their interfaces. More...

#include "handlers/tmc9660/Tmc9660Handler.h"
#include "CommChannelsManager.h"
#include "RtosMutex.h"
#include "api_helpers/Tmc9660DriveObservability.h"
#include <span>
#include <array>
#include <atomic>
#include <optional>
Include dependency graph for MotorController.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Tmc9660ControlPins
 Bundle of host-side GPIO references for TMC9660 control pins. More...
 
struct  MotorMechanics
 Mechanical mapping between the motor (rotor) frame and the load (output-shaft) frame. More...
 
struct  MotorAccessStats
 TMCL access accounting per device (every batch MotorController sends on the device's behalf). More...
 
struct  MotorSystemDiagnostics
 System-level diagnostics snapshot for motor controller health monitoring. More...
 
struct  MotorSystemDiagnostics::DeviceSnapshot
 Per-device snapshot (indexed 0..MAX_TMC9660_DEVICES-1) More...
 
class  MotorController
 Singleton managing multiple TMC9660 motor controllers on Vortex V1. More...
 

Typedefs

using MotorParameterAccess = vortex::motor::ParamAccess
 One element of a batch read / write.
 
using MotorParameterWrite = vortex::motor::ParamWrite
 One entry of a parameter image.
 
using MotorTelemetrySet = vortex::motor::TelemetrySet
 Which signals a telemetry read fetches.
 
using MotorTelemetryField = vortex::motor::TelemetryField
 
using MotorTelemetrySnapshot = vortex::motor::MotorTelemetrySnapshot
 
using MotorDriveDiagnostics = vortex::motor::MotorDriveDiagnostics
 
using MotorApplyOptions = vortex::motor::ApplyOptions
 
using MotorApplyResult = vortex::motor::ApplyResult
 

Enumerations

enum class  MotorError : uint8_t {
  SUCCESS = 0 , NOT_INITIALIZED , INITIALIZATION_FAILED , DEVICE_ALREADY_EXISTS ,
  DEVICE_NOT_FOUND , INVALID_DEVICE_INDEX , CANNOT_DELETE_ONBOARD , DEPENDENCY_NOT_READY ,
  COMMUNICATION_FAILED , INVALID_PARAMETER , HANDLER_CREATION_FAILED , MUTEX_LOCK_FAILED
}
 Motor controller manager error codes for consistent error reporting. More...
 
enum class  Tmc9660HostSpiGateMode : uint8_t { Disabled = 0 , EnabledForHostSpiMotor = 1 }
 Vortex-style host SPI steering to the onboard TMC9660 (PCAL95555 outputs). More...
 

Functions

constexpr const char * MotorErrorToString (MotorError error) noexcept
 Convert MotorError to a human-readable string.
 
MotorController & GetMotorController () noexcept
 Convenience accessor — equivalent to MotorController::GetInstance().
 

Detailed Description

Singleton class for managing multiple TMC9660 motor controllers and their interfaces.

This class provides a global singleton for managing TMC9660 motor controllers, including:

Note
Since the TMC9660 driver update, handler construction requires host-side GPIO control pins (RST, DRV_EN, FAULTN, WAKE). These must be provided when creating TMC9660 devices via the Tmc9660ControlPins struct.

Typedef Documentation

◆ MotorApplyOptions

◆ MotorApplyResult

◆ MotorDriveDiagnostics

◆ MotorParameterAccess

One element of a batch read / write.

◆ MotorParameterWrite

One entry of a parameter image.

◆ MotorTelemetryField

◆ MotorTelemetrySet

Which signals a telemetry read fetches.

◆ MotorTelemetrySnapshot

Enumeration Type Documentation

◆ MotorError

enum class MotorError : uint8_t
strong

Motor controller manager error codes for consistent error reporting.

Manager-layer errors for TMC9660 device lifecycle operations (create, delete, initialize). Driver-level TMC9660 errors are handled internally by the handler.

Enumerator
SUCCESS 

Operation completed successfully.

NOT_INITIALIZED 

Manager not yet initialised.

INITIALIZATION_FAILED 

Device initialisation failed.

DEVICE_ALREADY_EXISTS 

A device already occupies this slot.

DEVICE_NOT_FOUND 

No active device at the given index.

INVALID_DEVICE_INDEX 

Device index out of valid range.

CANNOT_DELETE_ONBOARD 

Onboard device (index 0) cannot be deleted.

DEPENDENCY_NOT_READY 

Required dependency not initialised.

COMMUNICATION_FAILED 

A bus-level transfer failed.

INVALID_PARAMETER 

Null pointer or out-of-range argument.

HANDLER_CREATION_FAILED 

Heap allocation or handler init failed.

MUTEX_LOCK_FAILED 

RTOS mutex acquire timed out.

◆ Tmc9660HostSpiGateMode

enum class Tmc9660HostSpiGateMode : uint8_t
strong

Vortex-style host SPI steering to the onboard TMC9660 (PCAL95555 outputs).

On Vortex, PCAL_TMC_SPI_COMM_EN (TMC_COMM_ENn, active-low) steers the shared SPI segment: asserted (SetActive) connects the ESP32 SPI master to the TMC9660; deasserted releases that path (e.g. host UART to TMC, or TMC-local SPI) per schematic.

Enumerator
Disabled 

SPI mux released (UART motor path / idle).

EnabledForHostSpiMotor 

Host SPI to TMC9660 (PCAL_TMC_SPI_COMM_EN asserted).

Function Documentation

◆ GetMotorController()

MotorController & GetMotorController ( )
inlinenoexcept

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

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

◆ MotorErrorToString()

constexpr const char * MotorErrorToString ( MotorError  error)
constexprnoexcept

Convert MotorError to a human-readable string.

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