mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ztimer: add on_demand_strict
Enforce ztimer_clock_t to be active (i.e. clock->users > 0) before ztimer_now() can be called.
This commit is contained in:
parent
a1ee7a5e05
commit
88a9f4b8f9
@ -659,12 +659,18 @@ ztimer_now_t _ztimer_now_extend(ztimer_clock_t *clock);
|
||||
* unrelated components are altered that change the systems's power
|
||||
* management behavior.
|
||||
*
|
||||
* @warning Make sure to call @ref ztimer_acquire(@p clock) before fetching
|
||||
* the clock's current time.
|
||||
*
|
||||
* @param[in] clock ztimer clock to operate on
|
||||
*
|
||||
* @return Current count on @p clock
|
||||
*/
|
||||
static inline ztimer_now_t ztimer_now(ztimer_clock_t *clock)
|
||||
{
|
||||
#if MODULE_ZTIMER_ONDEMAND_STRICT
|
||||
assert(clock->users > 0);
|
||||
#endif
|
||||
#if MODULE_ZTIMER_NOW64
|
||||
if (1) {
|
||||
#elif MODULE_ZTIMER_EXTEND
|
||||
@ -693,6 +699,10 @@ static inline ztimer_now_t ztimer_now(ztimer_clock_t *clock)
|
||||
* If the time (@p last_wakeup + @p period) has already passed, the function
|
||||
* sets @p last_wakeup to @p last_wakeup + @p period and returns immediately.
|
||||
*
|
||||
* @warning Make sure to call @ref ztimer_acquire(@p clock) before making use
|
||||
* of @ref ztimer_periodic_wakeup. After usage
|
||||
* @ref ztimer_release(@p clock) should be called.
|
||||
*
|
||||
* @param[in] clock ztimer clock to operate on
|
||||
* @param[in] last_wakeup base time stamp for the wakeup
|
||||
* @param[in] period time in ticks that will be added to @p last_wakeup
|
||||
|
@ -236,6 +236,11 @@ menuconfig MODULE_ZTIMER_ONDEMAND
|
||||
|
||||
if MODULE_ZTIMER_ONDEMAND
|
||||
|
||||
config MODULE_ZTIMER_ONDEMAND_STRICT
|
||||
bool "Strict ztimer on demand"
|
||||
help
|
||||
Enforce ztimer clocks to be running before calling ztimer_now().
|
||||
|
||||
config MODULE_ZTIMER_ONDEMAND_TIMER
|
||||
bool "Run Timer only on demand"
|
||||
depends on MODULE_ZTIMER_PERIPH_TIMER
|
||||
|
Loading…
Reference in New Issue
Block a user