HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
Loading...
Searching...
No Matches
tmc9660::TMC9660< CommType >::GateDriver Struct Reference

Subsystem for configuring the MOSFET gate driver. More...

#include <tmc9660.hpp>

Collaboration diagram for tmc9660::TMC9660< CommType >::GateDriver:
[legend]

Classes

struct  PowerStageProfile
 Configuration structure for auto-configuring power stage protection. More...
 

Public Member Functions

bool setOutputPolarity (tmc9660::tmcl::PwmOutputPolarity low_side, tmc9660::tmcl::PwmOutputPolarity high_side) noexcept
 Set the gate driver output polarity.
 
bool configureBreakBeforeMakeTiming (uint8_t low_side_uvw, uint8_t high_side_uvw, uint8_t low_side_y2, uint8_t high_side_y2) noexcept
 Configure the break-before-make timing for the gate driver (advanced API).
 
bool configureBreakBeforeMakeTiming_ns (float lowSideUVW_ns, float highSideUVW_ns, float lowSideY2_ns, float highSideY2_ns) noexcept
 Configure break-before-make timing using nanoseconds (recommended API).
 
bool enableAdaptiveDriveTime (bool enable_uvw, bool enable_y2) noexcept
 Enable or disable adaptive drive time for UVW and Y2 phases.
 
bool configureDriveTimes (uint8_t sink_time_uvw, uint8_t source_time_uvw, uint8_t sink_time_y2, uint8_t source_time_y2) noexcept
 Configure drive times for UVW and Y2 phases (advanced API).
 
bool configureDriveTimes_ns (float sinkTimeUVW_ns, float sourceTimeUVW_ns, float sinkTimeY2_ns, float sourceTimeY2_ns) noexcept
 Configure drive times using nanoseconds (recommended API).
 
bool configureCurrentLimits (tmc9660::tmcl::GateCurrentSink sink_current_uvw, tmc9660::tmcl::GateCurrentSource source_current_uvw, tmc9660::tmcl::GateCurrentSink sink_current_y2, tmc9660::tmcl::GateCurrentSource source_current_y2) noexcept
 Configure gate driver current limits for UVW and Y2 phases.
 
bool configureBootstrapCurrentLimit (tmc9660::tmcl::BootstrapCurrentLimit limit) noexcept
 Configure bootstrap current limit.
 
bool configureUndervoltageProtection (tmc9660::tmcl::UndervoltageLevel supplyLevel, tmc9660::tmcl::UndervoltageEnable enable_vdrv, tmc9660::tmcl::UndervoltageEnable enable_bst_uvw, tmc9660::tmcl::UndervoltageEnable enable_bst_y2) noexcept
 Configure undervoltage protection settings.
 
bool enableOvercurrentProtection (tmc9660::tmcl::OvercurrentEnable enable_uvw_low_side, tmc9660::tmcl::OvercurrentEnable enable_uvw_high_side, tmc9660::tmcl::OvercurrentEnable enable_y2_low_side, tmc9660::tmcl::OvercurrentEnable enable_y2_high_side) noexcept
 Enable or disable overcurrent protection for UVW and Y2 phases.
 
bool setOvercurrentThresholds (tmc9660::tmcl::OvercurrentThreshold uvw_low_side_threshold, tmc9660::tmcl::OvercurrentThreshold uvw_high_side_threshold, tmc9660::tmcl::OvercurrentThreshold y2LowSideThreshold, tmc9660::tmcl::OvercurrentThreshold y2HighSideThreshold) noexcept
 Configure overcurrent protection thresholds for UVW and Y2 phases.
 
bool setOvercurrentBlanking (tmc9660::tmcl::OvercurrentTiming uvw_low_side_time, tmc9660::tmcl::OvercurrentTiming uvw_high_side_time, tmc9660::tmcl::OvercurrentTiming y2LowSideTime, tmc9660::tmcl::OvercurrentTiming y2HighSideTime) noexcept
 Configure the overcurrent protection blanking time for UVW and Y2 phases.
 
bool setOvercurrentDeglitch (tmc9660::tmcl::OvercurrentTiming uvw_low_side_time, tmc9660::tmcl::OvercurrentTiming uvw_high_side_time, tmc9660::tmcl::OvercurrentTiming y2LowSideTime, tmc9660::tmcl::OvercurrentTiming y2HighSideTime) noexcept
 Configure the overcurrent protection deglitch time for UVW and Y2 phases.
 
