This module implements some utility functions for using PWM functionality in the application. More...
Data Structures | |
| struct | pwm_utils_contex_t |
| Context structure for defining application specific instance of PWM peripheral to be used with this module. More... | |
Functions | |
| void | pwm_utils_enable (pwm_utils_contex_t *p_ctx) |
| Enables the PWM channel. More... | |
| void | pwm_utils_level_set (pwm_utils_contex_t *p_ctx, int16_t level) |
| Set the PWM duty cycle corresponding to given int16 value. More... | |
| int16_t | pwm_utils_level_get (pwm_utils_contex_t *p_ctx) |
| Get the int16 value corresponding to the PWM duty cycle. More... | |
| uint32_t | pwm_utils_level_set_unsigned (pwm_utils_contex_t *p_ctx, uint16_t level) |
| Set the PWM duty cycle corresponding to given uint16 value. More... | |
| uint16_t | pwm_utils_level_get_unsigned (pwm_utils_contex_t *p_ctx) |
| Get the uint16 value corresponding to the PWM duty cycle. More... | |
Detailed Description
This module implements some utility functions for using PWM functionality in the application.
Function Documentation
◆ pwm_utils_enable()
| void pwm_utils_enable | ( | pwm_utils_contex_t * | p_ctx | ) |
Enables the PWM channel.
- Parameters
-
[in] p_ctx Pointer to a PWM utility context structure pwm_utils_contex_t.
◆ pwm_utils_level_set()
| void pwm_utils_level_set | ( | pwm_utils_contex_t * | p_ctx, |
| int16_t | level | ||
| ) |
Set the PWM duty cycle corresponding to given int16 value.
This function maps the range [INT16_MIN, INT16_MAX] to [1, PWM max], where PWM max is the tick value for the 100% PWM duty cycle.
- Parameters
-
[in] p_ctx Pointer to a PWM utils context structure pwm_utils_contex_t. [in] level Desired PWM duty cycle represented in the form of int16 value.
◆ pwm_utils_level_get()
| int16_t pwm_utils_level_get | ( | pwm_utils_contex_t * | p_ctx | ) |
Get the int16 value corresponding to the PWM duty cycle.
This function maps the range [1, PWM max] to [INT16_MIN, INT16_MAX], where PWM max is the tick value for the 100% PWM duty cycle.
- Parameters
-
[in] p_ctx Pointer to a PWM utils context structure pwm_utils_contex_t.
- Returns
- int16 representation of the current PWM duty cycle.
◆ pwm_utils_level_set_unsigned()
| uint32_t pwm_utils_level_set_unsigned | ( | pwm_utils_contex_t * | p_ctx, |
| uint16_t | level | ||
| ) |
Set the PWM duty cycle corresponding to given uint16 value.
This function maps the range [0, UINT16_MAX] to [1, PWM max], where PWM max is the tick value for the 100% PWM duty cycle.
- Parameters
-
[in] p_ctx Pointer to a PWM utils context structure pwm_utils_contex_t. [in] level Desired PWM duty cycle represented in the form of uint16 value.
- Return values
-
NRF_SUCCESS Successfully set PWM duty cycle. NRF_ERROR_INVALID_STATE Invalid state to perform operation. NRF_ERROR_BUSY PPI channels for synchronization are still in use.
◆ pwm_utils_level_get_unsigned()
| uint16_t pwm_utils_level_get_unsigned | ( | pwm_utils_contex_t * | p_ctx | ) |
Get the uint16 value corresponding to the PWM duty cycle.
This function maps the range [1, PWM max] to [0, UINT16_MAX], where PWM max is the tick value for the 100% PWM duty cycle.
- Parameters
-
[in] p_ctx Pointer to a PWM utils context structure pwm_utils_contex_t.
- Returns
- uint16 representation of the current PWM duty cycle.