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


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. | |
HAL interface for PWM (Pulse Width Modulation) configuration and control.
This header provides:
| void hal_pwm_init | ( | PWM_Handle * | pwm, |
| uint32_t | frequency, | ||
| float | dutyCycle ) |
Initialize a PWM handle with the specified frequency and duty cycle.
| pwm | Pointer to the PWM handle. |
| frequency | PWM frequency in Hz. |
| dutyCycle | Duty cycle as a percentage (0.0 to 100.0). |
Initialize a PWM handle with the specified frequency and duty cycle.
| [in,out] | pwm | Pointer to PWM handle structure |
| [in] | frequency | Desired PWM frequency in Hz |
| [in] | dutyCycle | Initial duty cycle (0.0 to 1.0) |
Configures the timer peripheral to generate PWM signals by:
| void hal_pwm_set_duty_cycle | ( | PWM_Handle * | pwm, |
| float | dutyCycle ) |
Set the PWM duty cycle.
| pwm | Pointer to the PWM handle. |
| dutyCycle | Duty cycle as a percentage (0.0 to 100.0). |
Set the PWM duty cycle.
| [in,out] | pwm | Pointer to PWM handle structure |
| [in] | dutyCycle | New duty cycle (0.0 to 1.0) |
Updates the capture/compare register to change the PWM duty cycle while maintaining the current frequency. The change takes effect immediately on the output.
| void hal_pwm_set_frequency | ( | PWM_Handle * | pwm, |
| uint32_t | frequency ) |
Set the PWM frequency.
| pwm | Pointer to the PWM handle. |
| frequency | PWM frequency in Hz. |
Set the PWM frequency.
| [in,out] | pwm | Pointer to PWM handle structure |
| [in] | frequency | Desired PWM frequency in Hz |
| void hal_pwm_start | ( | PWM_Handle * | pwm | ) |
Start PWM signal generation.
| pwm | Pointer to the PWM handle. |
Start PWM signal generation.
| [in] | pwm | Pointer to initialized PWM handle structure |
Enables the timer counter to start generating PWM signals on the configured channel. The output will appear on the corresponding GPIO pin.
| void hal_pwm_stop | ( | PWM_Handle * | pwm | ) |
Stop PWM signal generation.
| pwm | Pointer to the PWM handle. |
Stop PWM signal generation.
| [in] | pwm | Pointer to PWM handle structure |
Disables the timer channel output and stops the timer counter. The PWM output pin will return to its idle state.