From c31dae311a1cee906d67db3a39f7131d7e3b1061 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 3 Nov 2021 10:19:13 +0100 Subject: [PATCH] pkg/openthread: migrate to ztimer --- pkg/openthread/Makefile.dep | 3 ++- pkg/openthread/contrib/openthread.c | 1 - pkg/openthread/contrib/platform_alarm.c | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/openthread/Makefile.dep b/pkg/openthread/Makefile.dep index 1ddb74aef2..a1079c2ec5 100644 --- a/pkg/openthread/Makefile.dep +++ b/pkg/openthread/Makefile.dep @@ -3,7 +3,8 @@ USEMODULE += openthread_contrib USEMODULE += netdev USEMODULE += openthread_contrib_netdev USEMODULE += l2util -USEMODULE += xtimer +USEMODULE += ztimer +USEMODULE += ztimer_msec USEMODULE += event FEATURES_REQUIRED += cpp diff --git a/pkg/openthread/contrib/openthread.c b/pkg/openthread/contrib/openthread.c index fe3abfcd90..706f6394f4 100644 --- a/pkg/openthread/contrib/openthread.c +++ b/pkg/openthread/contrib/openthread.c @@ -21,7 +21,6 @@ #include "ot.h" #include "random.h" #include "thread.h" -#include "xtimer.h" #ifdef MODULE_AT86RF2XX #include "at86rf2xx.h" diff --git a/pkg/openthread/contrib/platform_alarm.c b/pkg/openthread/contrib/platform_alarm.c index f83ef28c02..4662c7f93c 100644 --- a/pkg/openthread/contrib/platform_alarm.c +++ b/pkg/openthread/contrib/platform_alarm.c @@ -22,8 +22,7 @@ #include "openthread/platform/alarm-milli.h" #include "ot.h" #include "thread.h" -#include "xtimer.h" -#include "timex.h" +#include "ztimer.h" #define ENABLE_DEBUG 0 #include "debug.h" @@ -44,7 +43,7 @@ void _timeout_cb(void *arg) event_post(openthread_get_evq(), &ev_timer); } -static xtimer_t ot_timer = { +static ztimer_t ot_timer = { .callback = _timeout_cb, }; @@ -66,8 +65,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) event_post(openthread_get_evq(), &ev_timer); } else { - int dt = aDt * US_PER_MS; - xtimer_set(&ot_timer, dt); + ztimer_set(ZTIMER_MSEC, &ot_timer, aDt); } } @@ -76,13 +74,13 @@ void otPlatAlarmMilliStop(otInstance *aInstance) { (void)aInstance; DEBUG("openthread: otPlatAlarmStop\n"); - xtimer_remove(&ot_timer); + ztimer_remove(ZTIMER_MSEC, &ot_timer); } /* OpenThread will call this for getting running time in millisecs */ uint32_t otPlatAlarmMilliGetNow(void) { - uint32_t now = xtimer_now_usec() / US_PER_MS; + uint32_t now = ztimer_now(ZTIMER_MSEC); DEBUG("openthread: otPlatAlarmGetNow: %" PRIu32 "\n", now); return now; }