File syn_pwm.c¶
FileList > drivers > syn_pwm.c
Go to the source code of this file
Hardware PWM driver implementation.
#include "../util/syn_assert.h"#include "syn_pwm.h"
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_pwm_enable (const SYN_PWM * pwm, bool enable) Enable or disable the PWM output. |
| SYN_Status | syn_pwm_init (SYN_PWM * pwm, uint8_t channel, uint32_t freq_hz) Initialize a hardware PWM channel. |
| SYN_Status | syn_pwm_set_duty (const SYN_PWM * pwm, uint8_t duty_pct) Set the PWM duty cycle as a percentage (0–100%). |
| SYN_Status | syn_pwm_set_duty_raw (const SYN_PWM * pwm, uint16_t duty_u16) Set the PWM duty cycle with 16-bit raw resolution (0–65535). |
| SYN_Status | syn_pwm_set_freq (SYN_PWM * pwm, uint32_t freq_hz) Change the PWM frequency at runtime. |
Public Functions Documentation¶
function syn_pwm_enable¶
Enable or disable the PWM output.
Parameters:
pwmInitialized PWM handle.enabletrue to enable, false to disable.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if handle is invalid.
function syn_pwm_init¶
Initialize a hardware PWM channel.
Parameters:
pwmHandle to initialize. Must not be NULL.channelPlatform PWM channel index.freq_hzDesired PWM frequency in Hz (must be > 0).
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
function syn_pwm_set_duty¶
Set the PWM duty cycle as a percentage (0–100%).
Parameters:
pwmInitialized PWM handle.duty_pctDuty cycle percentage (0 = 0%, 100 = 100%).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if handle is invalid.
function syn_pwm_set_duty_raw¶
Set the PWM duty cycle with 16-bit raw resolution (0–65535).
Parameters:
pwmInitialized PWM handle.duty_u1616-bit duty value (0 = off, 65535 = 100%).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if handle is invalid.
function syn_pwm_set_freq¶
Change the PWM frequency at runtime.
Parameters:
pwmInitialized PWM handle.freq_hzNew frequency in Hz (must be > 0).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if handle is invalid.
The documentation for this class was generated from the following file src/syntropic/drivers/syn_pwm.c