NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
pwm.c File Reference

PWM driver implementation for STM32F4 series (Cortex-M4). More...

#include "core/cortex-m4/pwm.h"
#include "core/cortex-m4/clock.h"
#include "core/cortex-m4/timer.h"
#include <stdint.h>
Include dependency graph for pwm.c:

Functions

void hal_pwm_init (PWM_Handle *pwm, uint32_t frequency, float dutyCycle)
 Initialize PWM with a specified frequency and duty cycle.
void hal_pwm_start (PWM_Handle *pwm)
 Start PWM output.
void hal_pwm_stop (PWM_Handle *pwm)
 Stop PWM output.
void hal_pwm_set_duty_cycle (PWM_Handle *pwm, float dutyCycle)
 Set PWM duty cycle.
void hal_pwm_set_frequency (PWM_Handle *pwm, uint32_t frequency)
 Set PWM frequency.

Detailed Description

PWM driver implementation for STM32F4 series (Cortex-M4).

Function Documentation

◆ hal_pwm_init()

void hal_pwm_init ( PWM_Handle * pwm,
uint32_t frequency,
float dutyCycle )

Initialize PWM with a specified frequency and duty cycle.

Initialize a PWM handle with the specified frequency and duty cycle.

This function configures the timer to generate a PWM signal on the specified channel with the given frequency and duty cycle.

Parameters
pwmPointer to the PWM handle structure.
frequencyDesired PWM frequency in Hz.
dutyCycleDuty cycle as a fraction (0.0f - 1.0f).

◆ hal_pwm_set_duty_cycle()

void hal_pwm_set_duty_cycle ( PWM_Handle * pwm,
float dutyCycle )

Set PWM duty cycle.

Set the PWM duty cycle.

Parameters
pwmPointer to the PWM handle structure.
dutyCycleNew duty cycle as a fraction (0.0f - 1.0f).

◆ hal_pwm_set_frequency()

void hal_pwm_set_frequency ( PWM_Handle * pwm,
uint32_t frequency )

Set PWM frequency.

Set the PWM frequency.

Note
This function is not yet implemented.
Parameters
pwmPointer to the PWM handle structure.
frequencyDesired PWM frequency in Hz.

◆ hal_pwm_start()

void hal_pwm_start ( PWM_Handle * pwm)

Start PWM output.

Start PWM signal generation.

Parameters
pwmPointer to the PWM handle structure.

◆ hal_pwm_stop()

void hal_pwm_stop ( PWM_Handle * pwm)

Stop PWM output.

Stop PWM signal generation.

This function disables the timer channel and stops the timer.

Parameters
pwmPointer to the PWM handle structure.