![]() |
Midnight Sun Firmware
|
PWM library. More...
Macros | |
| #define | pwm_init_hz(timer, frequency) pwm_init((timer), 1000000 / (frequency)) |
| Initializes the PWM for a set timer with a specific frequency (Hz) | |
Enumerations | |
| enum | PwmTimer { PWM_TIMER_1 = 0 , PWM_TIMER_2 , PWM_TIMER_3 , PWM_TIMER_4 , PWM_TIMER_15 , PWM_TIMER_16 , NUM_PWM_TIMERS } |
| PWM Timer selection. More... | |
| enum | PwmChannel { PWM_CHANNEL_1 = 0 , PWM_CHANNEL_2 , PWM_CHANNEL_3 , PWM_CHANNEL_4 , PWM_CHANNEL_5 , PWM_CHANNEL_6 , NUM_PWM_CHANNELS } |
| PWM Channel selection. More... | |
Functions | |
| StatusCode | pwm_init (PwmTimer timer, uint16_t period_us) |
| Initializes a specified PWM timer with a period. More... | |
| StatusCode | pwm_set_pulse (PwmTimer timer, uint16_t pulse_width_us, PwmChannel channel, bool n_channel_en) |
| Sets the pulse width of a specified channel of a PWM timer. More... | |
| StatusCode | pwm_set_dc (PwmTimer timer, uint16_t dc, PwmChannel channel, bool n_channel_en) |
| Sets the duty cycle of a specified channel for a PWM timer. More... | |
| uint16_t | pwm_get_period (PwmTimer timer) |
| Gets the current period of a specified PWM timer in microseconds. More... | |
| uint16_t | pwm_get_dc (PwmTimer timer, PwmChannel channel) |
| Gets the duty cycle of a specified channel for a PWM timer. More... | |
PWM library.
| enum PwmChannel |
| enum PwmTimer |
| uint16_t pwm_get_dc | ( | PwmTimer | timer, |
| PwmChannel | channel | ||
| ) |
Gets the duty cycle of a specified channel for a PWM timer.
| timer | PWM timer to configure |
| channel | Channel of the PWM timer to configure |
| uint16_t pwm_get_period | ( | PwmTimer | timer | ) |
Gets the current period of a specified PWM timer in microseconds.
| timer | PWM timer to check |
| StatusCode pwm_init | ( | PwmTimer | timer, |
| uint16_t | period_us | ||
| ) |
Initializes a specified PWM timer with a period.
| timer | PWM timer to configure |
| period_ms | Duration of one cycle in microseconds |
| StatusCode pwm_set_dc | ( | PwmTimer | timer, |
| uint16_t | dc, | ||
| PwmChannel | channel, | ||
| bool | n_channel_en | ||
| ) |
Sets the duty cycle of a specified channel for a PWM timer.
| timer | PWM timer to configure |
| dc | Duty cycle in units of 1% |
| channel | Channel of the PWM timer to configure |
| n_channel_en | Whether N channel is enabled or not |
| StatusCode pwm_set_pulse | ( | PwmTimer | timer, |
| uint16_t | pulse_width_us, | ||
| PwmChannel | channel, | ||
| bool | n_channel_en | ||
| ) |
Sets the pulse width of a specified channel of a PWM timer.
| timer | PWM timer to configure |
| pulse_width_us | Pulse width in microseconds |
| channel | Channel of the PWM timer to configure |
| n_channel_en | Whether N channel is enabled or not |