The Energest module provides functions for keeping track when components are on, off or in different modes. The API for the Energest module is shown in the following table.
|Get the system time from the Energest time source.
|The number of ticks per second from the Energest time source.
|Set the specified type to on and start tracking the time.
|Set the specified type to off and update the total time.
|Switch from tracking time for the first type to the second type.
|Get the total time Energest has been tracking.
|Flush the Energest times for all components that are currently turned on.
|uint64_t energest_type_time(energest_type_t type)
|Read the total time the specified type has been turned on.
|Initialize the Energest module.
1. The macro ENERGEST_CURRENT_TIME returns a platform dependent system time for use by the Energest module and the constant ENERGEST_SECOND specifies the number of ticks per second.
2. The macros ENERGEST_ON, ENERGEST_OFF, and ENERGEST_SWITCH are used to tell the Energest module when a component changes mode and is normally only called by platforms and device drivers. When a component switches from one mode to another, it is recommended to use ENERGEST_SWITCH as it provides better accuracy.
3. The macro ENERGEST_GET_TOTAL_TIME() returns the total time the Energest module has been tracking. This is normally the same as CPU + LPM + DEEP_LPM but can be overridden by platforms that provide additional Energest types.
4. The function energest_flush updates the total time for all types that are currently turned on.
5. The function energest_type_time returns the total time the specified type has been turned on. energy_flush should be called before reading the total time to ensure the total time has been updated.
6. The function energest_init() is called by the system during the boot-up procedure to initialize the Energest module.