Timekeeping for other modules.
More...
|
#define | SEC_TO_MILLISEC(PARAM) (PARAM * 1000) |
|
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.
IoT Timer client callback type.
- Parameters
-
[in] | wall_clock_value | The value of the wall clock that triggered the callback. |
- Return values
-
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_clients | Address 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_SUCCESS | Address of the list of clients successfully updated. |
NRF_ERROR_INVALID_PARAM | If 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_SUCCESS | Wall clock successfully updated. |
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_time | Past value of the wall clock. Has to be an integral multiple of IOT_TIMER_RESOLUTION_IN_MS or zero. |
[out] | p_delta_time | Time elapsed since p_past_time in milliseconds. |
- Return values
-
NRF_SUCCESS | Query successful. |
NRF_ERROR_NULL | If p_past_time or p_delta_time is a NULL pointer. |
NRF_ERROR_INVALID_PARAM | If p_past_time points to a value that is not an integral multiple of IOT_TIMER_RESOLUTION_IN_MS. |
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_time | Value of the wall clock. Time in milliseconds elapsed since startup (or an integer overflow). |
- Return values
-
NRF_SUCCESS | Query successful. |
NRF_ERROR_NULL | If p_elapsed_time is a NULL pointer. |