The Pulse Width Modulation A Controller (PWMA) controls several pulse width modulation (PWM) channels.
This driver provides an API to get access to the main features of the PWMA controller.
|
void | pwma_config_and_enable (volatile avr32_pwma_t *pwma, unsigned long long int channel_mask, int period_cycles, int duty_cycles) |
| Configure and enable the PWMA. More...
|
|
bool | pwma_config_enable (volatile avr32_pwma_t *pwma, uint32_t pwma_freq_hz, uint32_t gclk_freq_hz, uint16_t spread) |
| Configure and enable the PWMA. More...
|
|
static void | pwma_disable (volatile avr32_pwma_t *pwma) |
| Disable a PWMA module. More...
|
|
bool | pwma_set_channels_value (volatile avr32_pwma_t *pwma, uint64_t channel_mask, uint16_t duty_cycle) |
| Load the duty cycle value to the channels. This function uses Interlinked Single Value Mode where several channels are interlinked to allow multiple channels to be updated simultaneously with the same duty cycle value. More...
|
|
bool | pwma_set_multiple_values (volatile avr32_pwma_t *pwma, uint32_t channel_mask, uint16_t *channel_duty_cycles) |
| Load multiple duty cycle values to multiple channels. This function uses Interlinked Multi Value Mode where 4 channels can be updated simultaneously with 4 different duty cycle values. More...
|
|
static void | pwma_wait_for_ready (volatile avr32_pwma_t *pwma) |
| Wait for PWMA Module to be ready for writing. More...
|
|
bool | pwma_write_top_value (volatile avr32_pwma_t *pwma, uint16_t top_value) |
| Load TOP value. More...
|
|
#define PWMA_CHANNEL_LIMIT 4 |
void pwma_config_and_enable |
( |
volatile avr32_pwma_t * |
pwma, |
|
|
unsigned long long int |
channel_mask, |
|
|
int |
period_cycles, |
|
|
int |
duty_cycles |
|
) |
| |
Configure and enable the PWMA.
This function will enable the PWMA module and configure a mask of channels.
- Parameters
-
pwma | Pointer to the PWMA module. |
channel_mask | Bit mask of channels to set period_cycles for. |
period_cycles | Period cycles for the PWMA module, i.e. the TOP value (and eventually the SPREAD value). |
duty_cycles | Number of cycles for the active period for the channels provided by channel_mask. |
- Warning
- This function is deprecated, please rather use pwma_config_enable() function.
References pwma_set_channels_value().
bool pwma_config_enable |
( |
volatile avr32_pwma_t * |
pwma, |
|
|
uint32_t |
pwma_freq_hz, |
|
|
uint32_t |
gclk_freq_hz, |
|
|
uint16_t |
spread |
|
) |
| |
Configure and enable the PWMA.
This function will enable the PWMA module and configure a mask of channels.
- Parameters
-
pwma | Pointer to the PWMA module. |
pwma_freq_hz | Required PWMA frequency in hertz. |
gclk_freq_hz | GCLK_PWMA frequency in hertz. |
spread | Spread value to be loaded. |
- Return values
-
PASS | if configuration is successfully done. |
FAIL | for invalid arguments i.e. TOP or SPREAD exceed the limit value. |
References div_ceil, FAIL, PASS, and pwma_wait_for_ready().
Referenced by demo_init_pwma(), init_pwm(), main(), and pwma_init().
static void pwma_disable |
( |
volatile avr32_pwma_t * |
pwma | ) |
|
|
inlinestatic |
Disable a PWMA module.
- Parameters
-
pwma | Pointer to the PWMA module. |
bool pwma_set_channels_value |
( |
volatile avr32_pwma_t * |
pwma, |
|
|
uint64_t |
channel_mask, |
|
|
uint16_t |
duty_cycle |
|
) |
| |
Load the duty cycle value to the channels. This function uses Interlinked Single Value Mode where several channels are interlinked to allow multiple channels to be updated simultaneously with the same duty cycle value.
- Parameters
-
pwma | Pointer to the PWMA module. |
channel_mask | Channels for which the value should be loaded. |
duty_cycles | Number of cycles for the active period for the channels provided by channel_mask. |
- Return values
-
PASS | if the duty cycle value is with in the limit. |
FAIL | if the duty cycle value exceeds TOP [or] TOP-SPREAD. |
- Warning
- The duty cycle value should be less than the TOP value(normal mode). If spread value is loaded, the duty cycle value should not exceed TOP-SPREAD.
References FAIL, PASS, and pwma_wait_for_ready().
Referenced by demo_automatic_ledshow_play(), demo_init_pwma(), emulate_light_switch(), init_pwm(), ISR(), pwma_config_and_enable(), pwma_init(), reset_leds(), set_all_leds(), and touch_handler().
bool pwma_set_multiple_values |
( |
volatile avr32_pwma_t * |
pwma, |
|
|
uint32_t |
channel_mask, |
|
|
uint16_t * |
channel_duty_cycles |
|
) |
| |
Load multiple duty cycle values to multiple channels. This function uses Interlinked Multi Value Mode where 4 channels can be updated simultaneously with 4 different duty cycle values.
- Parameters
-
pwma | Pointer to the PWMA module. |
channel_mask | Channels for which the value should be loaded. |
channel_duty_cycles | Pointer to an array of duty cycle values. |
- Return values
-
PASS | if the duty cycle value is with in the limit. |
FAIL | if the duty cycle value exceeds TOP [or] TOP-SPREAD. |
- Warning
- The duty cycle value should be less than the TOP value(normal mode). If spread value is loaded, the duty cycle value should not exceed TOP-SPREAD.
References count, FAIL, PASS, PWMA_CHANNEL_LIMIT, and pwma_wait_for_ready().
Referenced by main(), play_auto_running_lights(), play_level_bar(), and process_wheel().
static void pwma_wait_for_ready |
( |
volatile avr32_pwma_t * |
pwma | ) |
|
|
inlinestatic |
bool pwma_write_top_value |
( |
volatile avr32_pwma_t * |
pwma, |
|
|
uint16_t |
top_value |
|
) |
| |
Load TOP value.
- Parameters
-
pwma | Pointer to the PWMA Module. |
top_value | TOP value to be loaded. |
- Return values
-
PASS | if the TOP value is within the limit. |
FAIL | if the TOP value exceeds its maximum limit. |
References FAIL, PASS, and pwma_wait_for_ready().