The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2015 Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 3 * All rights reserved.
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 143:86740a56073b 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 143:86740a56073b 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 143:86740a56073b 15 *
AnnaBridge 143:86740a56073b 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 143:86740a56073b 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 143:86740a56073b 18 * written permission.
AnnaBridge 143:86740a56073b 19 *
AnnaBridge 143:86740a56073b 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 143:86740a56073b 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 143:86740a56073b 22 *
AnnaBridge 143:86740a56073b 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 143:86740a56073b 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 143:86740a56073b 25 *
AnnaBridge 143:86740a56073b 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 36 *
AnnaBridge 143:86740a56073b 37 */
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40 /** @file
AnnaBridge 143:86740a56073b 41 *
AnnaBridge 143:86740a56073b 42 * @defgroup app_pwm Pulse-width modulation (PWM)
AnnaBridge 143:86740a56073b 43 * @{
AnnaBridge 143:86740a56073b 44 * @ingroup app_common
AnnaBridge 143:86740a56073b 45 *
AnnaBridge 143:86740a56073b 46 * @brief Module for generating a pulse-width modulated output signal.
AnnaBridge 143:86740a56073b 47 *
AnnaBridge 143:86740a56073b 48 * @details This module provides a PWM implementation using timers, GPIOTE, and PPI.
AnnaBridge 143:86740a56073b 49 *
AnnaBridge 143:86740a56073b 50 * Resource usage:
AnnaBridge 143:86740a56073b 51 * - 2 PPI channels per instance + 2 PPI channels per PWM channel.
AnnaBridge 143:86740a56073b 52 * - 1 PPI group per instance.
AnnaBridge 143:86740a56073b 53 * - 1 GPIOTE channel per PWM channel.
AnnaBridge 143:86740a56073b 54 *
AnnaBridge 143:86740a56073b 55 * For example, a PWM instance with two channels will consume 2+4 PPI channels, 1 PPI group, and 2 GPIOTE channels.
AnnaBridge 143:86740a56073b 56 *
AnnaBridge 143:86740a56073b 57 * The maximum number of PWM channels per instance is 2.
AnnaBridge 143:86740a56073b 58 */
AnnaBridge 143:86740a56073b 59
AnnaBridge 143:86740a56073b 60 #ifndef APP_PWM_H__
AnnaBridge 143:86740a56073b 61 #define APP_PWM_H__
AnnaBridge 143:86740a56073b 62
AnnaBridge 143:86740a56073b 63 #include <stdint.h>
AnnaBridge 143:86740a56073b 64 #include "sdk_errors.h"
AnnaBridge 143:86740a56073b 65 #include "nrf_drv_timer.h"
AnnaBridge 143:86740a56073b 66 #include "nrf_drv_common.h"
AnnaBridge 143:86740a56073b 67 #include "nrf_drv_ppi.h"
AnnaBridge 143:86740a56073b 68
AnnaBridge 143:86740a56073b 69
AnnaBridge 143:86740a56073b 70 #define APP_PWM_NOPIN 0xFFFFFFFF
AnnaBridge 143:86740a56073b 71
AnnaBridge 143:86740a56073b 72 /** @brief Number of channels for one timer instance (fixed to 2 due to timer properties).*/
AnnaBridge 143:86740a56073b 73 #define APP_PWM_CHANNELS_PER_INSTANCE 2
AnnaBridge 143:86740a56073b 74
AnnaBridge 143:86740a56073b 75 /**@brief Macro for creating a PWM instance. */
AnnaBridge 143:86740a56073b 76 #define APP_PWM_INSTANCE(name, num) \
AnnaBridge 143:86740a56073b 77 const nrf_drv_timer_t m_pwm_##name##_timer = NRF_DRV_TIMER_INSTANCE(num); \
AnnaBridge 143:86740a56073b 78 app_pwm_cb_t m_pwm_##name##_cb; \
AnnaBridge 143:86740a56073b 79 /*lint -e{545}*/ \
AnnaBridge 143:86740a56073b 80 const app_pwm_t name = { \
AnnaBridge 143:86740a56073b 81 .p_cb = &m_pwm_##name##_cb, \
AnnaBridge 143:86740a56073b 82 .p_timer = &m_pwm_##name##_timer, \
AnnaBridge 143:86740a56073b 83 }
AnnaBridge 143:86740a56073b 84
AnnaBridge 143:86740a56073b 85
AnnaBridge 143:86740a56073b 86 /**@brief PWM instance default configuration (1 channel). */
AnnaBridge 143:86740a56073b 87 #define APP_PWM_DEFAULT_CONFIG_1CH(period_in_us, pin) \
AnnaBridge 143:86740a56073b 88 { \
AnnaBridge 143:86740a56073b 89 .pins = {pin, APP_PWM_NOPIN}, \
AnnaBridge 143:86740a56073b 90 .pin_polarity = {APP_PWM_POLARITY_ACTIVE_LOW, APP_PWM_POLARITY_ACTIVE_LOW}, \
AnnaBridge 143:86740a56073b 91 .num_of_channels = 1, \
AnnaBridge 143:86740a56073b 92 .period_us = period_in_us \
AnnaBridge 143:86740a56073b 93 }
AnnaBridge 143:86740a56073b 94
AnnaBridge 143:86740a56073b 95 /**@brief PWM instance default configuration (2 channels). */
AnnaBridge 143:86740a56073b 96 #define APP_PWM_DEFAULT_CONFIG_2CH(period_in_us, pin0, pin1) \
AnnaBridge 143:86740a56073b 97 { \
AnnaBridge 143:86740a56073b 98 .pins = {pin0, pin1}, \
AnnaBridge 143:86740a56073b 99 .pin_polarity = {APP_PWM_POLARITY_ACTIVE_LOW, APP_PWM_POLARITY_ACTIVE_LOW}, \
AnnaBridge 143:86740a56073b 100 .num_of_channels = 2, \
AnnaBridge 143:86740a56073b 101 .period_us = period_in_us \
AnnaBridge 143:86740a56073b 102 }
AnnaBridge 143:86740a56073b 103
AnnaBridge 143:86740a56073b 104 typedef uint16_t app_pwm_duty_t;
AnnaBridge 143:86740a56073b 105
AnnaBridge 143:86740a56073b 106 /**
AnnaBridge 143:86740a56073b 107 * @brief PWM callback that is executed when a PWM duty change has been completed.
AnnaBridge 143:86740a56073b 108 *
AnnaBridge 143:86740a56073b 109 * @param[in] pwm_id PWM instance ID.
AnnaBridge 143:86740a56073b 110 */
AnnaBridge 143:86740a56073b 111 typedef void (* app_pwm_callback_t)(uint32_t);
AnnaBridge 143:86740a56073b 112
AnnaBridge 143:86740a56073b 113 /**
AnnaBridge 143:86740a56073b 114 * @brief Channel polarity.
AnnaBridge 143:86740a56073b 115 */
AnnaBridge 143:86740a56073b 116 typedef enum
AnnaBridge 143:86740a56073b 117 {
AnnaBridge 143:86740a56073b 118 APP_PWM_POLARITY_ACTIVE_LOW = 0,
AnnaBridge 143:86740a56073b 119 APP_PWM_POLARITY_ACTIVE_HIGH = 1
AnnaBridge 143:86740a56073b 120 } app_pwm_polarity_t;
AnnaBridge 143:86740a56073b 121
AnnaBridge 143:86740a56073b 122 /**@brief PWM configuration structure used for initialization. */
AnnaBridge 143:86740a56073b 123 typedef struct
AnnaBridge 143:86740a56073b 124 {
AnnaBridge 143:86740a56073b 125 uint32_t pins[APP_PWM_CHANNELS_PER_INSTANCE]; //!< Pins configured as PWM output.
AnnaBridge 143:86740a56073b 126 app_pwm_polarity_t pin_polarity[APP_PWM_CHANNELS_PER_INSTANCE]; //!< Polarity of active state on pin.
AnnaBridge 143:86740a56073b 127 uint32_t num_of_channels; //!< Number of channels that can be used.
AnnaBridge 143:86740a56073b 128 uint32_t period_us; //!< PWM signal output period to configure (in microseconds).
AnnaBridge 143:86740a56073b 129 } app_pwm_config_t;
AnnaBridge 143:86740a56073b 130
AnnaBridge 143:86740a56073b 131
AnnaBridge 143:86740a56073b 132 /**
AnnaBridge 143:86740a56073b 133 * @cond (NODOX)
AnnaBridge 143:86740a56073b 134 * @defgroup app_pwm_internal Auxiliary internal types declarations
AnnaBridge 143:86740a56073b 135 * @{
AnnaBridge 143:86740a56073b 136 * @internal
AnnaBridge 143:86740a56073b 137 *
AnnaBridge 143:86740a56073b 138 * @brief Module for internal usage inside the library only
AnnaBridge 143:86740a56073b 139 *
AnnaBridge 143:86740a56073b 140 * There are some definitions that must be included in the header file because
AnnaBridge 143:86740a56073b 141 * of the way the library is set up. In this way, the are accessible to the user.
AnnaBridge 143:86740a56073b 142 * However, any functions and variables defined here may change at any time
AnnaBridge 143:86740a56073b 143 * without a warning, so you should not access them directly.
AnnaBridge 143:86740a56073b 144 */
AnnaBridge 143:86740a56073b 145
AnnaBridge 143:86740a56073b 146 /**
AnnaBridge 143:86740a56073b 147 * @brief PWM channel instance
AnnaBridge 143:86740a56073b 148 *
AnnaBridge 143:86740a56073b 149 * This structure holds all data needed by a single PWM channel.
AnnaBridge 143:86740a56073b 150 */
AnnaBridge 143:86740a56073b 151 typedef struct
AnnaBridge 143:86740a56073b 152 {
AnnaBridge 143:86740a56073b 153 uint32_t gpio_pin; //!< Pin that is used by this PWM channel.
AnnaBridge 143:86740a56073b 154 uint32_t pulsewidth; //!< The copy of duty currently set (in ticks).
AnnaBridge 143:86740a56073b 155 nrf_ppi_channel_t ppi_channels[2]; //!< PPI channels used by the PWM channel to clear and set the output.
AnnaBridge 143:86740a56073b 156 app_pwm_polarity_t polarity; //!< The active state of the pin.
AnnaBridge 143:86740a56073b 157 uint8_t initialized; //!< The internal information if the selected channel was initialized.
AnnaBridge 143:86740a56073b 158 } app_pwm_channel_cb_t;
AnnaBridge 143:86740a56073b 159
AnnaBridge 143:86740a56073b 160 /**
AnnaBridge 143:86740a56073b 161 * @brief Variable part of PWM instance
AnnaBridge 143:86740a56073b 162 *
AnnaBridge 143:86740a56073b 163 * This structure holds instance data that may change.
AnnaBridge 143:86740a56073b 164 */
AnnaBridge 143:86740a56073b 165 typedef struct
AnnaBridge 143:86740a56073b 166 {
AnnaBridge 143:86740a56073b 167 app_pwm_channel_cb_t channels_cb[APP_PWM_CHANNELS_PER_INSTANCE]; //!< Channels data
AnnaBridge 143:86740a56073b 168 uint32_t period; //!< Selected period in ticks
AnnaBridge 143:86740a56073b 169 app_pwm_callback_t p_ready_callback; //!< Callback function called on PWM readiness
AnnaBridge 143:86740a56073b 170 nrf_ppi_channel_t ppi_channels[2]; //!< PPI channels used temporary while changing duty
AnnaBridge 143:86740a56073b 171 nrf_ppi_channel_group_t ppi_group; //!< PPI group used to synchronize changes on channels
AnnaBridge 143:86740a56073b 172 nrf_drv_state_t state; //!< Current driver status
AnnaBridge 143:86740a56073b 173 } app_pwm_cb_t;
AnnaBridge 143:86740a56073b 174 /** @}
AnnaBridge 143:86740a56073b 175 * @endcond
AnnaBridge 143:86740a56073b 176 */
AnnaBridge 143:86740a56073b 177
AnnaBridge 143:86740a56073b 178
AnnaBridge 143:86740a56073b 179 /**@brief PWM instance structure. */
AnnaBridge 143:86740a56073b 180 typedef struct
AnnaBridge 143:86740a56073b 181 {
AnnaBridge 143:86740a56073b 182 app_pwm_cb_t *p_cb; //!< Pointer to control block internals.
AnnaBridge 143:86740a56073b 183 nrf_drv_timer_t const * const p_timer; //!< Timer used by this PWM instance.
AnnaBridge 143:86740a56073b 184 } app_pwm_t;
AnnaBridge 143:86740a56073b 185
AnnaBridge 143:86740a56073b 186 /**
AnnaBridge 143:86740a56073b 187 * @brief Function for checking if the PWM instance is busy updating the duty cycle.
AnnaBridge 143:86740a56073b 188 *
AnnaBridge 143:86740a56073b 189 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 190 *
AnnaBridge 143:86740a56073b 191 * @retval True If the PWM instance is ready for duty cycle changes.
AnnaBridge 143:86740a56073b 192 * @retval False If a change operation is in progress.
AnnaBridge 143:86740a56073b 193 */
AnnaBridge 143:86740a56073b 194 bool app_pwm_busy_check(app_pwm_t const * const p_instance);
AnnaBridge 143:86740a56073b 195
AnnaBridge 143:86740a56073b 196 /**
AnnaBridge 143:86740a56073b 197 * @brief Function for initializing a PWM instance.
AnnaBridge 143:86740a56073b 198 *
AnnaBridge 143:86740a56073b 199 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 200 * @param[in] p_config Initial configuration.
AnnaBridge 143:86740a56073b 201 * @param[in] p_ready_callback Pointer to ready callback function (or NULL to disable).
AnnaBridge 143:86740a56073b 202 *
AnnaBridge 143:86740a56073b 203 * @retval NRF_SUCCESS If initialization was successful.
AnnaBridge 143:86740a56073b 204 * @retval NRF_ERROR_NO_MEM If there were not enough free resources.
AnnaBridge 143:86740a56073b 205 * @retval NRF_ERROR_INVALID_PARAM If an invalid configuration structure was passed.
AnnaBridge 143:86740a56073b 206 * @retval NRF_ERROR_INVALID_STATE If the timer/PWM is already in use or if initialization failed.
AnnaBridge 143:86740a56073b 207 */
AnnaBridge 143:86740a56073b 208 ret_code_t app_pwm_init(app_pwm_t const * const p_instance, app_pwm_config_t const * const p_config,
AnnaBridge 143:86740a56073b 209 app_pwm_callback_t p_ready_callback);
AnnaBridge 143:86740a56073b 210
AnnaBridge 143:86740a56073b 211
AnnaBridge 143:86740a56073b 212 /**
AnnaBridge 143:86740a56073b 213 * @brief Function for uninitializing a PWM instance and releasing the allocated resources.
AnnaBridge 143:86740a56073b 214 *
AnnaBridge 143:86740a56073b 215 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 216 *
AnnaBridge 143:86740a56073b 217 * @retval NRF_SUCCESS If uninitialization was successful.
AnnaBridge 143:86740a56073b 218 * @retval NRF_ERROR_INVALID_STATE If the given instance was not initialized.
AnnaBridge 143:86740a56073b 219 */
AnnaBridge 143:86740a56073b 220 ret_code_t app_pwm_uninit(app_pwm_t const * const p_instance);
AnnaBridge 143:86740a56073b 221
AnnaBridge 143:86740a56073b 222 /**
AnnaBridge 143:86740a56073b 223 * @brief Function for enabling a PWM instance after initialization.
AnnaBridge 143:86740a56073b 224 *
AnnaBridge 143:86740a56073b 225 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 226 */
AnnaBridge 143:86740a56073b 227 void app_pwm_enable(app_pwm_t const * const p_instance);
AnnaBridge 143:86740a56073b 228
AnnaBridge 143:86740a56073b 229 /**
AnnaBridge 143:86740a56073b 230 * @brief Function for disabling a PWM instance after initialization.
AnnaBridge 143:86740a56073b 231 *
AnnaBridge 143:86740a56073b 232 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 233 */
AnnaBridge 143:86740a56073b 234 void app_pwm_disable(app_pwm_t const * const p_instance);
AnnaBridge 143:86740a56073b 235
AnnaBridge 143:86740a56073b 236 /**
AnnaBridge 143:86740a56073b 237 * @brief Function for setting the PWM channel duty cycle in percents.
AnnaBridge 143:86740a56073b 238 *
AnnaBridge 143:86740a56073b 239 * A duty cycle change requires one full PWM clock period to finish.
AnnaBridge 143:86740a56073b 240 * If another change is attempted for any channel of given instance before
AnnaBridge 143:86740a56073b 241 * the current change is complete, the new attempt will result in the error
AnnaBridge 143:86740a56073b 242 * NRF_ERROR_BUSY.
AnnaBridge 143:86740a56073b 243 *
AnnaBridge 143:86740a56073b 244 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 245 * @param[in] channel Channel number.
AnnaBridge 143:86740a56073b 246 * @param[in] duty Duty cycle (0 - 100).
AnnaBridge 143:86740a56073b 247 *
AnnaBridge 143:86740a56073b 248 * @retval NRF_SUCCESS If the operation was successful.
AnnaBridge 143:86740a56073b 249 * @retval NRF_ERROR_BUSY If the PWM is not ready yet.
AnnaBridge 143:86740a56073b 250 * @retval NRF_ERROR_INVALID_STATE If the given instance was not initialized.
AnnaBridge 143:86740a56073b 251 *
AnnaBridge 143:86740a56073b 252 */
AnnaBridge 143:86740a56073b 253 ret_code_t app_pwm_channel_duty_set(app_pwm_t const * const p_instance,
AnnaBridge 143:86740a56073b 254 uint8_t channel, app_pwm_duty_t duty);
AnnaBridge 143:86740a56073b 255
AnnaBridge 143:86740a56073b 256 /**
AnnaBridge 143:86740a56073b 257 * @brief Function for retrieving the PWM channel duty cycle in percents.
AnnaBridge 143:86740a56073b 258 *
AnnaBridge 143:86740a56073b 259 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 260 * @param[in] channel Channel number.
AnnaBridge 143:86740a56073b 261 *
AnnaBridge 143:86740a56073b 262 * @return Duty cycle value.
AnnaBridge 143:86740a56073b 263 */
AnnaBridge 143:86740a56073b 264 app_pwm_duty_t app_pwm_channel_duty_get(app_pwm_t const * const p_instance, uint8_t channel);
AnnaBridge 143:86740a56073b 265
AnnaBridge 143:86740a56073b 266
AnnaBridge 143:86740a56073b 267 /**
AnnaBridge 143:86740a56073b 268 * @name Functions accessing values in ticks
AnnaBridge 143:86740a56073b 269 *
AnnaBridge 143:86740a56073b 270 * Auxiliary functions that allow to get values in actual timer ticks.
AnnaBridge 143:86740a56073b 271 * @{
AnnaBridge 143:86740a56073b 272 */
AnnaBridge 143:86740a56073b 273
AnnaBridge 143:86740a56073b 274 /**
AnnaBridge 143:86740a56073b 275 * @brief Function for setting PWM channel duty cycle in clock ticks.
AnnaBridge 143:86740a56073b 276 *
AnnaBridge 143:86740a56073b 277 * @note Duty cycle changes require one full PWM clock period to finish.
AnnaBridge 143:86740a56073b 278 * Until that, the next change attempt (for any channel of given instance)
AnnaBridge 143:86740a56073b 279 * will result in an NRF_ERROR_BUSY error.
AnnaBridge 143:86740a56073b 280 *
AnnaBridge 143:86740a56073b 281 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 282 * @param[in] channel Channel number.
AnnaBridge 143:86740a56073b 283 * @param[in] ticks Number of PWM clock ticks.
AnnaBridge 143:86740a56073b 284 *
AnnaBridge 143:86740a56073b 285 * @retval NRF_SUCCESS If the operation was successful.
AnnaBridge 143:86740a56073b 286 * @retval NRF_ERROR_BUSY If PWM is not ready yet.
AnnaBridge 143:86740a56073b 287 * @retval NRF_ERROR_INVALID_STATE If the given instance was not initialized.
AnnaBridge 143:86740a56073b 288 */
AnnaBridge 143:86740a56073b 289 ret_code_t app_pwm_channel_duty_ticks_set(app_pwm_t const * const p_instance,
AnnaBridge 143:86740a56073b 290 uint8_t channel,
AnnaBridge 143:86740a56073b 291 uint16_t ticks);
AnnaBridge 143:86740a56073b 292
AnnaBridge 143:86740a56073b 293
AnnaBridge 143:86740a56073b 294 /**
AnnaBridge 143:86740a56073b 295 * @brief Function for retrieving the PWM channel duty cycle in ticks.
AnnaBridge 143:86740a56073b 296 *
AnnaBridge 143:86740a56073b 297 * This function retrieves the real, currently set duty cycle in ticks.
AnnaBridge 143:86740a56073b 298 * For one full PWM cycle the value might be different than the value set by the last
AnnaBridge 143:86740a56073b 299 * @ref app_pwm_channel_duty_ticks_set function call.
AnnaBridge 143:86740a56073b 300 *
AnnaBridge 143:86740a56073b 301 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 302 * @param[in] channel Channel number.
AnnaBridge 143:86740a56073b 303 *
AnnaBridge 143:86740a56073b 304 * @return Number of ticks set for selected channel.
AnnaBridge 143:86740a56073b 305 *
AnnaBridge 143:86740a56073b 306 */
AnnaBridge 143:86740a56073b 307 uint16_t app_pwm_channel_duty_ticks_get(app_pwm_t const * const p_instance, uint8_t channel);
AnnaBridge 143:86740a56073b 308
AnnaBridge 143:86740a56073b 309 /**
AnnaBridge 143:86740a56073b 310 * @brief Function for returning the number of ticks in a whole cycle.
AnnaBridge 143:86740a56073b 311 *
AnnaBridge 143:86740a56073b 312 * @param[in] p_instance PWM instance.
AnnaBridge 143:86740a56073b 313 *
AnnaBridge 143:86740a56073b 314 * @return Number of ticks that corresponds to 100% of the duty cycle.
AnnaBridge 143:86740a56073b 315 */
AnnaBridge 143:86740a56073b 316 uint16_t app_pwm_cycle_ticks_get(app_pwm_t const * const p_instance);
AnnaBridge 143:86740a56073b 317 /** @} */
AnnaBridge 143:86740a56073b 318
AnnaBridge 143:86740a56073b 319
AnnaBridge 143:86740a56073b 320 #endif
AnnaBridge 143:86740a56073b 321
AnnaBridge 143:86740a56073b 322 /** @} */