From 47b8439cd85240491c712dbdf1916504d6e70f8a Mon Sep 17 00:00:00 2001 From: Juergen Fitschen Date: Fri, 20 Mar 2020 11:45:01 +0100 Subject: [PATCH] sys/evtimer: add helper for retrieving the current system time --- sys/include/evtimer.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/include/evtimer.h b/sys/include/evtimer.h index da8dc9a1ef..f4d7580350 100644 --- a/sys/include/evtimer.h +++ b/sys/include/evtimer.h @@ -46,6 +46,7 @@ #include #include "xtimer.h" +#include "timex.h" #ifdef __cplusplus extern "C" { @@ -105,6 +106,22 @@ void evtimer_del(evtimer_t *evtimer, evtimer_event_t *event); */ void evtimer_print(const evtimer_t *evtimer); +/** + * @brief Return the current system time in msec + */ +static inline uint32_t evtimer_now_msec(void) +{ + return xtimer_now_usec64() / US_PER_MS; +} + +/** + * @brief Return the current system time in minutes + */ +static inline uint32_t evtimer_now_min(void) +{ + return xtimer_now_usec64() / (US_PER_SEC * SEC_PER_MIN); +} + #ifdef __cplusplus } #endif