libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
mspm0_pwm.hpp
1#pragma once
2
3#include "pwm.hpp"
4#include "ti_msp_dl_config.h" // IWYU pragma: keep; required for GPTIMER_Regs and DL_TIMER_CC_INDEX
5
6namespace LibXR
7{
8
9class MSPM0PWM : public PWM
10{
11 public:
12 struct Resources
13 {
14 GPTIMER_Regs* timer;
15 DL_TIMER_CC_INDEX channel;
16 uint32_t clock_freq;
17 };
18
20
21 ErrorCode SetDutyCycle(float value);
22
24
26
28
29 private:
30 GPTIMER_Regs* timer_;
31 DL_TIMER_CC_INDEX channel_;
32 uint32_t clock_freq_;
33};
34
35// Helper macro to define PWM instance resources from SysConfig macros
36#define MSPM0_PWM_CH(name, ch) \
37 LibXR::MSPM0PWM::Resources \
38 { \
39 name##_INST, DL_TIMER_CC_##ch##_INDEX, \
40 name##_INST_CLK_FREQ* LibXR::MSPM0Config::name##_INST_CLK_DIV*( \
41 LibXR::MSPM0Config::name##_INST_CLK_PSC + 1) \
42 }
43
44} // namespace LibXR
ErrorCode Disable()
Disables the PWM output. 禁用 PWM 输出。
ErrorCode SetDutyCycle(float value)
Sets the duty cycle of the PWM signal. 设置 PWM 信号的占空比。
Definition mspm0_pwm.cpp:16
ErrorCode SetConfig(Configuration config)
Configures the PWM settings. 配置 PWM 参数。
Definition mspm0_pwm.cpp:56
ErrorCode Enable()
Enables the PWM output. 启用 PWM 输出。
Abstract base class for PWM (Pulse Width Modulation) control. PWM(脉冲宽度调制)控制的抽象基类。
Definition pwm.hpp:14
LibXR 命名空间
Definition ch32_can.hpp:14
ErrorCode
定义错误码枚举
Configuration parameters for PWM. PWM 配置参数。
Definition pwm.hpp:23