This module implements some utility functions for using PWM functionality in the application.
More...
|
struct | pwm_utils_contex_t |
| Context structure for defining application specific instance of PWM peripheral to be used with this module. More...
|
|
This module implements some utility functions for using PWM functionality in the application.
◆ pwm_utils_enable()
Enables the PWM channel.
- Parameters
-
◆ pwm_utils_level_set()
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()
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
-
- Returns
- int16 representation of the current PWM duty cycle.
◆ pwm_utils_level_set_unsigned()
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()
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
-
- Returns
- uint16 representation of the current PWM duty cycle.