bool enableVdsMonitoringLow (tmc9660::tmcl::VdsUsage uvw_enable, tmc9660::tmcl::VdsUsage y2Enable) noexcept
 Enable or disable VDS monitoring for overcurrent protection on UVW and Y2 low sides.
 
bool configureVgsShortProtectionUVW (tmc9660::tmcl::VgsShortEnable enable_low_side_on, tmc9660::tmcl::VgsShortEnable enable_low_side_off, tmc9660::tmcl::VgsShortEnable enable_high_side_on, tmc9660::tmcl::VgsShortEnable enable_high_side_off) noexcept
 Configure gate-to-source short protection for UVW phases.
 
bool configureVgsShortProtectionY2 (tmc9660::tmcl::VgsShortEnable enable_low_side_on, tmc9660::tmcl::VgsShortEnable enable_low_side_off, tmc9660::tmcl::VgsShortEnable enable_high_side_on, tmc9660::tmcl::VgsShortEnable enable_high_side_off) noexcept
 Configure gate-to-source short protection for Y2 phase.
 
bool setVgsShortBlankingTime (tmc9660::tmcl::VgsBlankingTime uvw_time, tmc9660::tmcl::VgsBlankingTime y2Time) noexcept
 Set gate-to-source short protection blanking time.
 
bool setVgsShortDeglitchTime (tmc9660::tmcl::VgsDeglitchTime uvw_time, tmc9660::tmcl::VgsDeglitchTime y2Time) noexcept
 Set gate-to-source short protection deglitch time.
 
bool setRetryBehavior (tmc9660::tmcl::GdrvRetryBehaviour retry_behavior) noexcept
 Configure fault retry behavior.
 
bool setDriveFaultBehavior (tmc9660::tmcl::DriveFaultBehaviour fault_behavior) noexcept
 Configure drive fault behavior.
 
bool setFaultHandlerRetries (uint8_t retries) noexcept
 Set the maximum number of retries for fault handling.
 
bool configurePowerStageProtection (const PowerStageProfile &profile) noexcept
 Auto-configure complete power stage based on physical properties.
 

Private Member Functions

 GateDriver (TMC9660 &parent) noexcept
 

Private Attributes

TMC9660driver
 

Friends

class TMC9660
 

Detailed Description

template<typename CommType>
struct tmc9660::TMC9660< CommType >::GateDriver

Subsystem for configuring the MOSFET gate driver.

Constructor & Destructor Documentation

◆ GateDriver()

template<typename CommType >
tmc9660::TMC9660< CommType >::GateDriver::GateDriver ( TMC9660 & parent)
inlineexplicitprivatenoexcept

Member Function Documentation

◆ configureBootstrapCurrentLimit()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureBootstrapCurrentLimit ( tmc9660::tmcl::BootstrapCurrentLimit limit)
noexcept

Configure bootstrap current limit.

Sets the maximum current for the bootstrap capacitor.

Parameters
limitBootstrap current limit (BootstrapCurrentLimit enum).
Returns
true if successfully configured.

◆ configureBreakBeforeMakeTiming()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureBreakBeforeMakeTiming ( uint8_t low_side_uvw,
uint8_t high_side_uvw,
uint8_t low_side_y2,
uint8_t high_side_y2 )
noexcept

Configure the break-before-make timing for the gate driver (advanced API).

Sets the timing for switching between high and low sides of the gate driver using register values.

The break-before-make time is applied according to the following equation: time_ns = value * 8.33

Or, conversely, for configuring a time in nanoseconds (ns): value = time_ns / 8.33

Note
For most use cases, prefer configureBreakBeforeMakeTiming_ns() which accepts time values in nanoseconds for a more intuitive API.
Parameters
low_side_uvwBreak-before-make time for UVW low side (register value: 0-255). Actual time: t = low_side_uvw * 8.33 ns
high_side_uvwBreak-before-make time for UVW high side (register value: 0-255). Actual time: t = high_side_uvw * 8.33 ns
low_side_y2Break-before-make time for Y2 low side (register value: 0-255). Actual time: t = low_side_y2 * 8.33 ns
high_side_y2Break-before-make time for Y2 high side (register value: 0-255). Actual time: t = high_side_y2 * 8.33 ns
Returns
true if successfully configured.

