Nordic stack and drivers for the mbed BLE API

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Wed Jul 16 10:53:07 2014 +0100
Revision:
45:3c4df37ed83e
Parent:
37:c29c330d942c
Child:
56:a1071b629aa3
add cplusplus guards for the cases where C files include the headers

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