|
| 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.
|
| |
Subsystem for configuring the MOSFET gate driver.
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_uvw | Break-before-make time for UVW low side (register value: 0-255). Actual time: t = low_side_uvw * 8.33 ns |
| high_side_uvw | Break-before-make time for UVW high side (register value: 0-255). Actual time: t = high_side_uvw * 8.33 ns |
| low_side_y2 | Break-before-make time for Y2 low side (register value: 0-255). Actual time: t = low_side_y2 * 8.33 ns |
| high_side_y2 | Break-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.
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_uvw | Discharge time for UVW phases (register value: 0 ... 255, default: 255). Actual time: t = (2*sink_time_uvw + 3) * 8.33 ns |
| source_time_uvw | Charge time for UVW phases (register value: 0 ... 255, default: 255). Actual time: t = (2*source_time_uvw + 3) * 8.33 ns |
| sink_time_y2 | Discharge time for Y2 phase (register value: 0 ... 255, default: 255). Actual time: t = (2*sink_time_y2 + 3) * 8.33 ns |
| source_time_y2 | Charge 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.
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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- Retry Behavior: Configurable behavior after gate driver fault
- OPEN_CIRCUIT (default): Motor spins freely
- ELECTRICAL_BRAKING: Enable braking if possible
- 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
- Fault Handler Retries: Maximum number of retries per detected fault
- Default: 5 retries (range: 0-255)
- Parameters
-
- 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.