#include <stdlib.h>
#include <errno.h>
#include "no_os_util.h"
#include "no_os_gpio.h"
#include "no_os_pwm.h"
#include "stm32_gpio.h"
#include "stm32_pwm.h"
#include "stm32_irq.h"
◆ FREQUENCY_HZ_TO_TIME_NS_FACTOR
#define FREQUENCY_HZ_TO_TIME_NS_FACTOR 1000000000.0 |
◆ NO_OS_CHN_TO_STM32_CHN
#define NO_OS_CHN_TO_STM32_CHN |
( |
|
x | ) |
(0x4*(x-1)) |
◆ PWM_DEFAULT_PERIOD
#define PWM_DEFAULT_PERIOD 0xffff |
◆ stm32_pwm_disable()
Disable the PWM.
- Parameters
-
- Returns
- 0 in case of success, negative error otherwise.
◆ stm32_pwm_enable()
Enable the PWM.
- Parameters
-
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_get_duty_cycle()
int32_t stm32_pwm_get_duty_cycle |
( |
struct no_os_pwm_desc * |
desc, |
|
|
uint32_t * |
duty_cycle_ns |
|
) |
| |
Get the PWM duty cycle.
- Parameters
-
desc | - Pointer where the configured instance is stored. |
duty_cycle_ns | - PWM duty cycle. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_get_period()
int32_t stm32_pwm_get_period |
( |
struct no_os_pwm_desc * |
desc, |
|
|
uint32_t * |
period_ns |
|
) |
| |
Get the PWM period.
- Parameters
-
desc | - Pointer where the configured instance is stored. |
period_ns | - PWM period. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_init()
Initialize the PWM.
- Parameters
-
desc | - PWM descriptor. |
param | - The structure containing PWM init parameters. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_remove()
Free the resources allocated by stm32_pwm_init()
- Parameters
-
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_set_duty_cycle()
int32_t stm32_pwm_set_duty_cycle |
( |
struct no_os_pwm_desc * |
desc, |
|
|
uint32_t |
duty_cycle_ns |
|
) |
| |
Set the PWM duty cycle.
- Parameters
-
desc | - Pointer where the configured instance is stored. |
duty_cycle_ns | - PWM duty cycle. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_set_period()
int32_t stm32_pwm_set_period |
( |
struct no_os_pwm_desc * |
desc, |
|
|
uint32_t |
period_ns |
|
) |
| |
Set the PWM period.
- Parameters
-
desc | - Pointer where the configured instance is stored. |
period_ns | - PWM period. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ stm32_pwm_ops
Initial value:
STM32 platform specific PWM platform ops structure.
STM32 specific PWM platform ops structure.
int32_t stm32_pwm_enable(struct no_os_pwm_desc *desc)
Enable the PWM.
Definition: stm32_pwm.c:509
int32_t stm32_pwm_set_duty_cycle(struct no_os_pwm_desc *desc, uint32_t duty_cycle_ns)
Set the PWM duty cycle.
Definition: stm32_pwm.c:664
int32_t stm32_pwm_get_period(struct no_os_pwm_desc *desc, uint32_t *period_ns)
Get the PWM period.
Definition: stm32_pwm.c:640
int32_t stm32_pwm_disable(struct no_os_pwm_desc *desc)
Disable the PWM.
Definition: stm32_pwm.c:561
int32_t stm32_pwm_init(struct no_os_pwm_desc **desc, const struct no_os_pwm_init_param *param)
Initialize the PWM.
Definition: stm32_pwm.c:403
int32_t stm32_pwm_remove(struct no_os_pwm_desc *desc)
Free the resources allocated by stm32_pwm_init()
Definition: stm32_pwm.c:463
int32_t stm32_pwm_get_duty_cycle(struct no_os_pwm_desc *desc, uint32_t *duty_cycle_ns)
Get the PWM duty cycle.
Definition: stm32_pwm.c:698
int32_t stm32_pwm_set_period(struct no_os_pwm_desc *desc, uint32_t period_ns)
Set the PWM period.
Definition: stm32_pwm.c:599