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

net/csma_sender: convert to ztimer_usec

This commit is contained in:
Karl Fessel 2022-02-23 18:02:46 +01:00
parent ddbf64ccca
commit eabdf45b30
2 changed files with 5 additions and 4 deletions

View File

@ -99,7 +99,7 @@ endif
ifneq (,$(filter csma_sender,$(USEMODULE)))
USEMODULE += random
USEMODULE += xtimer
USEMODULE += ztimer_usec
endif
ifneq (,$(filter dhcpv6_%,$(USEMODULE)))

View File

@ -22,8 +22,9 @@
#include <errno.h>
#include <stdbool.h>
#include <inttypes.h>
#include <kernel_defines.h>
#include "xtimer.h"
#include "ztimer.h"
#include "random.h"
#include "net/netdev.h"
#include "net/netopt.h"
@ -152,7 +153,7 @@ int csma_sender_csma_ca_send(netdev_t *dev, iolist_t *iolist,
/* if we arrive here, then we must perform the CSMA/CA procedure
ourselves by software */
random_init(xtimer_now_usec());
random_init(ztimer_now(ZTIMER_USEC));
DEBUG("csma: Starting software CSMA/CA....\n");
int nb = 0, be = conf->min_be;
@ -160,7 +161,7 @@ int csma_sender_csma_ca_send(netdev_t *dev, iolist_t *iolist,
while (nb <= conf->max_be) {
/* delay for an adequate random backoff period */
uint32_t bp = choose_backoff_period(be, conf);
xtimer_usleep(bp);
ztimer_sleep(ZTIMER_USEC, bp);
/* try to send after a CCA */
res = send_if_cca(dev, iolist);