19 #include "device_tick.h"    20 #include "irq_msg_util.h"    22 #include "nrf_assert.h"    23 #include "common_util.h"    25 #define DEV_TICK_MSTIMER    CONCAT_2(MS_TIMER,MS_TIMER_USED_DEVICE_TICKS)    27 #define MSTIMER_TICKS_TO_DEV_TICKS(lfclk_ticks)  (lfclk_ticks/DEVICE_TICK_MSTIMER_DIV_FACTOR)    28 #define DEV_TICKS_TO_MSTIMER_TICKS(dev_ticks)    (dev_ticks*DEVICE_TICK_MSTIMER_DIV_FACTOR)    32   uint32_t half_current_interval;
    33   uint32_t fast_tick_interval;
    34   uint32_t slow_tick_interval;
    35   uint32_t last_tick_count;
    38 static void add_tick(
void){
    39   uint32_t current_count, duration;
    42   duration = (current_count + (1<<24) - device_tick_ctx.last_tick_count) & 0xFFFFFF;
    43   device_tick_ctx.last_tick_count = current_count;
    44   irq_msg_push(MSG_NEXT_INTERVAL,(
void *) (uint32_t) MSTIMER_TICKS_TO_DEV_TICKS(duration));
    47 void tick_timer_handler(
void)
    58         device_tick_ctx.current_mode = cfg->
mode;
    60     device_tick_ctx.fast_tick_interval = cfg->fast_mode_ticks;
    63     device_tick_ctx.half_current_interval =
    68             2*device_tick_ctx.half_current_interval,
    77     if(device_tick_ctx.current_mode != mode){
    78         device_tick_ctx.current_mode = mode;
    80                 device_tick_ctx.slow_tick_interval:
    81                 device_tick_ctx.fast_tick_interval)/2;
    84                 2*device_tick_ctx.half_current_interval, tick_timer_handler);
    91     uint32_t current_count, duration;
    94     duration = (current_count + (1<<24) - device_tick_ctx.last_tick_count) & 0xFFFFFF;
    96     if(duration > device_tick_ctx.half_current_interval)
    99                 2*device_tick_ctx.half_current_interval, tick_timer_handler);
   101         device_tick_ctx.last_tick_count = current_count;
   103                 (
void *) (uint32_t) MSTIMER_TICKS_TO_DEV_TICKS(duration));
 uint32_t ms_timer_get_current_count(void)
Return the current count (24 bit) of the RTC timer used.
 
device_tick_mode mode
The number of LFCLK ticks for the slow mode.
 
uint32_t slow_mode_ticks
The number of LFCLK ticks for the fast mode.
 
device_tick_mode
The two different modes at which the device ticks, fast & slow.
 
Repeated call of the timer.
 
Stucture for passing the configuration for initializing the Device Tick module.
 
#define ASSERT(expression)
Macro for runtime assertion of an expression. If the expression is false the assert_nrf_callback func...
 
void device_tick_init(device_tick_cfg *cfg)
Initializes and starts the Device tick module. Provides a next interval event immediately....
 
void device_tick_process(void)
The function to be called whenever the SoC wakes up to see if more than half the time of the current ...
 
void ms_timer_start(ms_timer_num id, ms_timer_mode mode, uint64_t ticks, void(*handler)(void))
 
void device_tick_switch_mode(device_tick_mode mode)
Switches from the fast to slow mode or vice versa.
 
void irq_msg_push(irq_msg_types pushed_msg, void *more_data)