libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
mspm0_pwm.hpp
1#pragma once
2
3#include "mspm0_conf.hpp"
4#include "pwm.hpp"
5#include "ti_msp_dl_config.h"
6
7namespace LibXR
8{
9
10class MSPM0PWM : public PWM
11{
12 public:
13 struct Resources
14 {
15 GPTIMER_Regs* timer;
16 DL_TIMER_CC_INDEX channel;
17 uint32_t clock_freq;
18 };
19
21
22 ErrorCode SetDutyCycle(float value);
23
24 ErrorCode SetConfig(Configuration config);
25
26 ErrorCode Enable();
27
28 ErrorCode Disable();
29
30 private:
31 GPTIMER_Regs* timer_;
32 DL_TIMER_CC_INDEX channel_;
33 uint32_t clock_freq_;
34};
35
36// Helper macro to define PWM instance resources from SysConfig macros
37#define MSPM0_PWM_CH(name, ch) \
38 LibXR::MSPM0PWM::Resources \
39 { \
40 name##_INST, DL_TIMER_CC_##ch##_INDEX, \
41 name##_INST_CLK_FREQ* LibXR::MSPM0Config::name##_INST_CLK_DIV*( \
42 LibXR::MSPM0Config::name##_INST_CLK_PSC + 1) \
43 }
44
45} // 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
Configuration parameters for PWM. PWM 配置参数。
Definition pwm.hpp:23