Skip to content

File syn_port_pwm.h

FileList > port > syn_port_pwm.h

Go to the source code of this file

Hardware PWM port interface — implement these for your platform. More...

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

Public Functions

Type Name
void syn_port_pwm_enable (uint8_t channel, bool enable)
Enable/disable PWM output.
SYN_Status syn_port_pwm_init (uint8_t channel, uint32_t freq_hz)
Initialize a PWM channel.
void syn_port_pwm_set_duty (uint8_t channel, uint8_t duty_pct)
Set PWM duty cycle.
void syn_port_pwm_set_duty_raw (uint8_t channel, uint16_t duty_u16)
Set PWM duty cycle with fine resolution.
void syn_port_pwm_set_freq (uint8_t channel, uint32_t freq_hz)
Set PWM frequency (runtime change).

Detailed Description

Provides channel-based PWM control. Each channel maps to a physical timer/output pin on your MCU.

Public Functions Documentation

function syn_port_pwm_enable

Enable/disable PWM output.

void syn_port_pwm_enable (
    uint8_t channel,
    bool enable
) 

Parameters:

  • channel PWM channel index.
  • enable true to enable, false to disable.

function syn_port_pwm_init

Initialize a PWM channel.

SYN_Status syn_port_pwm_init (
    uint8_t channel,
    uint32_t freq_hz
) 

Parameters:

  • channel PWM channel number.
  • freq_hz PWM frequency in Hz.

Returns:

SYN_OK on success.


function syn_port_pwm_set_duty

Set PWM duty cycle.

void syn_port_pwm_set_duty (
    uint8_t channel,
    uint8_t duty_pct
) 

Parameters:

  • channel PWM channel number.
  • duty_pct Duty cycle 0–100 (percent).

function syn_port_pwm_set_duty_raw

Set PWM duty cycle with fine resolution.

void syn_port_pwm_set_duty_raw (
    uint8_t channel,
    uint16_t duty_u16
) 

Parameters:

  • channel PWM channel number.
  • duty_u16 Duty cycle 0–65535 (0 = off, 65535 = 100%).

function syn_port_pwm_set_freq

Set PWM frequency (runtime change).

void syn_port_pwm_set_freq (
    uint8_t channel,
    uint32_t freq_hz
) 

Parameters:

  • channel PWM channel number.
  • freq_hz New frequency in Hz.


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