6#include "hpm_clock_drv.h"
7#include "hpm_gptmr_drv.h"
9#if defined(PWM_SOC_CMP_MAX_COUNT) && defined(PWM_SOC_OUTPUT_TO_PWM_MAX_COUNT)
10#define LIBXR_HPM_PWM_SUPPORTED 1
11#include "hpm_pwm_drv.h"
12using LibXRHpmPwmType = PWM_Type;
14#define LIBXR_HPM_PWM_SUPPORTED 0
15using LibXRHpmPwmType = void;
18#if !LIBXR_HPM_PWM_SUPPORTED
19#define LIBXR_HPM_GPTMR_PWM_FALLBACK 1
21#define LIBXR_HPM_GPTMR_PWM_FALLBACK 0
44 HPMPWM(LibXRHpmPwmType* pwm, clock_name_t clock, uint8_t pwm_index, uint8_t cmp_index,
45 bool invert =
false,
bool auto_board_init =
true);
65 ErrorCode
Enable()
override;
74 static constexpr uint8_t kInvalidCmpIndex = 0xFFu;
75 static uint8_t ResolveGptmrReloadCmpIndex(uint8_t duty_cmp_index);
77 LibXRHpmPwmType* pwm_;
83 bool auto_board_init_;
HPM 平台 PWM 驱动实现 / PWM driver implementation for HPM platform.
HPMPWM(LibXRHpmPwmType *pwm, clock_name_t clock, uint8_t pwm_index, uint8_t cmp_index, bool invert=false, bool auto_board_init=true)
构造 HPM PWM 对象 / Construct an HPM PWM object.
ErrorCode Disable() override
停止 PWM 输出 / Stop PWM output.
ErrorCode SetDutyCycle(float value) override
设置占空比 / Set PWM duty cycle.
ErrorCode Enable() override
启动 PWM 输出 / Start PWM output.
ErrorCode SetConfig(Configuration config) override
配置 PWM 频率 / Configure PWM frequency.
Abstract base class for PWM (Pulse Width Modulation) control. PWM(脉冲宽度调制)控制的抽象基类。
Configuration parameters for PWM. PWM 配置参数。