|
PebbleOS
|
Pulse-width modulation outputs. More...
Functions | |
| void | pwm_init (const PwmConfig *pwm, uint32_t resolution, uint32_t frequency) |
| Initialize a PWM channel. | |
| void | pwm_set_duty_cycle (const PwmConfig *pwm, uint32_t duty_cycle) |
| Set the duty cycle. | |
| void | pwm_enable (const PwmConfig *pwm, bool enable) |
| Start or stop the output. | |
Pulse-width modulation outputs.
A channel is described by a board-defined PwmConfig. The period is resolution counts of a counter running at frequency, so the output frequency is frequency / resolution.
| void pwm_enable | ( | const PwmConfig * | pwm, |
| bool | enable | ||
| ) |
Start or stop the output.
| pwm | Channel. |
| enable | true to start, false to stop. |
| void pwm_init | ( | const PwmConfig * | pwm, |
| uint32_t | resolution, | ||
| uint32_t | frequency | ||
| ) |
Initialize a PWM channel.
| pwm | Channel. |
| resolution | Counts per period; duty cycles range from 0 to this value. |
| frequency | Counter frequency in Hz. |
| void pwm_set_duty_cycle | ( | const PwmConfig * | pwm, |
| uint32_t | duty_cycle | ||
| ) |
Set the duty cycle.
The channel must be enabled first.
| pwm | Channel. |
| duty_cycle | High time in counts, 0 to the resolution given to pwm_init(). |