mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +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
|
* unrelated components are altered that change the systems's power
|
||||||
* management behavior.
|
* 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
|
* @param[in] clock ztimer clock to operate on
|
||||||
*
|
*
|
||||||
* @return Current count on @p clock
|
* @return Current count on @p clock
|
||||||
*/
|
*/
|
||||||
static inline ztimer_now_t ztimer_now(ztimer_clock_t *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 MODULE_ZTIMER_NOW64
|
||||||
if (1) {
|
if (1) {
|
||||||
#elif MODULE_ZTIMER_EXTEND
|
#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
|
* 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.
|
* 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] clock ztimer clock to operate on
|
||||||
* @param[in] last_wakeup base time stamp for the wakeup
|
* @param[in] last_wakeup base time stamp for the wakeup
|
||||||
* @param[in] period time in ticks that will be added to @p last_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
|
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
|
config MODULE_ZTIMER_ONDEMAND_TIMER
|
||||||
bool "Run Timer only on demand"
|
bool "Run Timer only on demand"
|
||||||
depends on MODULE_ZTIMER_PERIPH_TIMER
|
depends on MODULE_ZTIMER_PERIPH_TIMER
|
||||||
|
Loading…
Reference in New Issue
Block a user