The existing API had two almost identical functions: _set_time() and _timer_idle_enter(). Both simply instruct the timer driver to set the next timer interrupt expiration appropriately so that the call to z_clock_announce() will be made at the requested number of ticks. On most/all hardware, these should be implementable identically. Unfortunately because they are specified differently, existing drivers have implemented them in parallel. Specify a new, unified, z_clock_set_timeout(). Document it clearly for implementors. And provide a shim layer for legacy drivers that will continue to use the old functions. Note that this patch fixes an existing bug found by inspection: the old call to _set_time() out of z_clock_announce() failed to test for the "wait forever" case in the situation where clock_always_on is true, meaning that a system that reached this point and then never set another timeout would freeze its uptime clock incorrectly. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
32 lines
730 B
C
32 lines
730 B
C
#ifndef ZEPHYR_LEGACY_SET_TIME_H__
|
|
#define ZEPHYR_LEGACY_SET_TIME_H__
|
|
|
|
/* Stub implementation of z_clock_set_timeout() in terms of the
|
|
* original APIs. Used by older timer drivers. Should be replaced.
|
|
*
|
|
* Yes, this "header" includes a function definition and must be
|
|
* included only once in a single compilation.
|
|
*/
|
|
|
|
|
|
#ifdef CONFIG_TICKLESS_KERNEL
|
|
void _set_time(u32_t time);
|
|
#endif
|
|
|
|
#ifdef CONFIG_TICKLESS_IDLE
|
|
void _timer_idle_enter(s32_t ticks);
|
|
void _timer_idle_exit(void);
|
|
#endif
|
|
|
|
extern void z_clock_set_timeout(s32_t ticks, bool idle)
|
|
{
|
|
#ifdef CONFIG_TICKLESS_KERNEL
|
|
if (idle) {
|
|
_timer_idle_enter(ticks);
|
|
} else {
|
|
_set_time(ticks == K_FOREVER ? 0 : ticks);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
#endif /* ZEPHYR_LEGACY_SET_TIME_H__ */
|