HARMcksL: ARM HAL toolbox (yet STM32 oriented) 1.6
SMFSW collection of HAL hacks for STM32
Loading...
Searching...
No Matches
PWM_GPIO.c File Reference

GPIO PWM emulation handling. More...

#include "sarmfsw.h"
#include "TIM_ex.h"
#include "PWM_GPIO.h"
Include dependency graph for PWM_GPIO.c:

Functions

FctERR PWM_GPIO_setPin (PWM_GPIO *const pPWM, GPIO_TypeDef *const GPIOx, const uint16_t GPIO_Pin, const bool polarity)
 Set channel pin & polarity for emulated PWM channel.
 
FctERR PWM_GPIO_setFreq (PWM_GPIO *const pPWM, TIM_HandleTypeDef *const pTim, const uint16_t freq, uint16_t granularity)
 Set channel frequency for emulated PWM channel.
 
FctERR PWM_GPIO_setDuty (PWM_GPIO *const pPWM, const uint16_t val)
 Set new duty cycle for emulated PWM channel.
 
void PWM_GPIO_handler (PWM_GPIO *const pPWM)
 Handler for an emulated PWM channel.
 

Detailed Description

GPIO PWM emulation handling.

Author
SMFSW

PWM_GPIO configuration: TIM with enabled period callback interrupt shall be used (as time base for PWM emulation)

Function Documentation

◆ PWM_GPIO_handler()

void PWM_GPIO_handler ( PWM_GPIO *const pPWM)

Handler for an emulated PWM channel.

Warning
Shall be called directly from timer interrupt (HAL_TIM_PeriodElapsedCallback)
Parameters
[in,out]pPWM- pointer to emulated PWM channel

◆ PWM_GPIO_setDuty()

FctERR PWM_GPIO_setDuty ( PWM_GPIO *const pPWM,
const uint16_t val )

Set new duty cycle for emulated PWM channel.

Parameters
[in,out]pPWM- pointer to emulated PWM channel
[in]val- Duty cycle to apply
Returns
Error code

◆ PWM_GPIO_setFreq()

FctERR PWM_GPIO_setFreq ( PWM_GPIO *const pPWM,
TIM_HandleTypeDef *const pTim,
const uint16_t freq,
uint16_t granularity )

Set channel frequency for emulated PWM channel.

Warning
For multiple PWMs on same timer with different frequencies, take care of init order (first configured channel will get TIM parameters precedence)
Parameters
[in,out]pPWM- pointer to emulated PWM channel
[in,out]pTim- pointer to TIM instance for Frequency computation
[in]freq- PWM frequency to apply
[in]granularity- PWM duty cycle granularity
Returns
Error code
Here is the call graph for this function:

◆ PWM_GPIO_setPin()

FctERR PWM_GPIO_setPin ( PWM_GPIO *const pPWM,
GPIO_TypeDef *const GPIOx,
const uint16_t GPIO_Pin,
const bool polarity )

Set channel pin & polarity for emulated PWM channel.

Parameters
[in]GPIOx- port for emulated PWM
[in]GPIO_Pin- pin for emulated PWM
[in,out]pPWM- pointer to emulated PWM channel
[in]polarity- 0: low polarity, 1: high polarity
Returns
Error code