AIROC™ BTSDK v4.9 - Documentation | ||||
PWM Functions. More...
Functions | |
BOOL32 | wiced_hal_pwm_start (UINT8 channel, pwm_clk_t clk, UINT32 toggleCount, UINT32 initCount, BOOL32 invert) |
Configures, enables, and starts the PWM to be active on a preconfigured GPIO pin. More... | |
BOOL32 | wiced_hal_pwm_change_values (UINT8 channel, UINT32 toggleCount, UINT32 initCount) |
Changes the PWM settings after the PWM HW has already been started. More... | |
UINT32 | wiced_hal_pwm_get_toggle_count (UINT8 channel) |
Returns the current toggle count setting for the corresponding PWM channel. More... | |
UINT32 | wiced_hal_pwm_get_init_value (UINT8 channel) |
Returns the current initial count setting for the corresponding PWM channel. More... | |
void | wiced_hal_pwm_disable (UINT8 channel) |
Disables the PWM channel. More... | |
void | wiced_hal_pwm_enable (UINT8 channel) |
Enables the PWM channel which is already preconfigured. More... | |
void | wiced_hal_pwm_get_params (UINT32 clock_frequency_in, UINT32 duty_cycle, UINT32 pwm_frequency_out, pwm_config_t *params_out) |
Calculate PWM parameters. More... | |
PWM Functions.
BOOL32 wiced_hal_pwm_change_values | ( | UINT8 | channel, |
UINT32 | toggleCount, | ||
UINT32 | initCount | ||
) |
Changes the PWM settings after the PWM HW has already been started.
(!) Note that the maximum width or period of the PWM is 0x3FF (10-bits).
channel | - Desired PWM channel to set [0-3]. |
toggleCount | - The number of ticks to wait before toggling the signal. |
initCount | - Initial value for the counter. |
void wiced_hal_pwm_disable | ( | UINT8 | channel | ) |
Disables the PWM channel.
channel | - Desired PWM channel to stop/disable. |
void wiced_hal_pwm_enable | ( | UINT8 | channel | ) |
Enables the PWM channel which is already preconfigured.
channel | - Desired PWM channel to enable. |
UINT32 wiced_hal_pwm_get_init_value | ( | UINT8 | channel | ) |
Returns the current initial count setting for the corresponding PWM channel.
channel | - Desired PWM channel from which to obtain the initial count. |
void wiced_hal_pwm_get_params | ( | UINT32 | clock_frequency_in, |
UINT32 | duty_cycle, | ||
UINT32 | pwm_frequency_out, | ||
pwm_config_t * | params_out | ||
) |
Calculate PWM parameters.
[in] | clock_frequency_in | - in clock frequency |
[in] | duty_cycle | - duty cycle in percentage (0 to 100) |
[in] | pwm_frequency_out | - Desire PWM output frequency |
[out] | params_out | - PWM params |
UINT32 wiced_hal_pwm_get_toggle_count | ( | UINT8 | channel | ) |
Returns the current toggle count setting for the corresponding PWM channel.
channel | - Desired PWM channel from which to obtain the toggle count. |
BOOL32 wiced_hal_pwm_start | ( | UINT8 | channel, |
pwm_clk_t | clk, | ||
UINT32 | toggleCount, | ||
UINT32 | initCount, | ||
BOOL32 | invert | ||
) |
Configures, enables, and starts the PWM to be active on a preconfigured GPIO pin.
(!) Note that the desired GPIO pin must have already been configured as output. See the HW muxing section in the Kit Guide for more information.
channel | - Desired PWM channel to use [0-5]. |
clk | - PMU_CLK or LHL_CLK |
toggleCount | - The number of ticks to wait before toggling the signal. |
initCount | - Initial value for the counter. |
invert | - 1 to invert the signal. |
The following example outputs a signal on P28 using the PMU clock.
(!) Note that the maximum width or period of the PWM is 0x3FF (10-bits).
(!) Note that if you use PMU_CLK instead of LHL_CLK, a call to wiced_hal_aclk_enable() is required. When configuring aclk, ACLK0 is not available for use with PWM–only ACLK1.
(!) Note that each PWM<#> channel corresponds to a specific GPIO pin, and said pin must be configured for output before PWM may use it. Please reference the Kit Guide or HW User Manual for your device for more information on which pins support PWM on your platform.
/// wiced_hal_aclk_enable(PWM_INP_CLK_IN_HZ, ACLK1, ACLK_FREQ_24_MHZ); /// wiced_hal_pwm_get_params(PWM_INP_CLK_IN_HZ, PWM_DUTY_CYCLE, PWM_FREQ_IN_HZ, &pwm_config); /// wiced_hal_pwm_start(PWM_CHANNEL, PMU_CLK, pwm_config.toggle_count, pwm_config.init_count, 0); ///