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

HAL interface for PWM (Pulse Width Modulation) configuration and control. More...

#include "utils/timer_types.h"
#include <stdint.h>
Include dependency graph for pwm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PWM_Handle
 PWM handle structure linking timer and channel. More...

Functions

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

Detailed Description

HAL interface for PWM (Pulse Width Modulation) configuration and control.

This header provides:

  • PWM handle structure linking hardware timers and channels.
  • Functions to initialize, start, stop, and configure PWM signals.

Function Documentation

◆ hal_pwm_init()

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

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

Parameters
pwmPointer to the PWM handle.
frequencyPWM frequency in Hz.
dutyCycleDuty cycle as a percentage (0.0 to 100.0).

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 the PWM duty cycle.

Parameters
pwmPointer to the PWM handle.
dutyCycleDuty cycle as a percentage (0.0 to 100.0).

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 the PWM frequency.

Parameters
pwmPointer to the PWM handle.
frequencyPWM frequency in Hz.

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 signal generation.

Parameters
pwmPointer to the PWM handle.

Start PWM signal generation.

Parameters
pwmPointer to the PWM handle structure.

◆ hal_pwm_stop()

void hal_pwm_stop ( PWM_Handle * pwm)

Stop PWM signal generation.

Parameters
pwmPointer to the PWM handle.

Stop PWM signal generation.

This function disables the timer channel and stops the timer.

Parameters
pwmPointer to the PWM handle structure.