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

pkg/lwip: use ztimer_msec instead of xtimer

This commit is contained in:
Francisco Molina 2021-11-04 13:20:23 +01:00
parent ea13f4421e
commit 64ff3d1d4f
2 changed files with 15 additions and 16 deletions

View File

@ -87,7 +87,7 @@ endif
ifneq (,$(filter lwip_contrib,$(USEMODULE)))
USEMODULE += sema
USEMODULE += xtimer
USEMODULE += ztimer_msec
endif
ifneq (,$(filter lwip_netif,$(USEMODULE)))

View File

@ -28,7 +28,7 @@
#include "msg.h"
#include "sema.h"
#include "thread.h"
#include "xtimer.h"
#include "ztimer.h"
#define _MSG_SUCCESS (0x5cac)
#define _MSG_TIMEOUT (0x5cad)
@ -40,7 +40,7 @@ void sys_init(void)
u32_t sys_now(void)
{
return (uint32_t)(xtimer_now_usec64() / US_PER_MS);
return ztimer_now(ZTIMER_MSEC);
}
err_t sys_mutex_new(sys_mutex_t *mutex)
@ -85,14 +85,14 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t count)
{
LWIP_ASSERT("invalid semaphore", sys_sem_valid(sem));
if (count != 0) {
uint64_t stop, start;
start = xtimer_now_usec64();
int res = sema_wait_timed((sema_t *)sem, count * US_PER_MS);
stop = xtimer_now_usec64() - start;
uint32_t stop, start;
start = ztimer_now(ZTIMER_MSEC);
int res = sema_wait_timed_ztimer((sema_t *)sem, ZTIMER_MSEC, count);
stop = ztimer_now(ZTIMER_MSEC);
if (res == -ETIMEDOUT) {
return SYS_ARCH_TIMEOUT;
}
return (u32_t)(stop / US_PER_MS);
return stop - start;
}
else {
sema_wait((sema_t *)sem);
@ -142,21 +142,20 @@ static void _mbox_timeout(void *arg)
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
{
msg_t m;
xtimer_t timer = { .callback = _mbox_timeout, .arg = &mbox->mbox };
uint64_t start, stop;
ztimer_t timer = { .callback = _mbox_timeout, .arg = &mbox->mbox };
uint32_t start, stop;
start = xtimer_now_usec64();
start = ztimer_now(ZTIMER_MSEC);
if (timeout > 0) {
uint64_t u_timeout = (timeout * US_PER_MS);
xtimer_set64(&timer, u_timeout);
ztimer_set(ZTIMER_MSEC, &timer, timeout);
}
mbox_get(&mbox->mbox, &m);
stop = xtimer_now_usec64();
xtimer_remove(&timer); /* in case timer did not time out */
stop = ztimer_now(ZTIMER_MSEC);
ztimer_remove(ZTIMER_MSEC, &timer); /* in case timer did not time out */
switch (m.type) {
case _MSG_SUCCESS:
*msg = m.content.ptr;
return (u32_t)((stop - start) / US_PER_MS);
return stop - start;
case _MSG_TIMEOUT:
break;
default: /* should not happen */