5#include DEF2STR(LIBXR_CH32_CONFIG_FILE)
18 CH32PWM(TIM_TypeDef* tim, uint16_t channel,
bool active_high, GPIO_TypeDef* gpio,
19 uint16_t pin, uint32_t pin_remap = 0,
bool complementary =
false);
36 static bool IsAdvancedTimer(TIM_TypeDef* t);
37 static bool OnAPB2(TIM_TypeDef* t);
38 static uint32_t GetTimerClockHz(TIM_TypeDef* t);
40 static inline uint32_t ReadARR32(TIM_TypeDef* t) {
return t->ATRLR; }
42 void ApplyCompare(uint32_t pulse);
43 void OcInitForChannel(uint32_t pulse);
44 void EnableChannel(
bool en);
45 void EnableChannelN(
bool en);
49 static void EnableTIMClock(TIM_TypeDef* tim);
CH32 PWM 驱动实现 / CH32 PWM driver implementation.
ErrorCode Enable() override
Enables the PWM output. 启用 PWM 输出。
ErrorCode Disable() override
Disables the PWM output. 禁用 PWM 输出。
ErrorCode SetDutyCycle(float value) override
Sets the duty cycle of the PWM signal. 设置 PWM 信号的占空比。
static void EnableGPIOClock(GPIO_TypeDef *gpio)
时钟与 GPIO 初始化辅助 / Clock and GPIO configuration helpers
ErrorCode SetConfig(Configuration config) override
Configures the PWM settings. 配置 PWM 参数。
CH32PWM(TIM_TypeDef *tim, uint16_t channel, bool active_high, GPIO_TypeDef *gpio, uint16_t pin, uint32_t pin_remap=0, bool complementary=false)
构造 PWM 对象 / Construct PWM object
Abstract base class for PWM (Pulse Width Modulation) control. PWM(脉冲宽度调制)控制的抽象基类。
Configuration parameters for PWM. PWM 配置参数。