nRF5 IoT SDK
v0.9.0
|
Many of the modules in an IPv6 stack need to take regular periodic actions and the period does not have to have to be accurately distanced. Using a dedicated timer for each of such modules has proven to be very resource hungry. The IoT Timer module aims to provide the needed timekeeping functionality. The unit of timekeeping is milliseconds and the IoT Timer's resolution is configurable by IOT_TIMER_RESOLUTION_IN_MS. To conserve power, this value should be set as high as allowed by the requirements. 100 ms can be used in most practical use cases.
The IoT Timer module can provide periodic callbacks for other modules based on their configured needs. The callback intervals can be configured as integral multiples of the resolution set by IOT_TIMER_RESOLUTION_IN_MS. It is also possible to receive a wall clock reference from the IoT Timer. This functionality can be used if regular periodic callbacks are not needed by a module, but it needs a reference wall clock to determine the time difference between certain events.
To be platform independent, the module has no internal tick source. Therefore, the application designer must cater the IoT Timer with calling the iot_timer_update procedure at regular intervals. For proper functioning, the interval between updates must be the same as IOT_TIMER_RESOLUTION_IN_MS.
Modules can query the IoT Timer for the current value of the wall clock with iot_timer_wall_clock_get.
Modules can act as clients of the IoT Timer by using iot_timer_client_list_set. After each update of the wall clock the module will cycle through the list of clients. If the updated value of the wall clock is an integral multiple of the callback interval of any clients, the callback procedure of the client is executed. 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.
The list of clients can be set to NULL with iot_timer_client_list_set to cancel all subscriptions.
The following configuration parameters should be defined in sdk_config.h
.
The resolution of timekeeping in milliseconds.
Restriction | Value |
---|---|
Minimum value | 1 |
Dependencies | None, but the application designer must ensure that the iot_timer_update procedure is called repeatedly with the same frequency. |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module.
API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |