semf
|
Pwm
implementation for STM32.
More...
#include <stm32pwm.h>
Public Types | |
enum class | ErrorCode : uint8_t { Set_HalError = 0 , Set_HalBusy , Set_HalTimeout , Start_HalError , Start_HalBusy , Start_HalTimeout , Stop_HalError , Stop_HalBusy , Stop_HalTimeout } |
enum class | Mode : uint8_t { Mode1 , Mode2 } |
Defines the start level of a PWM cycle. See also OCxM setting IMx_CCMR1 register description. More... | |
Public Member Functions | |
Stm32Pwm (TIM_HandleTypeDef &hwHandle, uint32_t channel, bool fastMode=false, Mode mode=Mode::Mode1) | |
Constructor. More... | |
Stm32Pwm (const Stm32Pwm &other)=delete | |
virtual | ~Stm32Pwm ()=default |
void | setMaxValue (unsigned int maxValue) override |
Set the maximum possible PWM value. More... | |
unsigned int | maxValue () const override |
Returns the maximum possible PWM value. More... | |
void | set (unsigned int value, bool inverted=false) override |
Set a PWM value. Duty cycle is value / maxValue. More... | |
unsigned int | value () const override |
Returns the current PWM value. More... | |
void | start () override |
void | stop () override |
bool | isEnabled () const override |
Returns the current status of PWM module. More... | |
Public Member Functions inherited from semf::Pwm | |
virtual | ~Pwm ()=default |
virtual void | setMaxValue (unsigned int maxValue)=0 |
Set the maximum possible PWM value. More... | |
virtual unsigned int | maxValue () const =0 |
Returns the maximum possible PWM value. More... | |
virtual void | set (unsigned int value, bool inverted=false)=0 |
Set a PWM value. Duty cycle is value / maxValue. More... | |
virtual unsigned int | value () const =0 |
Returns the current PWM value. More... | |
virtual void | start ()=0 |
virtual void | stop ()=0 |
virtual bool | isEnabled () const =0 |
Returns the current status of PWM module. More... | |
Additional Inherited Members | |
Public Attributes inherited from semf::Pwm | |
Signal< Error > | error |
Pwm
implementation for STM32.
Definition at line 22 of file stm32pwm.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Enumerator | |
---|---|
Set_HalError | |
Set_HalBusy | |
Set_HalTimeout | |
Start_HalError | |
Start_HalBusy | |
Start_HalTimeout | |
Stop_HalError | |
Stop_HalBusy | |
Stop_HalTimeout |
Definition at line 26 of file stm32pwm.h.
|
strong |
Defines the start level of a PWM cycle. See also OCxM setting IMx_CCMR1 register description.
Definition at line 43 of file stm32pwm.h.
semf::Stm32Pwm::Stm32Pwm | ( | TIM_HandleTypeDef & | hwHandle, |
uint32_t | channel, | ||
bool | fastMode = false , |
||
Mode | mode = Mode::Mode1 |
||
) |
Constructor.
hwHandle | Reference to timer hardware handle. |
channel | Channel selection define from STM timer HAL description. Use TIM_CHANNEL_1, TIM_CHANNEL_2, TIM_CHANNEL_3 or TIM_CHANNEL_4. |
fastMode | Flag to enable or disable fast mode. |
mode | Mode setting. |
Definition at line 16 of file stm32pwm.cpp.
|
explicitdelete |
|
virtualdefault |
|
overridevirtual |
Returns the current status of PWM module.
Implements semf::Pwm.
Definition at line 160 of file stm32pwm.cpp.
|
overridevirtual |
Returns the maximum possible PWM value.
Implements semf::Pwm.
Definition at line 30 of file stm32pwm.cpp.
|
overridevirtual |
Set a PWM value. Duty cycle is value / maxValue.
value | The new PWM value. |
inverted | Invert the PWM output. |
Set_HalError | If the ST-HAL returns a hal error. |
Set_HalBusy | If the ST-HAL returns a hal busy. |
Set_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::Pwm.
Definition at line 35 of file stm32pwm.cpp.
|
overridevirtual |
Set the maximum possible PWM value.
maxValue | The maximum possible PWM value. |
Implements semf::Pwm.
Definition at line 24 of file stm32pwm.cpp.
|
overridevirtual |
Start the PWM hardware.
Start_HalError | If the ST-HAL returns a hal error. |
Start_HalBusy | If the ST-HAL returns a hal busy. |
Start_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::Pwm.
Definition at line 103 of file stm32pwm.cpp.
|
overridevirtual |
Start the PWM hardware.
Stop_HalError | If the ST-HAL returns a hal error. |
Stop_HalBusy | If the ST-HAL returns a hal busy. |
Stop_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::Pwm.
Definition at line 134 of file stm32pwm.cpp.
|
overridevirtual |
Returns the current PWM value.
Implements semf::Pwm.
Definition at line 129 of file stm32pwm.cpp.