1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #15780 from haukepetersen/opt_ztimer_isset

ztimer: add ztimer_is_set() to user API
This commit is contained in:
Kaspar Schleiser 2021-01-20 12:42:21 +01:00 committed by GitHub
commit a1250963d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

View File

@ -349,6 +349,17 @@ void ztimer_handler(ztimer_clock_t *clock);
*/
void ztimer_set(ztimer_clock_t *clock, ztimer_t *timer, uint32_t val);
/**
* @brief Check if a timer is currently active
*
* @param[in] clock ztimer clock to operate on
* @param[in] timer timer to check
*
* @return > 0 if timer is active
* @return 0 if timer is not active
*/
unsigned ztimer_is_set(const ztimer_clock_t *clock, const ztimer_t *timer);
/**
* @brief Remove a timer from a clock
*

View File

@ -58,6 +58,15 @@ static unsigned _is_set(const ztimer_clock_t *clock, const ztimer_t *t)
}
}
unsigned ztimer_is_set(const ztimer_clock_t *clock, const ztimer_t *timer)
{
unsigned state = irq_disable();
unsigned res = _is_set(clock, timer);
irq_restore(state);
return res;
}
void ztimer_remove(ztimer_clock_t *clock, ztimer_t *timer)
{
unsigned state = irq_disable();

View File

@ -70,6 +70,11 @@ int main(void)
ztimer_periodic_start(&t);
if (!ztimer_is_set(ZTIMER_MSEC, &t.timer)) {
print_str("Test failed\n");
return 1;
}
/* wait for periodic to trigger N times */
mutex_lock(&_mutex);