Adapt to RIOT ztimer and ztimer64 (#988)

RIOT-OS currently changes xtimer to ztimer
This commit is contained in:
Karl Fessel 2022-01-28 11:38:35 +01:00 committed by GitHub
parent c2d041ce94
commit 770ca8c90c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 4 deletions

View File

@ -8,6 +8,8 @@
#include "platform_api_extension.h" #include "platform_api_extension.h"
#include <panic.h> #include <panic.h>
#include <sema.h>
#include <ztimer.h>
/* clang-format off */ /* clang-format off */
#define bh_assert(v) do { \ #define bh_assert(v) do { \
@ -373,7 +375,7 @@ os_cond_wait_internal(korp_cond *cond, korp_mutex *mutex, bool timed,
if (timed) if (timed)
sema_wait(&node->sem); sema_wait(&node->sem);
else else
sema_wait_timed(&node->sem, useconds); sema_wait_timed_ztimer(&node->sem, ZTIMER_USEC, useconds);
mutex_lock(mutex); mutex_lock(mutex);
/* Remove wait node from wait list */ /* Remove wait node from wait list */

View File

@ -5,10 +5,30 @@
*/ */
#include "platform_api_vmcore.h" #include "platform_api_vmcore.h"
#include <xtimer.h> #include <ztimer64.h>
#include <kernel_defines.h>
#if IS_USED(MODULE_ZTIMER64_USEC)
uint64 uint64
os_time_get_boot_microsecond() os_time_get_boot_microsecond()
{ {
return xtimer_now_usec64(); return ztimer64_now(ZTIMER64_USEC);
} }
#elif IS_USED(MODULE_ZTIMER64_MSEC)
uint64
os_time_get_boot_microsecond()
{
return ztimer64_now(ZTIMER64_MSEC) * 1000;
}
#else
#ifdef __GNUC__
__attribute__((weak)) uint64
os_time_get_boot_microsecond();
#endif
uint64
os_time_get_boot_microsecond()
{
static uint64_t times;
return ++times;
}
#endif

View File

@ -5,7 +5,8 @@ BOARD ?= native
# This has to be the absolute path to the RIOT base directory: # This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../../../../RIOT RIOTBASE ?= $(CURDIR)/../../../../RIOT
USEMODULE += xtimer USEMODULE += ztimer64_msec
USEMODULE += ztimer_usec
USEMODULE += sema USEMODULE += sema
WPEDANTIC := 0 WPEDANTIC := 0