HardFOC Vortex V1 HAL
Unified HAL API for the HardFOC Vortex motor-control platform (ESP32-C6, TMC9660)
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
vortex::motor Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  ApplyOptions
 How ApplyParameterImage() works. More...
 
struct  ApplyResult
 What ApplyParameterImage() did. More...
 
struct  MotorDriveDiagnostics
 The four TMC9660 status words, decoded (design §1.5). Raw words are kept for anything not named. More...
 
struct  MotorTelemetrySnapshot
 Caller-owned snapshot, refreshed in place by MotorController::ReadTelemetry(). More...
 
struct  ParamAccess
 One axis-parameter access in a batch (MCU- and transport-neutral copy of the driver's type). More...
 
struct  ParamWrite
 One entry of a parameter image (design §4.1, the TMC image). More...
 

Typedefs

using Param = tmc9660::tmcl::Parameters
 
using ReplyCode = tmc9660::tmcl::ReplyCode
 

Enumerations

enum class  TelemetryField : uint8_t {
  ActualPosition = 0 , ActualVelocity , TorqueFluxActual , GeneralStatus ,
  GeneralErrors , GateDriverErrors , AdcStatus , SupplyVoltage ,
  ChipTemperature , ExternalTemperature , TotalMotorCurrent , RampVelocity ,
  RampPosition , VoltageDqActual , Iit1Sum , Iit2Sum ,
  Count
}
 The telemetry signals a snapshot carries (design §1.3, tiers C/F/S). More...
 
enum class  TelemetrySet : uint8_t { Cyclic = 0 , Status , Full }
 Which signals one ReadTelemetry() call fetches. More...
 
enum class  DriveSeverity : uint8_t { Ok = 0 , Warning , Fault }
 How serious the decoded status words are. More...
 

Functions

template<typename Driver >
size_t BatchRead (Driver &driver, std::span< ParamAccess > items) noexcept
 Read a batch (GAP, pipelined).
 
template<typename Driver >
size_t BatchWrite (Driver &driver, std::span< ParamAccess > items) noexcept
 Write a batch (SAP, pipelined; SAP is idempotent).
 
constexpr uint32_t TelemetryRequestMask (TelemetrySet set, uint32_t next_sequence) noexcept
 Fields a set asks for, given the snapshot's next sequence number (Cyclic alternates 299/300).
 
template<typename Driver >
size_t ReadTelemetry (Driver &driver, TelemetrySet set, MotorTelemetrySnapshot &snap) noexcept
 Refresh snap from one pipelined batch.
 
MotorDriveDiagnostics DecodeDriveStatus (uint32_t status, uint32_t gen_err, uint32_t gdrv, uint32_t adc) noexcept
 Decode the four status words into named conditions and a severity.
 
template<typename Driver >
bool ReadDriveDiagnostics (Driver &driver, MotorDriveDiagnostics &out) noexcept
 Read the four status words in one batch and decode them.
 
template<typename Driver >
bool ClearLatchedFlags (Driver &driver, uint32_t general_errors, uint32_t gate_driver_errors, uint32_t adc_status) noexcept
 Clear latched (write-1-to-clear) bits of the error words in one batch.
 
template<typename Driver >
ApplyResult ApplyParameterImage (Driver &driver, std::span< const ParamWrite > image, ApplyOptions opt) noexcept
 Apply a parameter image: MOTOR_TYPE first, then the rest in image order.
 

Variables

constexpr size_t kBatchChunk = 16
 Elements per pipelined chunk (bounds the stack buffer; the driver chunks again internally).
 
constexpr size_t kTelemetryFieldCount = static_cast<size_t>(TelemetryField::Count)
 
constexpr std::array< Param, kTelemetryFieldCount > kTelemetryParam
 TMC9660 parameter behind each telemetry field.
 

Typedef Documentation

◆ Param

using vortex::motor::Param = typedef tmc9660::tmcl::Parameters

◆ ReplyCode

using vortex::motor::ReplyCode = typedef tmc9660::tmcl::ReplyCode

Enumeration Type Documentation

◆ DriveSeverity

enum class vortex::motor::DriveSeverity : uint8_t
strong

How serious the decoded status words are.

Enumerator
Ok 

Nothing set that needs attention.

Warning 

Thresholds crossed or events latched; the bridge may still run.

Fault 

The chip stopped (or must stop) driving: gate-driver fault, retries failed, overtemperature.

◆ TelemetryField

enum class vortex::motor::TelemetryField : uint8_t
strong

The telemetry signals a snapshot carries (design §1.3, tiers C/F/S).

Enumerator
ActualPosition 

A:144, counts.

ActualVelocity 

A:125, chip velocity units.

TorqueFluxActual 

A:331, packed Iq (high 16) / Id (low 16), unscaled.

GeneralStatus 

A:289.

GeneralErrors 

A:299 (write-1-to-clear latches)

GateDriverErrors 

A:300.

AdcStatus 

A:301.

SupplyVoltage 

A:290, 0.1 V.

ChipTemperature 

A:296, raw (°C = v·0.01615 − 268.15)

ExternalTemperature 

A:293, raw AIN3 (NTC curve on the host)

TotalMotorCurrent 

A:231, mA.

RampVelocity 

A:69.

RampPosition 

A:70.

VoltageDqActual 

A:332, packed Ud/Uq, unscaled.

Iit1Sum 

A:226, A²·ms.

Iit2Sum 

A:229, A²·ms.

Count 

◆ TelemetrySet

enum class vortex::motor::TelemetrySet : uint8_t
strong

Which signals one ReadTelemetry() call fetches.

Enumerator
Cyclic 

The cyclic fixed slots (§2.2): 144, 125, 331, 289, and 299 / 300 on alternate calls (5 accesses).

Status 

Status, error and power/thermal words: 289, 299, 300, 301, 290, 296, 293, 231, 226, 229.

Full 

Every field.

Function Documentation

◆ ApplyParameterImage()

template<typename Driver >
ApplyResult vortex::motor::ApplyParameterImage ( Driver &  driver,
std::span< const ParamWrite >  image,
ApplyOptions  opt 
)
noexcept

Apply a parameter image: MOTOR_TYPE first, then the rest in image order.

Before MOTOR_TYPE is set, FW051V100 answers most axis parameters with REPLY_WRONG_TYPE (design §1.10), so it is written (and verified) before anything else. The rest goes kBatchChunk entries per pipelined batch. No allocation and a fixed stack footprint, whatever the image size.

Returns
The counts; ApplyResult::ok() when nothing was rejected or mismatched.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BatchRead()

template<typename Driver >
size_t vortex::motor::BatchRead ( Driver &  driver,
std::span< ParamAccess >  items 
)
noexcept

Read a batch (GAP, pipelined).

Returns
number of elements answered REPLY_OK.
Here is the caller graph for this function:

◆ BatchWrite()

template<typename Driver >
size_t vortex::motor::BatchWrite ( Driver &  driver,
std::span< ParamAccess >  items 
)
noexcept

Write a batch (SAP, pipelined; SAP is idempotent).

Returns
number of elements answered REPLY_OK.
Here is the caller graph for this function:

◆ ClearLatchedFlags()

template<typename Driver >
bool vortex::motor::ClearLatchedFlags ( Driver &  driver,
uint32_t  general_errors,
uint32_t  gate_driver_errors,
uint32_t  adc_status 
)
noexcept

Clear latched (write-1-to-clear) bits of the error words in one batch.

Parameters
general_errorsBits of A:299 to clear (0 = leave the word alone)
gate_driver_errorsBits of A:300 to clear
adc_statusBits of A:301 to clear
Returns
true if every write was accepted.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecodeDriveStatus()

MotorDriveDiagnostics vortex::motor::DecodeDriveStatus ( uint32_t  status,
uint32_t  gen_err,
uint32_t  gdrv,
uint32_t  adc 
)
inlinenoexcept

Decode the four status words into named conditions and a severity.

Here is the caller graph for this function:

◆ ReadDriveDiagnostics()

template<typename Driver >
bool vortex::motor::ReadDriveDiagnostics ( Driver &  driver,
MotorDriveDiagnostics &  out 
)
noexcept

Read the four status words in one batch and decode them.

Returns
false if a word failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadTelemetry()

template<typename Driver >
size_t vortex::motor::ReadTelemetry ( Driver &  driver,
TelemetrySet  set,
MotorTelemetrySnapshot &  snap 
)
noexcept

Refresh snap from one pipelined batch.

Returns
Number of fields read OK.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TelemetryRequestMask()

constexpr uint32_t vortex::motor::TelemetryRequestMask ( TelemetrySet  set,
uint32_t  next_sequence 
)
constexprnoexcept

Fields a set asks for, given the snapshot's next sequence number (Cyclic alternates 299/300).

Here is the caller graph for this function:

Variable Documentation

◆ kBatchChunk

constexpr size_t vortex::motor::kBatchChunk = 16
inlineconstexpr

Elements per pipelined chunk (bounds the stack buffer; the driver chunks again internally).

◆ kTelemetryFieldCount

constexpr size_t vortex::motor::kTelemetryFieldCount = static_cast<size_t>(TelemetryField::Count)
inlineconstexpr

◆ kTelemetryParam

constexpr std::array<Param, kTelemetryFieldCount> vortex::motor::kTelemetryParam
inlineconstexpr
Initial value:
{
Param::ACTUAL_POSITION, Param::ACTUAL_VELOCITY,
Param::TORQUE_FLUX_COMBINED_ACTUAL_VALUES,
Param::GENERAL_STATUS_FLAGS, Param::GENERAL_ERROR_FLAGS, Param::GDRV_ERROR_FLAGS, Param::ADC_STATUS_FLAGS,
Param::SUPPLY_VOLTAGE, Param::CHIP_TEMPERATURE, Param::EXTERNAL_TEMPERATURE,
Param::ACTUAL_TOTAL_MOTOR_CURRENT,
Param::RAMP_VELOCITY, Param::RAMP_POSITION,
Param::VOLTAGE_D_Q_COMBINED_ACTUAL_VALUES,
Param::IIT_SUM_1, Param::IIT_SUM_2,
}

TMC9660 parameter behind each telemetry field.