10#ifndef SEMF_HARDWAREABSTRACTION_STM32_STM32PWM_H_
11#define SEMF_HARDWAREABSTRACTION_STM32_STM32PWM_H_
15#if defined(STM32) && defined(HAL_TIM_MODULE_ENABLED)
69 unsigned int maxValue()
const override;
76 void set(
unsigned int value,
bool inverted =
false)
override;
77 unsigned int value()
const override;
84 void start()
override;
96 TIM_HandleTypeDef* m_hwHandle;
100 bool m_fastModeEnabled;
104 unsigned int m_pwmValue = 0;
106 bool m_enabled =
false;
108 static constexpr Error::ClassID kSemfClassId = Error::ClassID::Stm32Pwm;
Class to interface pwm's hardware module of the microcontroller.
Pwm implementation for STM32.
void set(unsigned int value, bool inverted=false) override
Set a PWM value. Duty cycle is value / maxValue.
Mode
Defines the start level of a PWM cycle. See also OCxM setting IMx_CCMR1 register description.
Stm32Pwm(TIM_HandleTypeDef &hwHandle, uint32_t channel, bool fastMode=false, Mode mode=Mode::Mode1)
Constructor.
Stm32Pwm(const Stm32Pwm &other)=delete
bool isEnabled() const override
Returns the current status of PWM module.
void setMaxValue(unsigned int maxValue) override
Set the maximum possible PWM value.
virtual ~Stm32Pwm()=default
unsigned int maxValue() const override
Returns the maximum possible PWM value.
unsigned int value() const override
Returns the current PWM value.