◆ configureBreakBeforeMakeTiming_ns()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureBreakBeforeMakeTiming_ns ( float lowSideUVW_ns,
float highSideUVW_ns,
float lowSideY2_ns,
float highSideY2_ns )
noexcept

Configure break-before-make timing using nanoseconds (recommended API).

Internally computes the register value from the requested ns value. Values outside the valid 0...255 range will be clamped.

This is the recommended API for most users as it accepts time values in intuitive units (nanoseconds) rather than register values.

Parameters
lowSideUVW_nsBreak-before-make time for UVW low side, in nanoseconds.
highSideUVW_nsBreak-before-make time for UVW high side, in nanoseconds.
lowSideY2_nsBreak-before-make time for Y2 low side, in nanoseconds.
highSideY2_nsBreak-before-make time for Y2 high side, in nanoseconds.
Returns
true if successfully configured.

◆ configureCurrentLimits()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureCurrentLimits ( tmc9660::tmcl::GateCurrentSink sink_current_uvw,
tmc9660::tmcl::GateCurrentSource source_current_uvw,
tmc9660::tmcl::GateCurrentSink sink_current_y2,
tmc9660::tmcl::GateCurrentSource source_current_y2 )
noexcept

Configure gate driver current limits for UVW and Y2 phases.

Sets the maximum sink and source currents for the gate driver.

Parameters
sink_current_uvwSink current for UVW phases (GateCurrentSink enum).
source_current_uvwSource current for UVW phases (GateCurrentSource enum).
sink_current_y2Sink current for Y2 phase (GateCurrentSink enum).
source_current_y2Source current for Y2 phase (GateCurrentSource enum).
Returns
true if successfully configured.

◆ configureDriveTimes()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureDriveTimes ( uint8_t sink_time_uvw,
uint8_t source_time_uvw,
uint8_t sink_time_y2,
uint8_t source_time_y2 )
noexcept

Configure drive times for UVW and Y2 phases (advanced API).

Sets the discharge and charge times for the gate driver using register values.

The drive time is applied according to the following equation: time_seconds = (1 / 120,000,000) * (2 * value + 3) For example, input a value between 0...255 (register units).

Example conversion to nanoseconds: time_ns = ((2 * value + 3) * (1e9 / 120'000'000)) = (2*value + 3) * 8.33 ns

Or, conversely, for configuring a drive time in nanoseconds (ns): value = ((desired_time_ns / 8.33) - 3) / 2

Note
For most use cases, prefer configureDriveTimes_ns() which accepts time values in nanoseconds for a more intuitive API.
Parameters
sink_time_uvwDischarge time for UVW phases (register value: 0 ... 255, default: 255). Actual time: t = (2*sink_time_uvw + 3) * 8.33 ns
source_time_uvwCharge time for UVW phases (register value: 0 ... 255, default: 255). Actual time: t = (2*source_time_uvw + 3) * 8.33 ns
sink_time_y2Discharge time for Y2 phase (register value: 0 ... 255, default: 255). Actual time: t = (2*sink_time_y2 + 3) * 8.33 ns
source_time_y2Charge time for Y2 phase (register value: 0 ... 255, default: 255). Actual time: t = (2*source_time_y2 + 3) * 8.33 ns
Returns
true if successfully configured.

◆ configureDriveTimes_ns()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureDriveTimes_ns ( float sinkTimeUVW_ns,
float sourceTimeUVW_ns,
float sinkTimeY2_ns,
float sourceTimeY2_ns )
noexcept

Configure drive times using nanoseconds (recommended API).

Internally computes the register value from the requested ns value. Values outside the valid 0...255 range will be clamped.

This is the recommended API for most users as it accepts time values in intuitive units (nanoseconds) rather than register values.

Parameters
sinkTimeUVW_nsDischarge time for UVW phases, in nanoseconds.
sourceTimeUVW_nsCharge time for UVW phases, in nanoseconds.
sinkTimeY2_nsDischarge time for Y2 phase, in nanoseconds.
sourceTimeY2_nsCharge time for Y2 phase, in nanoseconds.
Returns
true if successfully configured.

◆ configurePowerStageProtection()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configurePowerStageProtection ( const PowerStageProfile & profile)
noexcept

Auto-configure complete power stage based on physical properties.

This method automatically configures the entire power stage including:

  • Gate driver interface (PWM polarity)
  • Gate driver timing (drive times, gate currents, dead time, bootstrap)
  • Protection parameters (overcurrent thresholds, blanking, deglitch, VGS protection, bootstrap UVP)
  • Fault handling (retry behavior, fault behavior, retry count)

