mediCAL's first BLE project

Dependents:   BLE_mediCAL

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Mon Jul 07 13:43:31 2014 +0100
Revision:
37:c29c330d942c
Parent:
0:eff01767de02
Child:
45:3c4df37ed83e
changes required to upgrade to V7 of the soft-device

Who changed what in which revision?

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