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:
parent
c4400e8964
commit
cbde66f610
@ -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)))
|
||||||
|
@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user