All parameters are derived from high-level physical properties, eliminating the need to manually configure dozens of low-level registers.

Note
This function does NOT enable the gate driver. After calling this function, you must:
  • Assert the DRV_EN hardware pin (if used)
  • Set COMMUTATION_MODE to a value other than SYSTEM_OFF (e.g., via setCommutationMode())
Phase selection (3-phase vs 4-phase) is determined by boot configuration and MOTOR_TYPE. This function configures all phases that are enabled by the system.

Automatic Derivation Logic:

PART 0: Gate Driver Interface Configuration

0. PWM Output Polarity: Configurable via profile (default: ACTIVE_HIGH/ACTIVE_HIGH)

  • Critical for hardware compatibility - must match PCB layout and external gate driver stages
  • Wrong polarity will prevent gate driver from working correctly

PART 1: Gate Driver Timing Configuration

  1. Gate Current Limits: Calculated from gate charge (Qg) and target switching times
    • Source current: I = Qg / target_turn_on_time (default: ~200ns, can be overridden)
    • Sink current: I = Qg / target_turn_off_time (default: ~135ns, can be overridden)
    • Automatically selects closest available enum values
    • Use targetTurnOnTime_ns and targetTurnOffTime_ns in profile to override defaults
  2. Drive Times: Set to target switching times (default: 200ns turn-on, 135ns turn-off)
    • With adaptive drive time enabled, these are maximum times
    • Driver automatically optimizes down based on actual gate voltage monitoring
    • Can be customized via optional targetTurnOnTime_ns and targetTurnOffTime_ns profile members
  3. Adaptive Drive Time: Automatically enabled for efficiency
    • Monitors gate voltage and shortens drive times automatically
    • DRIVE_TIME_SINK acts as upper bound when adaptive mode is enabled
  4. Break-Before-Make (Dead Time): Set to 0 per documentation recommendation
    • Driver uses internal optimized timing
    • Can be overridden in future via PowerStageProfile if needed for special cases
  5. Bootstrap Current Limit: Physics-based calculation from PWM frequency and gate charge
    • I_avg = (Qg × 3_phases × f_PWM) / duty_cycle × safety_margin
    • Accounts for 3 high-side FETs, 50% average duty cycle, 2.5× safety margin
    • Automatically selects closest available enum value
  6. Undervoltage Protection: Configured from profile
    • Supply level: From profile.supplyLevel (0=disabled, 1-16 map to HW levels 0-15)
    • VDRV protection: Enabled by default for safety
    • Bootstrap UVP: Enabled by default for safety (prevents gate drive failure)
    • Enabled for both UVW and Y2 phases

PART 2: Protection Parameter Configuration

  1. Overcurrent Threshold: Computed from Rds_on and expected peak current
    • Threshold = expectedPeakCurrent_A * overcurrentMargin * Rds_on_mOhm (VDS)
    • Threshold = expectedPeakCurrent_A * overcurrentMargin * R_shunt_mOhm (RSHUNT)
    • Automatically selects appropriate register values for both sensing methods
  2. Blanking Time: Derived from di/dt estimation
    • di/dt ≈ busVoltage_V / motorInductance_uH (or 20µH conservative estimate if unknown)
    • Blanking time selected based on di/dt range:
      • < 5 A/µs → 0.25 µs
      • 5-15 A/µs → 0.5 µs
      • 15-30 A/µs → 1.0 µs
      • 30-60 A/µs → 2.0 µs
      • > 60 A/µs → 4-8 µs (capped at 10-15% of PWM period, minimum 5% or 0.25µs)
    • Applied blankingMargin safety factor
  3. Deglitch Time: Based on gate charge (Qg) and switching speed
    • Low Qg (< 15 n_c): Fast switching → longer deglitch (1-4 µs)
    • Medium Qg (15-40 n_c): Normal → moderate deglitch (0.5-1 µs)
    • High Qg (> 40 n_c): Slow switching → shorter deglitch (0.25-0.5 µs)
    • Applied blankingMargin safety factor
  4. VGS Short Protection: Based on gate charge
    • Fast FETs (low Qg): Longer blanking/deglitch
    • Slow FETs (high Qg): Shorter blanking/deglitch
    • Automatically enabled for all transitions
  5. VDS Monitoring: Automatically enabled if Rds_on < 10 mΩ for reliable sensing
    • Otherwise uses RSHUNT-based sensing (more accurate, recommended)

