1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/trickle: Remove xtimer and only use ztimer

This commit is contained in:
MrKevinWeiss 2023-03-17 12:04:44 +01:00
parent c4400e8964
commit cbde66f610
No known key found for this signature in database
GPG Key ID: 4B69974722CBEEAE
3 changed files with 2 additions and 25 deletions

View File

@ -225,12 +225,7 @@ endif
ifneq (,$(filter trickle,$(USEMODULE))) ifneq (,$(filter trickle,$(USEMODULE)))
USEMODULE += random USEMODULE += random
ifeq (,$(filter ztimer_msec,$(USEMODULE))) USEMODULE += ztimer_msec
USEMODULE += xtimer
ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
USEMODULE += ztimer_msec
endif
endif
endif endif
ifneq (,$(filter eui_provider,$(USEMODULE))) ifneq (,$(filter eui_provider,$(USEMODULE)))

View File

@ -33,11 +33,7 @@
#endif #endif
#include "thread.h" #include "thread.h"
#if IS_USED(MODULE_ZTIMER_MSEC)
#include "ztimer.h" #include "ztimer.h"
#else
#include "xtimer.h"
#endif
/** /**
* @brief Trickle callback function with arguments * @brief Trickle callback function with arguments
@ -63,13 +59,8 @@ typedef struct {
trickle_callback_t callback; /**< callback function and parameter that trickle_callback_t callback; /**< callback function and parameter that
trickle calls after each interval */ trickle calls after each interval */
msg_t msg; /**< the msg_t to use for intervals */ msg_t msg; /**< the msg_t to use for intervals */
#if IS_USED(MODULE_ZTIMER_MSEC)
ztimer_t msg_timer; /**< timer to send a msg_t to the target ztimer_t msg_timer; /**< timer to send a msg_t to the target
thread for a new interval */ thread for a new interval */
#else
xtimer_t msg_timer; /**< xtimer to send a msg_t to the target
thread for a new interval */
#endif
} trickle_t; } trickle_t;
/** /**

View File

@ -19,6 +19,7 @@
#include "inttypes.h" #include "inttypes.h"
#include "random.h" #include "random.h"
#include "trickle.h" #include "trickle.h"
#include "ztimer.h"
#define ENABLE_DEBUG 0 #define ENABLE_DEBUG 0
#include "debug.h" #include "debug.h"
@ -53,14 +54,8 @@ void trickle_interval(trickle_t *trickle)
/* old_interval == trickle->I / 2 */ /* old_interval == trickle->I / 2 */
trickle->t = random_uint32_range(old_interval, trickle->I); trickle->t = random_uint32_range(old_interval, trickle->I);
#if IS_USED(MODULE_ZTIMER_MSEC)
ztimer_set_msg(ZTIMER_MSEC, &trickle->msg_timer, (trickle->t + diff), ztimer_set_msg(ZTIMER_MSEC, &trickle->msg_timer, (trickle->t + diff),
&trickle->msg, trickle->pid); &trickle->msg, trickle->pid);
#else
uint64_t msg_time = (trickle->t + diff) * US_PER_MS;
xtimer_set_msg64(&trickle->msg_timer, msg_time, &trickle->msg,
trickle->pid);
#endif
} }
void trickle_reset_timer(trickle_t *trickle) void trickle_reset_timer(trickle_t *trickle)
@ -93,11 +88,7 @@ void trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t msg_type,
void trickle_stop(trickle_t *trickle) void trickle_stop(trickle_t *trickle)
{ {
#if IS_USED(MODULE_ZTIMER_MSEC)
ztimer_remove(ZTIMER_MSEC, &trickle->msg_timer); ztimer_remove(ZTIMER_MSEC, &trickle->msg_timer);
#else
xtimer_remove(&trickle->msg_timer);
#endif
} }
void trickle_increment_counter(trickle_t *trickle) void trickle_increment_counter(trickle_t *trickle)