Skip to content

File syn_hrpwm.h

FileList > drivers > syn_hrpwm.h

Go to the source code of this file

High-Resolution Power & Precision Motion Control Driver. More...

  • #include "../common/syn_defs.h"
  • #include "../port/syn_port_hrpwm.h"
  • #include <stdbool.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_HRPWM
High-Resolution PWM handle. Caller allocates; zero heap.

Public Functions

Type Name
SYN_Status syn_hrpwm_bind_fault (const SYN_HRPWM * hrpwm, uint8_t fault_id)
Bind hardware emergency fault trip protection.
SYN_Status syn_hrpwm_enable (SYN_HRPWM * hrpwm, bool enable)
Enable or disable complementary HRPWM gate drivers.
SYN_Status syn_hrpwm_init (SYN_HRPWM * hrpwm, uint8_t channel, uint32_t freq_hz)
Initialize a High-Resolution PWM driver channel.
SYN_Status syn_hrpwm_set_deadtime_ns (SYN_HRPWM * hrpwm, uint16_t rise_ns, uint16_t fall_ns)
Configure complementary dead-time insertion.
SYN_Status syn_hrpwm_set_duty_float (const SYN_HRPWM * hrpwm, float duty_float)
Set high-resolution duty cycle ratio using float (0.0 to 1.0).
SYN_Status syn_hrpwm_set_duty_q16 (const SYN_HRPWM * hrpwm, int32_t duty_q16)
Set high-resolution duty cycle ratio using Q16.16 fixed-point format.
SYN_Status syn_hrpwm_set_phase_deg (SYN_HRPWM * hrpwm, uint16_t phase_deg)
Set channel phase shift offset in degrees.

Detailed Description

Provides a vendor-agnostic, zero-allocation OS interface for sub-nanosecond PWM edge placement, complementary high-side/low-side gate driver control, hardware dead-time insertion, phase shifting, and emergency fault trips.

Usage:

SYN_HRPWM hrpwm;
syn_hrpwm_init(&hrpwm, 0, 500000);                     // 500 kHz switching frequency
syn_hrpwm_set_deadtime_ns(&hrpwm, 100, 100);          // 100 ns dead-time
syn_hrpwm_set_duty_q16(&hrpwm, Q16_FROM_FLOAT(0.50f)); // 50% duty cycle
syn_hrpwm_enable(&hrpwm, true);

Public Functions Documentation

function syn_hrpwm_bind_fault

Bind hardware emergency fault trip protection.

SYN_Status syn_hrpwm_bind_fault (
    const SYN_HRPWM * hrpwm,
    uint8_t fault_id
) 

Parameters:

  • hrpwm Initialized HRPWM handle.
  • fault_id Hardware fault pin/comparator ID.

Returns:

SYN_OK on success.


function syn_hrpwm_enable

Enable or disable complementary HRPWM gate drivers.

SYN_Status syn_hrpwm_enable (
    SYN_HRPWM * hrpwm,
    bool enable
) 

Parameters:

  • hrpwm Initialized HRPWM handle.
  • enable true to enable outputs, false to disable.

Returns:

SYN_OK on success.


function syn_hrpwm_init

Initialize a High-Resolution PWM driver channel.

SYN_Status syn_hrpwm_init (
    SYN_HRPWM * hrpwm,
    uint8_t channel,
    uint32_t freq_hz
) 

Parameters:

  • hrpwm Handle to initialize. Must not be NULL.
  • channel Platform channel index.
  • freq_hz Target switching frequency in Hz.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid argument.


function syn_hrpwm_set_deadtime_ns

Configure complementary dead-time insertion.

SYN_Status syn_hrpwm_set_deadtime_ns (
    SYN_HRPWM * hrpwm,
    uint16_t rise_ns,
    uint16_t fall_ns
) 

Parameters:

  • hrpwm Initialized HRPWM handle.
  • rise_ns High-side rise dead-time in nanoseconds.
  • fall_ns Low-side fall dead-time in nanoseconds.

Returns:

SYN_OK on success.


function syn_hrpwm_set_duty_float

Set high-resolution duty cycle ratio using float (0.0 to 1.0).

SYN_Status syn_hrpwm_set_duty_float (
    const SYN_HRPWM * hrpwm,
    float duty_float
) 

Parameters:

  • hrpwm Initialized HRPWM handle.
  • duty_float Duty ratio (0.0f = 0%, 1.0f = 100%).

Returns:

SYN_OK on success.


function syn_hrpwm_set_duty_q16

Set high-resolution duty cycle ratio using Q16.16 fixed-point format.

SYN_Status syn_hrpwm_set_duty_q16 (
    const SYN_HRPWM * hrpwm,
    int32_t duty_q16
) 

Parameters:

  • hrpwm Initialized HRPWM handle.
  • duty_q16 Duty ratio in Q16.16 (0 = 0%, 65536 = 100%).

Returns:

SYN_OK on success.


function syn_hrpwm_set_phase_deg

Set channel phase shift offset in degrees.

SYN_Status syn_hrpwm_set_phase_deg (
    SYN_HRPWM * hrpwm,
    uint16_t phase_deg
) 

Parameters:

  • hrpwm Initialized HRPWM handle.
  • phase_deg Phase angle offset in degrees (0–360).

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/drivers/syn_hrpwm.h