PART 3: Fault Handling Configuration

  1. Retry Behavior: Configurable behavior after gate driver fault
    • OPEN_CIRCUIT (default): Motor spins freely
    • ELECTRICAL_BRAKING: Enable braking if possible
  2. Drive Fault Behavior: Configurable behavior after all retries fail
    • OPEN_CIRCUIT (default): Motor spins freely
    • ELECTRICAL_BRAKING: Enable braking if possible
    • MECHANICAL_BRAKING_AND_OPEN_CIRCUIT: Engage mechanical brake if configured
    • MECHANICAL_AND_ELECTRICAL_BRAKING: Both electrical and mechanical braking
  3. Fault Handler Retries: Maximum number of retries per detected fault
    • Default: 5 retries (range: 0-255)
Parameters
profilePower stage physical properties (see PowerStageProfile)
Returns
true if configuration was successful
Note
All protection features are enabled by default. The method configures timing parameters only - protection enables are set to safe defaults.
If motor inductance is not provided (NaN), conservative di/dt estimates are used based on typical motor sizes.

◆ configureUndervoltageProtection()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureUndervoltageProtection ( tmc9660::tmcl::UndervoltageLevel supplyLevel,
tmc9660::tmcl::UndervoltageEnable enable_vdrv,
tmc9660::tmcl::UndervoltageEnable enable_bst_uvw,
tmc9660::tmcl::UndervoltageEnable enable_bst_y2 )
noexcept

Configure undervoltage protection settings.

Parameters
supplyLevelSupply voltage (VS) protection level (tmc9660::tmcl::UndervoltageLevel enum).
enable_vdrvEnable driver voltage (VDRV) protection (tmc9660::tmcl::UndervoltageEnable enum).
enable_bst_uvwEnable bootstrap capacitor protection for UVW phases (tmc9660::tmcl::UndervoltageEnable enum).
enable_bst_y2Enable bootstrap capacitor protection for Y2 phase (tmc9660::tmcl::UndervoltageEnable enum).
Returns
true if successfully configured.

◆ configureVgsShortProtectionUVW()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureVgsShortProtectionUVW ( tmc9660::tmcl::VgsShortEnable enable_low_side_on,
tmc9660::tmcl::VgsShortEnable enable_low_side_off,
tmc9660::tmcl::VgsShortEnable enable_high_side_on,
tmc9660::tmcl::VgsShortEnable enable_high_side_off )
noexcept

Configure gate-to-source short protection for UVW phases.

Parameters
enable_low_side_onEnable protection for ON transition of low side (tmc9660::tmcl::VgsShortEnable enum).
enable_low_side_offEnable protection for OFF transition of low side (tmc9660::tmcl::VgsShortEnable enum).
enable_high_side_onEnable protection for ON transition of high side (tmc9660::tmcl::VgsShortEnable enum).
enable_high_side_offEnable protection for OFF transition of high side (tmc9660::tmcl::VgsShortEnable enum).
Returns
true if successfully configured.

◆ configureVgsShortProtectionY2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::configureVgsShortProtectionY2 ( tmc9660::tmcl::VgsShortEnable enable_low_side_on,
tmc9660::tmcl::VgsShortEnable enable_low_side_off,
tmc9660::tmcl::VgsShortEnable enable_high_side_on,
tmc9660::tmcl::VgsShortEnable enable_high_side_off )
noexcept

Configure gate-to-source short protection for Y2 phase.

Parameters
enable_low_side_onEnable protection for ON transition of low side (tmc9660::tmcl::VgsShortEnable enum).
enable_low_side_offEnable protection for OFF transition of low side (tmc9660::tmcl::VgsShortEnable enum).
enable_high_side_onEnable protection for ON transition of high side (tmc9660::tmcl::VgsShortEnable enum).
enable_high_side_offEnable protection for OFF transition of high side (tmc9660::tmcl::VgsShortEnable enum).
Returns
true if successfully configured.

◆ enableAdaptiveDriveTime()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::enableAdaptiveDriveTime ( bool enable_uvw,
bool enable_y2 )
noexcept

Enable or disable adaptive drive time for UVW and Y2 phases.

Adaptive drive time shortens the discharge cycle by monitoring gate voltages.

Parameters
enable_uvwTrue to enable adaptive drive time for UVW phases.
enable_y2True to enable adaptive drive time for Y2 phase.
Returns
true if successfully configured.

