Straightforward PWM handling.
More...
#include "sarmfsw.h"
|
HAL_StatusTypeDef | init_PWM_Chan (TIM_HandleTypeDef *const pTim, const uint32_t chan, const uint16_t freq, const eState start_polarity) |
| Init TIM PWM module channel with frequency and starts the channel.
|
|
HAL_StatusTypeDef | set_PWM_Output (TIM_HandleTypeDef *const pTim, const uint32_t chan, const bool on) |
| Set PWM channel output on/off.
|
|
HAL_StatusTypeDef | set_PWM_Duty_Scaled (const TIM_HandleTypeDef *const pTim, const uint32_t chan, const uint32_t duty, const uint32_t scale) |
| Set TIM module PWM duty cycle (scaled)
|
|
HAL_StatusTypeDef | set_PWM_Duty_Word (const TIM_HandleTypeDef *const pTim, const uint32_t chan, const uint16_t duty) |
| Set TIM module PWM duty cycle (u16 value)
|
|
HAL_StatusTypeDef | set_PWM_Duty_Byte (const TIM_HandleTypeDef *const pTim, const uint32_t chan, const uint8_t duty) |
| Set TIM module PWM duty cycle (u8 value)
|
|
HAL_StatusTypeDef | set_PWM_Duty_Perc (const TIM_HandleTypeDef *const pTim, const uint32_t chan, const uint8_t duty) |
| Set TIM module PWM duty cycle (percents)
|
|
Straightforward PWM handling.
- Author
- SMFSW
- Copyright
- MIT (c) 2017-2024, SMFSW
- Warning
- Init functions assume that TIM peripherals instance were already configured by HAL
◆ init_PWM_Chan()
HAL_StatusTypeDef init_PWM_Chan |
( |
TIM_HandleTypeDef *const | pTim, |
|
|
const uint32_t | chan, |
|
|
const uint16_t | freq, |
|
|
const eState | start_polarity ) |
Init TIM PWM module channel with frequency and starts the channel.
- Parameters
-
[in,out] | pTim | - pointer to TIM instance for PWM generation |
[in] | chan | - Channel to write |
[in] | freq | - Desired PWM frequency |
[in] | start_polarity | - Set PWM output to 100% at init if set to On (0% otherwise) |
- Returns
- HAL Status
◆ set_PWM_Duty_Byte()
HAL_StatusTypeDef set_PWM_Duty_Byte |
( |
const TIM_HandleTypeDef *const | pTim, |
|
|
const uint32_t | chan, |
|
|
const uint8_t | duty ) |
|
inline |
Set TIM module PWM duty cycle (u8 value)
- Parameters
-
[in,out] | pTim | - pointer to TIM instance for PWM generation |
[in] | chan | - Channel to write |
[in] | duty | - 8b duty cycle value to write |
- Returns
- HAL Status
◆ set_PWM_Duty_Perc()
HAL_StatusTypeDef set_PWM_Duty_Perc |
( |
const TIM_HandleTypeDef *const | pTim, |
|
|
const uint32_t | chan, |
|
|
const uint8_t | duty ) |
|
inline |
Set TIM module PWM duty cycle (percents)
- Parameters
-
[in,out] | pTim | - pointer to TIM instance for PWM generation |
[in] | chan | - Channel to write |
[in] | duty | - Percent duty cycle value to write |
- Returns
- HAL Status
◆ set_PWM_Duty_Scaled()
HAL_StatusTypeDef set_PWM_Duty_Scaled |
( |
const TIM_HandleTypeDef *const | pTim, |
|
|
const uint32_t | chan, |
|
|
const uint32_t | duty, |
|
|
const uint32_t | scale ) |
Set TIM module PWM duty cycle (scaled)
- Parameters
-
[in,out] | pTim | - pointer to TIM instance for PWM generation |
[in] | chan | - Channel to write |
[in] | duty | - Scaled duty cycle value to write |
[in] | scale | - Full scale value |
- Returns
- HAL Status
◆ set_PWM_Duty_Word()
HAL_StatusTypeDef set_PWM_Duty_Word |
( |
const TIM_HandleTypeDef *const | pTim, |
|
|
const uint32_t | chan, |
|
|
const uint16_t | duty ) |
|
inline |
Set TIM module PWM duty cycle (u16 value)
- Parameters
-
[in,out] | pTim | - pointer to TIM instance for PWM generation |
[in] | chan | - Channel to write |
[in] | duty | - 16b duty cycle value to write |
- Returns
- HAL Status
◆ set_PWM_Output()
HAL_StatusTypeDef set_PWM_Output |
( |
TIM_HandleTypeDef *const | pTim, |
|
|
const uint32_t | chan, |
|
|
const bool | on ) |
|
inline |
Set PWM channel output on/off.
- Parameters
-
[in,out] | pTim | - pointer to TIM instance for PWM generation |
[in] | chan | - Channel to write |
[in] | on | - Channel Output state 0: off, 1: on |
- Returns
- HAL Status