nRF5 SDK v17.1.0
Data Structures | Typedefs | Enumerations | Functions

Module for declaring Time API. More...

Data Structures

struct  sys_timer_t
 Timer descriptor. More...
 

Typedefs

typedef uint64_t sys_time_t
 Unsigned type of system time.
 
typedef int64_t sys_signed_time_t
 Signed type of system time.
 
typedef void(* sys_timer_callback_t )(void *p_data)
 Prototype of the user-defined timer callback. More...
 

Enumerations

enum  sys_timer_type_t {
  SYS_TIMER_ONESHOT,
  SYS_TIMER_PERIODIC
}
 System timer type (one-shot or periodic timer). More...
 

Functions

void sys_timers_init (void)
 Function for initializing the timers module.
 
void sys_timer_start (sys_timer_t *p_timer)
 Function for starting the timer. More...
 
void sys_timer_stop (sys_timer_t *p_timer)
 Function for stopping the timer. More...
 
bool sys_timer_is_started (sys_timer_t *p_timer)
 Function for checking if input timer has been started. More...
 
sys_time_t sys_time_get (void)
 Function for getting the current system time. More...
 
void sys_time_delay_us (uint32_t delay_us)
 Function for implementing a delay for short hardware delays. More...
 
void sys_timer_adjust (void)
 Function for executing expired timers after sleep.
 

Detailed Description

Module for declaring Time API.

The system time module implements some routines to deal with time (timers). The timer can be started by sys_timer_start(), stopped by sys_timer_stop(), and adjusted after sleep by sys_timer_adjust(). Some information can be acquired by sys_timer_is_started() and sys_time_get(). The correct API for implementing hardware delays is sys_time_delay_us(). Note that the module must be initialized by sys_timers_init() which is done by sys_init().

Typedef Documentation

typedef void(* sys_timer_callback_t)(void *p_data)

Prototype of the user-defined timer callback.

Parameters
p_dataPointer to the data, specific for this callback.

Enumeration Type Documentation

System timer type (one-shot or periodic timer).

Enumerator
SYS_TIMER_ONESHOT 

The timer is Oneshot

SYS_TIMER_PERIODIC 

The timer is Periodic

Function Documentation

void sys_time_delay_us ( uint32_t  delay_us)

Function for implementing a delay for short hardware delays.

Warning
Interrupts are NOT disabled inside this function.
Parameters
[in]delay_usNumber of microseconds to delay.
sys_time_t sys_time_get ( void  )

Function for getting the current system time.

Return values
Thecurrent system timer counter value in microseconds.
bool sys_timer_is_started ( sys_timer_t p_timer)

Function for checking if input timer has been started.

Parameters
[in]p_timerPointer to a timer.
Return values
truep_timer has been started and has not been stopped yet.
falsep_timer has never been started or already timed out.
void sys_timer_start ( sys_timer_t p_timer)

Function for starting the timer.

See the description of sys_timer_t fields for the details on how to program the timer.

Parameters
[in]p_timerPointer to a valid timer descriptor, which is filled by the user, according to sys_timer_t fields description.
void sys_timer_stop ( sys_timer_t p_timer)

Function for stopping the timer.

This function is used to stop the timer, which was started earlier. After this function is called, the timer will not fire.

Parameters
[in]p_timerPointer to a valid timer descriptor.

Documentation feedback | Developer Zone | Subscribe | Updated