From 03dccb568dee0085cd5863eb9120de45785cd162 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Tue, 9 Jan 2018 14:37:45 +0100 Subject: [PATCH] sys/event/timeout: add timeout_clear() function --- sys/event/timeout.c | 5 +++++ sys/include/event/timeout.h | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/sys/event/timeout.c b/sys/event/timeout.c index c26e63f091..e7d4d0a4d3 100644 --- a/sys/event/timeout.c +++ b/sys/event/timeout.c @@ -26,3 +26,8 @@ void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout) { xtimer_set(&event_timeout->timer, timeout); } + +void event_timeout_clear(event_timeout_t *event_timeout) +{ + xtimer_remove(&event_timeout->timer); +} diff --git a/sys/include/event/timeout.h b/sys/include/event/timeout.h index 0d13e65ea7..1d101ba3fd 100644 --- a/sys/include/event/timeout.h +++ b/sys/include/event/timeout.h @@ -74,6 +74,18 @@ void event_timeout_init(event_timeout_t *event_timeout, event_queue_t *queue, ev */ void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout); +/** + * @brief Clear a timeout event + * + * Calling this function will cancel the timeout by removing its underlying + * timer. If the timer has already fired before calling this function, the + * connected event will be put already into the given event queue and this + * function does not have any effect. + * + * @param[in] event_timeout event_timeout context object to use + */ +void event_timeout_clear(event_timeout_t *event_timeout); + #ifdef __cplusplus } #endif