nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Timekeeping for other modules. More...

Data Structures

struct  iot_timer_client_t
 IoT Timer client structure. More...
 
struct  iot_timer_clients_list_t
 IoT Timer client list structure. More...
 

Macros

#define SEC_TO_MILLISEC(PARAM)   (PARAM * 1000)
 

Typedefs

typedef uint32_t iot_timer_time_in_ms_t
 The type of an instant in milliseconds.
 
typedef void(* iot_timer_tick_cb )(iot_timer_time_in_ms_t wall_clock_value)
 IoT Timer client callback type. More...
 

Functions

uint32_t iot_timer_client_list_set (const iot_timer_clients_list_t *p_list_of_clients)
 Function for setting the list of clients that subscribe for repeated callbacks from the module. More...
 
uint32_t iot_timer_update (void)
 Function for updating the wall clock. More...
 
uint32_t iot_timer_wall_clock_get (iot_timer_time_in_ms_t *p_elapsed_time)
 Function for getting the current wall clock value. More...
 
uint32_t iot_timer_wall_clock_delta_get (iot_timer_time_in_ms_t *p_past_time, iot_timer_time_in_ms_t *p_delta_time)
 Function for getting the difference between the current and an older wall clock value. More...
 

Detailed Description

Timekeeping for other modules.

The IoT Timer stores the value of the wall clock, which represents the time elapsed since startup (or an integer overflow). The unit of timekeeping is milliseconds. The IoT Timer module is conceived to be platform independent, therefore, it does not have an internal tick source. An external source has to update the wall clock of the IoT Timer at regular intervals. Other modules can query the current value of the wall clock and/or can act as clients of the IoT Timer by subscribing to callbacks that are repeated at regular intervals. You can configure the module by changing the sdk_config.h configuration file.

Typedef Documentation

typedef void(* iot_timer_tick_cb)(iot_timer_time_in_ms_t wall_clock_value)

IoT Timer client callback type.

Parameters
[in]wall_clock_valueThe value of the wall clock that triggered the callback.
Return values
None.

Function Documentation

uint32_t iot_timer_client_list_set ( const iot_timer_clients_list_t p_list_of_clients)

Function for setting the list of clients that subscribe for repeated callbacks from the module.

Note
To minimize drift between client callbacks, the callback function of each client should be designed in a way that the duration of execution does not vary and is as short as possible.
Parameters
[in]p_list_of_clientsAddress of the client list. Can be NULL to cancel all subscriptions. To see what parameters are valid, please see the description of iot_timer_client_t.
Return values
NRF_SUCCESSAddress of the list of clients successfully updated.
NRF_ERROR_INVALID_PARAMIf any member of the client list has NULL as a callback procedure or the interval for repeated callbacks is smaller or equal to IOT_TIMER_RESOLUTION_IN_MS or it is not an integral multiple of IOT_TIMER_RESOLUTION_IN_MS.
uint32_t iot_timer_update ( void  )

Function for updating the wall clock.

The application designer must ensure that this function is called at regular intervals, which is set in the sdk_config.h configuration file. If the updated value of the wall clock is an integral multiple of the callback interval of any clients of the module, the callback procedure of the client is executed.

Note
The interrupt that triggers the update of the wall clock should have a high relative priority to minimize inaccuracy.
Return values
NRF_SUCCESSWall clock successfully updated.
uint32_t iot_timer_wall_clock_delta_get ( iot_timer_time_in_ms_t p_past_time,
iot_timer_time_in_ms_t p_delta_time 
)

Function for getting the difference between the current and an older wall clock value.

Note
The accuracy of calculation is limited by the wall clock resolution, as set in the sdk_config.h configuration file.
The time difference can only be calculated correctly if only at most one integer overflow of the wall clock has occured since the past wall clock value was obtained.
Parameters
[in]p_past_timePast value of the wall clock. Has to be an integral multiple of IOT_TIMER_RESOLUTION_IN_MS or zero.
[out]p_delta_timeTime elapsed since p_past_time in milliseconds.
Return values
NRF_SUCCESSQuery successful.
NRF_ERROR_NULLIf p_past_time or p_delta_time is a NULL pointer.
NRF_ERROR_INVALID_PARAMIf p_past_time points to a value that is not an integral multiple of IOT_TIMER_RESOLUTION_IN_MS.
uint32_t iot_timer_wall_clock_get ( iot_timer_time_in_ms_t p_elapsed_time)

Function for getting the current wall clock value.

Note
The accuracy of timekeeping is limited by the resolution, as set in the sdk_config.h configuration file.
Parameters
[out]p_elapsed_timeValue of the wall clock. Time in milliseconds elapsed since startup (or an integer overflow).
Return values
NRF_SUCCESSQuery successful.
NRF_ERROR_NULLIf p_elapsed_time is a NULL pointer.