From 3b5662e1167363ebf56fab958922a352dca11118 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Wed, 8 Dec 2021 10:54:51 +0100 Subject: [PATCH] gnrc/netif: convert to ztimer --- sys/net/gnrc/Makefile.dep | 1 + sys/net/gnrc/netif/gnrc_netif.c | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/net/gnrc/Makefile.dep b/sys/net/gnrc/Makefile.dep index 6adb734191..36736af2fc 100644 --- a/sys/net/gnrc/Makefile.dep +++ b/sys/net/gnrc/Makefile.dep @@ -137,6 +137,7 @@ ifneq (,$(filter gnrc_netif,$(USEMODULE))) USEMODULE += netif USEMODULE += l2util USEMODULE += fmt + USEMODULE += ztimer_msec ifneq (,$(filter netdev_ieee802154_submac,$(USEMODULE))) USEMODULE += gnrc_netif_pktq endif diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index ff420bdad2..4c197e999e 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -41,8 +41,8 @@ #include "fmt.h" #include "log.h" #include "sched.h" -#if IS_USED(MODULE_XTIMER) || IS_USED(MODULE_ZTIMER_XTIMER_COMPAT) -#include "xtimer.h" +#if IS_USED(MODULE_ZTIMER) +#include "ztimer.h" #endif #include "net/gnrc/netif.h" @@ -1370,7 +1370,7 @@ bool gnrc_netif_ipv6_wait_for_global_address(gnrc_netif_t *netif, /* wait for global address */ msg_t m; while (!has_global) { - if (xtimer_msg_receive_timeout(&m, timeout_ms * US_PER_MS) < 0) { + if (ztimer_msg_receive_timeout(ZTIMER_MSEC, &m, timeout_ms) < 0) { DEBUG_PUTS("gnrc_netif: timeout waiting for prefix"); break; } @@ -1867,7 +1867,7 @@ static void *_gnrc_netif_thread(void *args) /* now let rest of GNRC use the interface */ gnrc_netif_release(netif); #if (CONFIG_GNRC_NETIF_MIN_WAIT_AFTER_SEND_US > 0U) - xtimer_ticks32_t last_wakeup = xtimer_now(); + uint32_t last_wakeup = ztimer_now(ZTIMER_USEC); #endif while (1) { @@ -1893,13 +1893,14 @@ static void *_gnrc_netif_thread(void *args) DEBUG("gnrc_netif: GNRC_NETDEV_MSG_TYPE_SND received\n"); _send(netif, msg.content.ptr, false); #if (CONFIG_GNRC_NETIF_MIN_WAIT_AFTER_SEND_US > 0U) - xtimer_periodic_wakeup( + ztimer_periodic_wakeup( + ZTIMER_USEC, &last_wakeup, CONFIG_GNRC_NETIF_MIN_WAIT_AFTER_SEND_US ); /* override last_wakeup in case last_wakeup + * CONFIG_GNRC_NETIF_MIN_WAIT_AFTER_SEND_US was in the past */ - last_wakeup = xtimer_now(); + last_wakeup = ztimer_now(ZTIMER_USEC); #endif break; case GNRC_NETAPI_MSG_TYPE_SET: