5#ifdef HAL_TIM_MODULE_ENABLED
23 else if (
value > 1.0f)
29 static_cast<uint32_t>(
static_cast<float>(htim_->Init.Period + 1) *
value);
40#if defined(STM32F0) || defined(STM32G0)
47 return ErrorCode::ARG_ERR;
51 htim_->Instance ==
TIM1 ||
54 htim_->Instance ==
TIM8 ||
57 htim_->Instance ==
TIM9 ||
60 htim_->Instance ==
TIM10 ||
63 htim_->Instance ==
TIM11 ||
66 htim_->Instance ==
TIM15 ||
69 htim_->Instance ==
TIM16 ||
72 htim_->Instance ==
TIM17 ||
75 htim_->Instance ==
TIM20 ||
89 htim_->Instance ==
TIM2 ||
92 htim_->Instance ==
TIM3 ||
95 htim_->Instance ==
TIM4 ||
98 htim_->Instance ==
TIM5 ||
101 htim_->Instance ==
TIM6 ||
104 htim_->Instance ==
TIM7 ||
107 htim_->Instance ==
TIM12 ||
110 htim_->Instance ==
TIM13 ||
113 htim_->Instance ==
TIM14 ||
127 return ErrorCode::NOT_SUPPORT;
133 return ErrorCode::INIT_ERR;
154 return ErrorCode::INIT_ERR;
158 htim_->Init.Period =
period - 1;
162 return ErrorCode::INIT_ERR;
165 return ErrorCode::OK;
172 return ErrorCode::FAILED;
174 return ErrorCode::OK;
181 return ErrorCode::FAILED;
183 return ErrorCode::OK;
Abstract base class for PWM (Pulse Width Modulation) control. PWM(脉冲宽度调制)控制的抽象基类。
ErrorCode Disable() override
Disables the PWM output. 禁用 PWM 输出。
ErrorCode SetDutyCycle(float value) override
Sets the duty cycle of the PWM signal. 设置 PWM 信号的占空比。
ErrorCode Enable() override
Enables the PWM output. 启用 PWM 输出。
ErrorCode SetConfig(Configuration config) override
Configures the PWM settings. 配置 PWM 参数。
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
Configuration parameters for PWM. PWM 配置参数。