◆ enableOvercurrentProtection()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::enableOvercurrentProtection ( tmc9660::tmcl::OvercurrentEnable enable_uvw_low_side,
tmc9660::tmcl::OvercurrentEnable enable_uvw_high_side,
tmc9660::tmcl::OvercurrentEnable enable_y2_low_side,
tmc9660::tmcl::OvercurrentEnable enable_y2_high_side )
noexcept

Enable or disable overcurrent protection for UVW and Y2 phases.

Parameters
enable_uvw_low_sideEnable protection for UVW low side (tmc9660::tmcl::OvercurrentEnable enum).
enable_uvw_high_sideEnable protection for UVW high side (tmc9660::tmcl::OvercurrentEnable enum).
enable_y2_low_sideEnable protection for Y2 low side (tmc9660::tmcl::OvercurrentEnable enum).
enable_y2_high_sideEnable protection for Y2 high side (tmc9660::tmcl::OvercurrentEnable enum).
Returns
true if successfully configured.

◆ enableVdsMonitoringLow()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::enableVdsMonitoringLow ( tmc9660::tmcl::VdsUsage uvw_enable,
tmc9660::tmcl::VdsUsage y2Enable )
noexcept

Enable or disable VDS monitoring for overcurrent protection on UVW and Y2 low sides.

Parameters
uvw_enableTrue to enable VDS measurement for overcurrent protection on UVW low side (tmc9660::tmcl::VdsUsage enum).
y2EnableTrue to enable VDS measurement for overcurrent protection on Y2 low side (tmc9660::tmcl::VdsUsage enum).
Returns
true if successfully configured.

◆ setDriveFaultBehavior()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setDriveFaultBehavior ( tmc9660::tmcl::DriveFaultBehaviour fault_behavior)
noexcept

Configure drive fault behavior.

Parameters
fault_behaviorBehavior after all retries fail (tmc9660::tmcl::DriveFaultBehavior enum).
Returns
true if successfully configured.

◆ setFaultHandlerRetries()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setFaultHandlerRetries ( uint8_t retries)
noexcept

Set the maximum number of retries for fault handling.

Parameters
retriesMaximum number of retries (0-255).
Returns
true if successfully configured.

◆ setOutputPolarity()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setOutputPolarity ( tmc9660::tmcl::PwmOutputPolarity low_side,
tmc9660::tmcl::PwmOutputPolarity high_side )
noexcept

Set the gate driver output polarity.

Configures the PWM_L and PWM_H output polarity.

Parameters
low_sidePolarity for the low-side gate outputs (tmc9660::tmcl::PwmOutputPolarity enum).
high_sidePolarity for the high-side gate outputs (tmc9660::tmcl::PwmOutputPolarity enum).
Returns
true if the polarity was set successfully.

◆ setOvercurrentBlanking()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setOvercurrentBlanking ( tmc9660::tmcl::OvercurrentTiming uvw_low_side_time,
tmc9660::tmcl::OvercurrentTiming uvw_high_side_time,
tmc9660::tmcl::OvercurrentTiming y2LowSideTime,
tmc9660::tmcl::OvercurrentTiming y2HighSideTime )
noexcept

Configure the overcurrent protection blanking time for UVW and Y2 phases.

Sets the blanking time for overcurrent protection to filter out transient spikes during switching events.

Parameters
uvw_low_side_timeBlanking time for the low side of UVW phases (tmc9660::tmcl::OvercurrentTiming enum).
uvw_high_side_timeBlanking time for the high side of UVW phases (tmc9660::tmcl::OvercurrentTiming enum).
y2LowSideTimeBlanking time for the low side of Y2 phase (tmc9660::tmcl::OvercurrentTiming enum).
y2HighSideTimeBlanking time for the high side of Y2 phase (tmc9660::tmcl::OvercurrentTiming enum).
Returns
true if successfully configured.

◆ setOvercurrentDeglitch()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setOvercurrentDeglitch ( tmc9660::tmcl::OvercurrentTiming uvw_low_side_time,
tmc9660::tmcl::OvercurrentTiming uvw_high_side_time,
tmc9660::tmcl::OvercurrentTiming y2LowSideTime,
tmc9660::tmcl::OvercurrentTiming y2HighSideTime )
noexcept

Configure the overcurrent protection deglitch time for UVW and Y2 phases.

