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);
48 static void EnableGPIOClock(GPIO_TypeDef* gpio);
49 static void EnableTIMClock(TIM_TypeDef* tim);
CH32 PWM 驱动实现 / CH32 PWM driver implementation.
ErrorCode Enable() override
启用 PWM 输出 / Enables the PWM output.
ErrorCode Disable() override
禁用 PWM 输出 / Disables the PWM output.
ErrorCode SetDutyCycle(float value) override
设置 PWM 信号的占空比 / Sets the duty cycle of the PWM signal.
ErrorCode SetConfig(Configuration config) override
配置 PWM 参数 / Configures the PWM settings.
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
PWM(脉冲宽度调制)控制的抽象基类。 Abstract base class for PWM (Pulse Width Modulation) control.
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
PWM 配置参数 / Configuration parameters for PWM.