Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:56 2016 +0100
Revision:
28:041dac1366b2
Parent:
20:a90c48eb1d30
Child:
29:286940b7ee5a
Synchronized with git rev 012b8118
Author: Liyou Zhou
Pull in files from sdk 10.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 28:041dac1366b2 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
vcoubard 28:041dac1366b2 2 *
vcoubard 28:041dac1366b2 3 * The information contained herein is property of Nordic Semiconductor ASA.
vcoubard 28:041dac1366b2 4 * Terms and conditions of usage are described in detail in NORDIC
vcoubard 28:041dac1366b2 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
vcoubard 28:041dac1366b2 6 *
vcoubard 28:041dac1366b2 7 * Licensees are granted free, non-transferable use of the information. NO
vcoubard 28:041dac1366b2 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
vcoubard 28:041dac1366b2 9 * the file.
vcoubard 28:041dac1366b2 10 *
vcoubard 1:ebc0e0ef0a11 11 */
vcoubard 1:ebc0e0ef0a11 12
vcoubard 1:ebc0e0ef0a11 13 /** @file
vcoubard 1:ebc0e0ef0a11 14 *
vcoubard 1:ebc0e0ef0a11 15 * @defgroup app_timer Application Timer
vcoubard 1:ebc0e0ef0a11 16 * @{
vcoubard 1:ebc0e0ef0a11 17 * @ingroup app_common
vcoubard 1:ebc0e0ef0a11 18 *
vcoubard 1:ebc0e0ef0a11 19 * @brief Application timer functionality.
vcoubard 1:ebc0e0ef0a11 20 *
vcoubard 28:041dac1366b2 21 * @details This module enables the application to create multiple timer instances based on the RTC1
vcoubard 28:041dac1366b2 22 * peripheral. Checking for time-outs and invokation of user time-out handlers is performed
vcoubard 1:ebc0e0ef0a11 23 * in the RTC1 interrupt handler. List handling is done using a software interrupt (SWI0).
vcoubard 1:ebc0e0ef0a11 24 * Both interrupt handlers are running in APP_LOW priority level.
vcoubard 1:ebc0e0ef0a11 25 *
vcoubard 28:041dac1366b2 26 * @details When calling app_timer_start() or app_timer_stop(), the timer operation is just queued,
vcoubard 1:ebc0e0ef0a11 27 * and the software interrupt is triggered. The actual timer start/stop operation is
vcoubard 1:ebc0e0ef0a11 28 * executed by the SWI0 interrupt handler. Since the SWI0 interrupt is running in APP_LOW,
vcoubard 1:ebc0e0ef0a11 29 * if the application code calling the timer function is running in APP_LOW or APP_HIGH,
vcoubard 1:ebc0e0ef0a11 30 * the timer operation will not be performed until the application handler has returned.
vcoubard 28:041dac1366b2 31 * This will be the case, for example, when stopping a timer from a time-out handler when not using
vcoubard 1:ebc0e0ef0a11 32 * the scheduler.
vcoubard 1:ebc0e0ef0a11 33 *
vcoubard 1:ebc0e0ef0a11 34 * @details Use the USE_SCHEDULER parameter of the APP_TIMER_INIT() macro to select if the
vcoubard 28:041dac1366b2 35 * @ref app_scheduler should be used or not. Even if the scheduler is
vcoubard 28:041dac1366b2 36 * not used, app_timer.h will include app_scheduler.h, so when
vcoubard 1:ebc0e0ef0a11 37 * compiling, app_scheduler.h must be available in one of the compiler include paths.
vcoubard 1:ebc0e0ef0a11 38 */
vcoubard 1:ebc0e0ef0a11 39
vcoubard 1:ebc0e0ef0a11 40 #ifndef APP_TIMER_H__
vcoubard 1:ebc0e0ef0a11 41 #define APP_TIMER_H__
vcoubard 1:ebc0e0ef0a11 42
vcoubard 1:ebc0e0ef0a11 43 #include <stdint.h>
vcoubard 1:ebc0e0ef0a11 44 #include <stdbool.h>
vcoubard 1:ebc0e0ef0a11 45 #include <stdio.h>
vcoubard 1:ebc0e0ef0a11 46 #include "app_error.h"
vcoubard 1:ebc0e0ef0a11 47 #include "app_util.h"
vcoubard 1:ebc0e0ef0a11 48 #include "compiler_abstraction.h"
vcoubard 1:ebc0e0ef0a11 49
vcoubard 1:ebc0e0ef0a11 50 #define APP_TIMER_CLOCK_FREQ 32768 /**< Clock frequency of the RTC timer used to implement the app timer module. */
vcoubard 1:ebc0e0ef0a11 51 #define APP_TIMER_MIN_TIMEOUT_TICKS 5 /**< Minimum value of the timeout_ticks parameter of app_timer_start(). */
vcoubard 1:ebc0e0ef0a11 52
vcoubard 28:041dac1366b2 53 #define APP_TIMER_NODE_SIZE 32 /**< Size of app_timer.timer_node_t (used to allocate data). */
vcoubard 1:ebc0e0ef0a11 54 #define APP_TIMER_USER_OP_SIZE 24 /**< Size of app_timer.timer_user_op_t (only for use inside APP_TIMER_BUF_SIZE()). */
vcoubard 1:ebc0e0ef0a11 55 #define APP_TIMER_USER_SIZE 8 /**< Size of app_timer.timer_user_t (only for use inside APP_TIMER_BUF_SIZE()). */
vcoubard 1:ebc0e0ef0a11 56 #define APP_TIMER_INT_LEVELS 3 /**< Number of interrupt levels from where timer operations may be initiated (only for use inside APP_TIMER_BUF_SIZE()). */
vcoubard 1:ebc0e0ef0a11 57
vcoubard 1:ebc0e0ef0a11 58 /**@brief Compute number of bytes required to hold the application timer data structures.
vcoubard 1:ebc0e0ef0a11 59 *
vcoubard 1:ebc0e0ef0a11 60 * @param[in] OP_QUEUE_SIZE Size of queues holding timer operations that are pending execution.
vcoubard 28:041dac1366b2 61 * Note that due to the queue implementation, this size must be one more
vcoubard 1:ebc0e0ef0a11 62 * than the size that is actually needed.
vcoubard 1:ebc0e0ef0a11 63 *
vcoubard 1:ebc0e0ef0a11 64 * @return Required application timer buffer size (in bytes).
vcoubard 1:ebc0e0ef0a11 65 */
vcoubard 28:041dac1366b2 66 #define APP_TIMER_BUF_SIZE(OP_QUEUE_SIZE) \
vcoubard 1:ebc0e0ef0a11 67 ( \
vcoubard 1:ebc0e0ef0a11 68 ( \
vcoubard 1:ebc0e0ef0a11 69 APP_TIMER_INT_LEVELS \
vcoubard 1:ebc0e0ef0a11 70 * \
vcoubard 1:ebc0e0ef0a11 71 (APP_TIMER_USER_SIZE + ((OP_QUEUE_SIZE) + 1) * APP_TIMER_USER_OP_SIZE) \
vcoubard 1:ebc0e0ef0a11 72 ) \
vcoubard 1:ebc0e0ef0a11 73 )
vcoubard 1:ebc0e0ef0a11 74
vcoubard 1:ebc0e0ef0a11 75 /**@brief Convert milliseconds to timer ticks.
vcoubard 1:ebc0e0ef0a11 76 *
vcoubard 28:041dac1366b2 77 * This macro uses 64-bit integer arithmetic, but as long as the macro parameters are
vcoubard 1:ebc0e0ef0a11 78 * constants (i.e. defines), the computation will be done by the preprocessor.
vcoubard 1:ebc0e0ef0a11 79 *
vcoubard 28:041dac1366b2 80 * When using this macro, ensure that the
vcoubard 1:ebc0e0ef0a11 81 * values provided as input result in an output value that is supported by the
vcoubard 1:ebc0e0ef0a11 82 * @ref app_timer_start function. For example, when the ticks for 1 ms is needed, the
vcoubard 1:ebc0e0ef0a11 83 * maximum possible value of PRESCALER must be 6, when @ref APP_TIMER_CLOCK_FREQ is 32768.
vcoubard 1:ebc0e0ef0a11 84 * This will result in a ticks value as 5. Any higher value for PRESCALER will result in a
vcoubard 1:ebc0e0ef0a11 85 * ticks value that is not supported by this module.
vcoubard 1:ebc0e0ef0a11 86 *
vcoubard 28:041dac1366b2 87 * @param[in] MS Milliseconds.
vcoubard 28:041dac1366b2 88 * @param[in] PRESCALER Value of the RTC1 PRESCALER register (must be the same value that was
vcoubard 28:041dac1366b2 89 * passed to APP_TIMER_INIT()).
vcoubard 28:041dac1366b2 90 *
vcoubard 1:ebc0e0ef0a11 91 * @return Number of timer ticks.
vcoubard 1:ebc0e0ef0a11 92 */
vcoubard 1:ebc0e0ef0a11 93 #define APP_TIMER_TICKS(MS, PRESCALER)\
vcoubard 1:ebc0e0ef0a11 94 ((uint32_t)ROUNDED_DIV((MS) * (uint64_t)APP_TIMER_CLOCK_FREQ, ((PRESCALER) + 1) * 1000))
vcoubard 1:ebc0e0ef0a11 95
vcoubard 28:041dac1366b2 96 typedef struct app_timer_t { uint32_t data[CEIL_DIV(APP_TIMER_NODE_SIZE, sizeof(uint32_t))]; } app_timer_t;
vcoubard 28:041dac1366b2 97
vcoubard 28:041dac1366b2 98 /**@brief Timer ID type.
vcoubard 28:041dac1366b2 99 * Never declare a variable of this type, but use the macro @ref APP_TIMER_DEF instead.*/
vcoubard 28:041dac1366b2 100 typedef app_timer_t * app_timer_id_t;
vcoubard 1:ebc0e0ef0a11 101
vcoubard 28:041dac1366b2 102 /**
vcoubard 28:041dac1366b2 103 * @brief Create a timer identifier and statically allocate memory for the timer.
vcoubard 28:041dac1366b2 104 *
vcoubard 28:041dac1366b2 105 * @param timer_id Name of the timer identifier variable that will be used to control the timer.
vcoubard 28:041dac1366b2 106 */
vcoubard 28:041dac1366b2 107 #define APP_TIMER_DEF(timer_id) \
vcoubard 28:041dac1366b2 108 static app_timer_t timer_id##_data = { {0} }; \
vcoubard 28:041dac1366b2 109 static const app_timer_id_t timer_id = &timer_id##_data
vcoubard 28:041dac1366b2 110
vcoubard 28:041dac1366b2 111
vcoubard 28:041dac1366b2 112 /**@brief Application time-out handler type. */
vcoubard 1:ebc0e0ef0a11 113 typedef void (*app_timer_timeout_handler_t)(void * p_context);
vcoubard 1:ebc0e0ef0a11 114
vcoubard 1:ebc0e0ef0a11 115 /**@brief Type of function for passing events from the timer module to the scheduler. */
vcoubard 1:ebc0e0ef0a11 116 typedef uint32_t (*app_timer_evt_schedule_func_t) (app_timer_timeout_handler_t timeout_handler,
vcoubard 1:ebc0e0ef0a11 117 void * p_context);
vcoubard 1:ebc0e0ef0a11 118
vcoubard 1:ebc0e0ef0a11 119 /**@brief Timer modes. */
vcoubard 1:ebc0e0ef0a11 120 typedef enum
vcoubard 1:ebc0e0ef0a11 121 {
vcoubard 1:ebc0e0ef0a11 122 APP_TIMER_MODE_SINGLE_SHOT, /**< The timer will expire only once. */
vcoubard 1:ebc0e0ef0a11 123 APP_TIMER_MODE_REPEATED /**< The timer will restart each time it expires. */
vcoubard 1:ebc0e0ef0a11 124 } app_timer_mode_t;
vcoubard 1:ebc0e0ef0a11 125
vcoubard 28:041dac1366b2 126 /**@brief Initialize the application timer module.
vcoubard 1:ebc0e0ef0a11 127 *
vcoubard 28:041dac1366b2 128 * @details This macro handles dimensioning and allocation of the memory buffer required by the timer,
vcoubard 1:ebc0e0ef0a11 129 * making sure that the buffer is correctly aligned. It will also connect the timer module
vcoubard 1:ebc0e0ef0a11 130 * to the scheduler (if specified).
vcoubard 1:ebc0e0ef0a11 131 *
vcoubard 28:041dac1366b2 132 * @note This module assumes that the LFCLK is already running. If it is not, the module will
vcoubard 28:041dac1366b2 133 * be non-functional, since the RTC will not run. If you do not use a SoftDevice, you
vcoubard 28:041dac1366b2 134 * must start the LFCLK manually. See the rtc_example's lfclk_config() function
vcoubard 28:041dac1366b2 135 * for an example of how to do this. If you use a SoftDevice, the LFCLK is started on
vcoubard 28:041dac1366b2 136 * SoftDevice init.
vcoubard 1:ebc0e0ef0a11 137 *
vcoubard 1:ebc0e0ef0a11 138 *
vcoubard 1:ebc0e0ef0a11 139 * @param[in] PRESCALER Value of the RTC1 PRESCALER register. This will decide the
vcoubard 1:ebc0e0ef0a11 140 * timer tick rate. Set to 0 for no prescaling.
vcoubard 1:ebc0e0ef0a11 141 * @param[in] OP_QUEUES_SIZE Size of queues holding timer operations that are pending execution.
vcoubard 1:ebc0e0ef0a11 142 * @param[in] SCHEDULER_FUNC Pointer to scheduler event handler
vcoubard 1:ebc0e0ef0a11 143 *
vcoubard 1:ebc0e0ef0a11 144 * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
vcoubard 28:041dac1366b2 145 * several times as long as it is from the same location, for example, to do a re-initialization).
vcoubard 1:ebc0e0ef0a11 146 */
vcoubard 1:ebc0e0ef0a11 147 /*lint -emacro(506, APP_TIMER_INIT) */ /* Suppress "Constant value Boolean */
vcoubard 28:041dac1366b2 148 #define APP_TIMER_INIT(PRESCALER, OP_QUEUES_SIZE, SCHEDULER_FUNC) \
vcoubard 1:ebc0e0ef0a11 149 do \
vcoubard 1:ebc0e0ef0a11 150 { \
vcoubard 28:041dac1366b2 151 static uint32_t APP_TIMER_BUF[CEIL_DIV(APP_TIMER_BUF_SIZE((OP_QUEUES_SIZE) + 1), \
vcoubard 1:ebc0e0ef0a11 152 sizeof(uint32_t))]; \
vcoubard 1:ebc0e0ef0a11 153 uint32_t ERR_CODE = app_timer_init((PRESCALER), \
vcoubard 1:ebc0e0ef0a11 154 (OP_QUEUES_SIZE) + 1, \
vcoubard 1:ebc0e0ef0a11 155 APP_TIMER_BUF, \
vcoubard 1:ebc0e0ef0a11 156 SCHEDULER_FUNC); \
vcoubard 1:ebc0e0ef0a11 157 APP_ERROR_CHECK(ERR_CODE); \
vcoubard 1:ebc0e0ef0a11 158 } while (0)
vcoubard 1:ebc0e0ef0a11 159
vcoubard 28:041dac1366b2 160
vcoubard 28:041dac1366b2 161
vcoubard 1:ebc0e0ef0a11 162 /**@brief Function for initializing the timer module.
vcoubard 1:ebc0e0ef0a11 163 *
vcoubard 28:041dac1366b2 164 * Normally, initialization should be done using the APP_TIMER_INIT() macro, because that macro will both
vcoubard 28:041dac1366b2 165 * allocate the buffers needed by the timer module (including aligning the buffers correctly)
vcoubard 28:041dac1366b2 166 * and take care of connecting the timer module to the scheduler (if specified).
vcoubard 1:ebc0e0ef0a11 167 *
vcoubard 1:ebc0e0ef0a11 168 * @param[in] prescaler Value of the RTC1 PRESCALER register. Set to 0 for no prescaling.
vcoubard 1:ebc0e0ef0a11 169 * @param[in] op_queues_size Size of queues holding timer operations that are pending
vcoubard 28:041dac1366b2 170 * execution. Note that due to the queue implementation, this size must
vcoubard 1:ebc0e0ef0a11 171 * be one more than the size that is actually needed.
vcoubard 1:ebc0e0ef0a11 172 * @param[in] p_buffer Pointer to memory buffer for internal use in the app_timer
vcoubard 1:ebc0e0ef0a11 173 * module. The size of the buffer can be computed using the
vcoubard 1:ebc0e0ef0a11 174 * APP_TIMER_BUF_SIZE() macro. The buffer must be aligned to a
vcoubard 1:ebc0e0ef0a11 175 * 4 byte boundary.
vcoubard 28:041dac1366b2 176 * @param[in] evt_schedule_func Function for passing time-out events to the scheduler. Point to
vcoubard 1:ebc0e0ef0a11 177 * app_timer_evt_schedule() to connect to the scheduler. Set to NULL
vcoubard 28:041dac1366b2 178 * to make the timer module call the time-out handler directly from
vcoubard 1:ebc0e0ef0a11 179 * the timer interrupt handler.
vcoubard 1:ebc0e0ef0a11 180 *
vcoubard 28:041dac1366b2 181 * @retval NRF_SUCCESS If the module was initialized successfully.
vcoubard 28:041dac1366b2 182 * @retval NRF_ERROR_INVALID_PARAM If a parameter was invalid (buffer not aligned to a 4 byte
vcoubard 1:ebc0e0ef0a11 183 * boundary or NULL).
vcoubard 1:ebc0e0ef0a11 184 */
vcoubard 1:ebc0e0ef0a11 185 uint32_t app_timer_init(uint32_t prescaler,
vcoubard 1:ebc0e0ef0a11 186 uint8_t op_queues_size,
vcoubard 1:ebc0e0ef0a11 187 void * p_buffer,
vcoubard 1:ebc0e0ef0a11 188 app_timer_evt_schedule_func_t evt_schedule_func);
vcoubard 1:ebc0e0ef0a11 189
vcoubard 1:ebc0e0ef0a11 190 /**@brief Function for creating a timer instance.
vcoubard 1:ebc0e0ef0a11 191 *
vcoubard 28:041dac1366b2 192 * @param[in] p_timer_id Pointer to timer identifier.
vcoubard 1:ebc0e0ef0a11 193 * @param[in] mode Timer mode.
vcoubard 1:ebc0e0ef0a11 194 * @param[in] timeout_handler Function to be executed when the timer expires.
vcoubard 1:ebc0e0ef0a11 195 *
vcoubard 28:041dac1366b2 196 * @retval NRF_SUCCESS If the timer was successfully created.
vcoubard 28:041dac1366b2 197 * @retval NRF_ERROR_INVALID_PARAM If a parameter was invalid.
vcoubard 28:041dac1366b2 198 * @retval NRF_ERROR_INVALID_STATE If the application timer module has not been initialized or
vcoubard 28:041dac1366b2 199 * the timer is running.
vcoubard 1:ebc0e0ef0a11 200 *
vcoubard 1:ebc0e0ef0a11 201 * @note This function does the timer allocation in the caller's context. It is also not protected
vcoubard 1:ebc0e0ef0a11 202 * by a critical region. Therefore care must be taken not to call it from several interrupt
vcoubard 1:ebc0e0ef0a11 203 * levels simultaneously.
vcoubard 28:041dac1366b2 204 * @note The function can be called again on the timer instance and will re-initialize the instance if
vcoubard 28:041dac1366b2 205 * the timer is not running.
vcoubard 28:041dac1366b2 206 * @attention The FreeRTOS and RTX app_timer implementation does not allow app_timer_create to
vcoubard 28:041dac1366b2 207 * be called on the previously initialized instance.
vcoubard 1:ebc0e0ef0a11 208 */
vcoubard 28:041dac1366b2 209 uint32_t app_timer_create(app_timer_id_t const * p_timer_id,
vcoubard 1:ebc0e0ef0a11 210 app_timer_mode_t mode,
vcoubard 1:ebc0e0ef0a11 211 app_timer_timeout_handler_t timeout_handler);
vcoubard 1:ebc0e0ef0a11 212
vcoubard 1:ebc0e0ef0a11 213 /**@brief Function for starting a timer.
vcoubard 1:ebc0e0ef0a11 214 *
vcoubard 28:041dac1366b2 215 * @param[in] timer_id Timer identifier.
vcoubard 28:041dac1366b2 216 * @param[in] timeout_ticks Number of ticks (of RTC1, including prescaling) to time-out event
vcoubard 28:041dac1366b2 217 * (minimum 5 ticks).
vcoubard 28:041dac1366b2 218 * @param[in] p_context General purpose pointer. Will be passed to the time-out handler when
vcoubard 28:041dac1366b2 219 * the timer expires.
vcoubard 1:ebc0e0ef0a11 220 *
vcoubard 28:041dac1366b2 221 * @retval NRF_SUCCESS If the timer was successfully started.
vcoubard 28:041dac1366b2 222 * @retval NRF_ERROR_INVALID_PARAM If a parameter was invalid.
vcoubard 28:041dac1366b2 223 * @retval NRF_ERROR_INVALID_STATE If the application timer module has not been initialized or the timer
vcoubard 1:ebc0e0ef0a11 224 * has not been created.
vcoubard 28:041dac1366b2 225 * @retval NRF_ERROR_NO_MEM If the timer operations queue was full.
vcoubard 1:ebc0e0ef0a11 226 *
vcoubard 1:ebc0e0ef0a11 227 * @note The minimum timeout_ticks value is 5.
vcoubard 28:041dac1366b2 228 * @note For multiple active timers, time-outs occurring in close proximity to each other (in the
vcoubard 1:ebc0e0ef0a11 229 * range of 1 to 3 ticks) will have a positive jitter of maximum 3 ticks.
vcoubard 28:041dac1366b2 230 * @note When calling this method on a timer that is already running, the second start operation
vcoubard 28:041dac1366b2 231 * is ignored.
vcoubard 1:ebc0e0ef0a11 232 */
vcoubard 1:ebc0e0ef0a11 233 uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context);
vcoubard 1:ebc0e0ef0a11 234
vcoubard 1:ebc0e0ef0a11 235 /**@brief Function for stopping the specified timer.
vcoubard 1:ebc0e0ef0a11 236 *
vcoubard 28:041dac1366b2 237 * @param[in] timer_id Timer identifier.
vcoubard 1:ebc0e0ef0a11 238 *
vcoubard 28:041dac1366b2 239 * @retval NRF_SUCCESS If the timer was successfully stopped.
vcoubard 28:041dac1366b2 240 * @retval NRF_ERROR_INVALID_PARAM If a parameter was invalid.
vcoubard 28:041dac1366b2 241 * @retval NRF_ERROR_INVALID_STATE If the application timer module has not been initialized or the timer
vcoubard 1:ebc0e0ef0a11 242 * has not been created.
vcoubard 28:041dac1366b2 243 * @retval NRF_ERROR_NO_MEM If the timer operations queue was full.
vcoubard 1:ebc0e0ef0a11 244 */
vcoubard 1:ebc0e0ef0a11 245 uint32_t app_timer_stop(app_timer_id_t timer_id);
vcoubard 1:ebc0e0ef0a11 246
vcoubard 1:ebc0e0ef0a11 247 /**@brief Function for stopping all running timers.
vcoubard 1:ebc0e0ef0a11 248 *
vcoubard 28:041dac1366b2 249 * @retval NRF_SUCCESS If all timers were successfully stopped.
vcoubard 28:041dac1366b2 250 * @retval NRF_ERROR_INVALID_STATE If the application timer module has not been initialized.
vcoubard 28:041dac1366b2 251 * @retval NRF_ERROR_NO_MEM If the timer operations queue was full.
vcoubard 1:ebc0e0ef0a11 252 */
vcoubard 1:ebc0e0ef0a11 253 uint32_t app_timer_stop_all(void);
vcoubard 1:ebc0e0ef0a11 254
vcoubard 1:ebc0e0ef0a11 255 /**@brief Function for returning the current value of the RTC1 counter.
vcoubard 1:ebc0e0ef0a11 256 *
vcoubard 1:ebc0e0ef0a11 257 * @param[out] p_ticks Current value of the RTC1 counter.
vcoubard 1:ebc0e0ef0a11 258 *
vcoubard 28:041dac1366b2 259 * @retval NRF_SUCCESS If the counter was successfully read.
vcoubard 1:ebc0e0ef0a11 260 */
vcoubard 1:ebc0e0ef0a11 261 uint32_t app_timer_cnt_get(uint32_t * p_ticks);
vcoubard 1:ebc0e0ef0a11 262
vcoubard 1:ebc0e0ef0a11 263 /**@brief Function for computing the difference between two RTC1 counter values.
vcoubard 1:ebc0e0ef0a11 264 *
vcoubard 1:ebc0e0ef0a11 265 * @param[in] ticks_to Value returned by app_timer_cnt_get().
vcoubard 1:ebc0e0ef0a11 266 * @param[in] ticks_from Value returned by app_timer_cnt_get().
vcoubard 1:ebc0e0ef0a11 267 * @param[out] p_ticks_diff Number of ticks from ticks_from to ticks_to.
vcoubard 1:ebc0e0ef0a11 268 *
vcoubard 28:041dac1366b2 269 * @retval NRF_SUCCESS If the counter difference was successfully computed.
vcoubard 1:ebc0e0ef0a11 270 */
vcoubard 1:ebc0e0ef0a11 271 uint32_t app_timer_cnt_diff_compute(uint32_t ticks_to,
vcoubard 1:ebc0e0ef0a11 272 uint32_t ticks_from,
vcoubard 1:ebc0e0ef0a11 273 uint32_t * p_ticks_diff);
vcoubard 1:ebc0e0ef0a11 274
vcoubard 1:ebc0e0ef0a11 275 #endif // APP_TIMER_H__
vcoubard 1:ebc0e0ef0a11 276
vcoubard 1:ebc0e0ef0a11 277 /** @} */