Sets how long an overcurrent condition must persist before triggering protection.

Parameters
uvw_low_side_timeDeglitch time for the low side of UVW phases (tmc9660::tmcl::OvercurrentTiming enum).
uvw_high_side_timeDeglitch time for the high side of UVW phases (tmc9660::tmcl::OvercurrentTiming enum).
y2LowSideTimeDeglitch time for the low side of Y2 phase (tmc9660::tmcl::OvercurrentTiming enum).
y2HighSideTimeDeglitch time for the high side of Y2 phase (tmc9660::tmcl::OvercurrentTiming enum).
Returns
true if successfully configured.

◆ setOvercurrentThresholds()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setOvercurrentThresholds ( tmc9660::tmcl::OvercurrentThreshold uvw_low_side_threshold,
tmc9660::tmcl::OvercurrentThreshold uvw_high_side_threshold,
tmc9660::tmcl::OvercurrentThreshold y2LowSideThreshold,
tmc9660::tmcl::OvercurrentThreshold y2HighSideThreshold )
noexcept

Configure overcurrent protection thresholds for UVW and Y2 phases.

Threshold Selection:

  • High-Side (HS): Always uses VDS sensing thresholds (63mV, 125mV, 187mV, etc.)
  • Low-Side (LS): Hardware automatically selects threshold based on UVW_LOW_SIDE_USE_VDS / Y2_LOW_SIDE_USE_VDS setting:
    • If VDS enabled: Uses VDS threshold (e.g., V_250_OR_187_MILLIVOLT → 187mV)
    • If RSHUNT enabled: Uses RSHUNT threshold (e.g., V_250_OR_187_MILLIVOLT → 250mV)

The enum values encode both thresholds (e.g., V_250_OR_187_MILLIVOLT means 250mV for RSHUNT or 187mV for VDS). The hardware automatically applies the correct value based on the sensing method configured via enableVdsMonitoringLow().

Parameters
uvw_low_side_thresholdThreshold for UVW low side (auto-selected based on VDS/RSHUNT config) (tmc9660::tmcl::OvercurrentThreshold enum).
uvw_high_side_thresholdThreshold for UVW high side (always VDS value) (tmc9660::tmcl::OvercurrentThreshold enum).
y2LowSideThresholdThreshold for Y2 low side (auto-selected based on VDS/RSHUNT config) (tmc9660::tmcl::OvercurrentThreshold enum).
y2HighSideThresholdThreshold for Y2 high side (always VDS value) (tmc9660::tmcl::OvercurrentThreshold enum).
Returns
true if successfully configured.
Note
Configure the sensing method (VDS vs RSHUNT) via enableVdsMonitoringLow() before calling this function to ensure the correct threshold is applied.

◆ setRetryBehavior()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setRetryBehavior ( tmc9660::tmcl::GdrvRetryBehaviour retry_behavior)
noexcept

Configure fault retry behavior.

Parameters
retry_behaviorRetry behavior after a fault (tmc9660::tmcl::GdrvRetryBehaviour enum).
Returns
true if successfully configured.

◆ setVgsShortBlankingTime()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setVgsShortBlankingTime ( tmc9660::tmcl::VgsBlankingTime uvw_time,
tmc9660::tmcl::VgsBlankingTime y2Time )
noexcept

Set gate-to-source short protection blanking time.

Parameters
uvw_timeBlanking time for UVW phases (tmc9660::tmcl::VgsBlankingTime enum).
y2TimeBlanking time for Y2 phase (tmc9660::tmcl::VgsBlankingTime enum).
Returns
true if successfully configured.

◆ setVgsShortDeglitchTime()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::GateDriver::setVgsShortDeglitchTime ( tmc9660::tmcl::VgsDeglitchTime uvw_time,
tmc9660::tmcl::VgsDeglitchTime y2Time )
noexcept

Set gate-to-source short protection deglitch time.

Parameters
uvw_timeDeglitch time for UVW phases (tmc9660::tmcl::VgsDeglitchTime enum).
y2TimeDeglitch time for Y2 phase (tmc9660::tmcl::VgsDeglitchTime enum).
Returns
true if successfully configured.

Friends And Related Symbol Documentation

◆ TMC9660

template<typename CommType >
friend class TMC9660
friend

Member Data Documentation

◆ driver

template<typename CommType >
TMC9660& tmc9660::TMC9660< CommType >::GateDriver::driver
private

The documentation for this struct was generated from the following file: