18 Timer/counter (TIMER)

Timer/counter (TIMER) user guide link.

/**@brief Initialize the application timer module.
 * @details This macro handles dimensioning and allocation of the memory buffer required by the timer,
 *          making sure that the buffer is correctly aligned. It will also connect the timer module
 *          to the scheduler (if specified).
 * @note    This module assumes that the LFCLK is already running. If it is not, the module will
 *          be non-functional, since the RTC will not run. If you do not use a SoftDevice, you
 *          must start the LFCLK manually. See the rtc_example's lfclk_config() function
 *          for an example of how to do this. If you use a SoftDevice, the LFCLK is started on
 *          SoftDevice init.
 * @param[in]  PRESCALER        Value of the RTC1 PRESCALER register. This will decide the
 *                              timer tick rate. Set to 0 for no prescaling.
 * @param[in]  OP_QUEUE_SIZE    Size of the queue holding timer operations that are pending execution.
 * @param[in]  SCHEDULER_FUNC   Pointer to scheduler event handler
 * @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
 *       several times as long as it is from the same location, for example, to do a re-initialization).
/*lint -emacro(506, APP_TIMER_INIT) */ /* Suppress "Constant value Boolean */
    do                                                                            \
    {                                                                             \
                                               sizeof(uint32_t))];                \
        uint32_t ERR_CODE = app_timer_init((PRESCALER),                           \
                                           (OP_QUEUE_SIZE) + 1,                   \
                                           APP_TIMER_BUF,                         \
                                           SCHEDULER_FUNC);                       \
        APP_ERROR_CHECK(ERR_CODE);                                                \
    } while (0)