File syn_soft_pwm.h¶
File List > output > syn_soft_pwm.h
Go to the documentation of this file
#ifndef SYN_SOFT_PWM_H
#define SYN_SOFT_PWM_H
#include "../common/syn_defs.h"
#include "../drivers/syn_gpio.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ── Soft PWM descriptor ────────────────────────────────────────────────── */
typedef struct {
SYN_GPIO_Pin pin;
uint16_t resolution;
uint16_t duty;
uint16_t counter;
bool active_high;
} SYN_SoftPWM;
/* ── API ────────────────────────────────────────────────────────────────── */
void syn_soft_pwm_init(SYN_SoftPWM *pwm, SYN_GPIO_Pin pin, uint16_t resolution);
void syn_soft_pwm_set_duty(SYN_SoftPWM *pwm, uint16_t duty);
void syn_soft_pwm_set_percent(SYN_SoftPWM *pwm, uint8_t percent);
void syn_soft_pwm_tick(SYN_SoftPWM *pwm);
void syn_soft_pwm_service(SYN_SoftPWM *channels, size_t count);
static inline uint16_t syn_soft_pwm_get_duty(const SYN_SoftPWM *pwm)
{
return pwm->duty;
}
#ifdef __cplusplus
}
#endif
#endif /* SYN_SOFT_PWM_H */