From 0cdc5826fdd78130b333b90bd5ae9c6435a05651 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 5 Jul 2021 14:30:19 +0200 Subject: [PATCH 1/5] pkg/mynewt-core: initial commit --- pkg/mynewt-core/Makefile | 46 ++++ pkg/mynewt-core/Makefile.dep | 17 ++ pkg/mynewt-core/Makefile.include | 16 ++ pkg/mynewt-core/contrib/Makefile | 12 + pkg/mynewt-core/contrib/callout.c | 58 +++++ pkg/mynewt-core/contrib/core.c | 34 +++ pkg/mynewt-core/contrib/cputime.c | 77 ++++++ pkg/mynewt-core/contrib/mutex.c | 57 +++++ pkg/mynewt-core/contrib/nrf5x_isr.c | 56 +++++ pkg/mynewt-core/contrib/sem.c | 41 +++ pkg/mynewt-core/contrib/task.c | 68 +++++ pkg/mynewt-core/doc.txt | 12 + pkg/mynewt-core/include/hal/hal_gpio.h | 197 +++++++++++++++ pkg/mynewt-core/include/hal/hal_spi.h | 169 +++++++++++++ pkg/mynewt-core/include/log/log.h | 48 ++++ pkg/mynewt-core/include/mcu/mcu.h | 61 +++++ pkg/mynewt-core/include/os/mynewt.h | 36 +++ pkg/mynewt-core/include/os/os.h | 146 +++++++++++ pkg/mynewt-core/include/os/os_dev.h | 44 ++++ pkg/mynewt-core/include/os/os_eventq.h | 236 ++++++++++++++++++ pkg/mynewt-core/include/os/os_time.h | 116 +++++++++ pkg/mynewt-core/include/os/os_types.h | 59 +++++ pkg/mynewt-core/include/syscfg/syscfg.h | 122 +++++++++ pkg/mynewt-core/include/sysinit/sysinit.h | 43 ++++ pkg/mynewt-core/mynewt-core_nrf5x_hal.mk | 5 + pkg/mynewt-core/mynewt-core_os.mk | 15 ++ pkg/mynewt-core/mynewt-core_util.mk | 5 + ...hw-mcu-nrf5x-adapt-NVIC-init-to-RIOT.patch | Bin 0 -> 2272 bytes .../0002-kernel-os-src-riot-patches.patch | Bin 0 -> 7985 bytes .../patches/0003-hw-hal-patch-hal_timer.patch | Bin 0 -> 1390 bytes sys/auto_init/auto_init.c | 5 + 31 files changed, 1801 insertions(+) create mode 100644 pkg/mynewt-core/Makefile create mode 100644 pkg/mynewt-core/Makefile.dep create mode 100644 pkg/mynewt-core/Makefile.include create mode 100644 pkg/mynewt-core/contrib/Makefile create mode 100644 pkg/mynewt-core/contrib/callout.c create mode 100644 pkg/mynewt-core/contrib/core.c create mode 100644 pkg/mynewt-core/contrib/cputime.c create mode 100644 pkg/mynewt-core/contrib/mutex.c create mode 100644 pkg/mynewt-core/contrib/nrf5x_isr.c create mode 100644 pkg/mynewt-core/contrib/sem.c create mode 100644 pkg/mynewt-core/contrib/task.c create mode 100644 pkg/mynewt-core/doc.txt create mode 100644 pkg/mynewt-core/include/hal/hal_gpio.h create mode 100644 pkg/mynewt-core/include/hal/hal_spi.h create mode 100644 pkg/mynewt-core/include/log/log.h create mode 100644 pkg/mynewt-core/include/mcu/mcu.h create mode 100644 pkg/mynewt-core/include/os/mynewt.h create mode 100644 pkg/mynewt-core/include/os/os.h create mode 100644 pkg/mynewt-core/include/os/os_dev.h create mode 100644 pkg/mynewt-core/include/os/os_eventq.h create mode 100644 pkg/mynewt-core/include/os/os_time.h create mode 100644 pkg/mynewt-core/include/os/os_types.h create mode 100644 pkg/mynewt-core/include/syscfg/syscfg.h create mode 100644 pkg/mynewt-core/include/sysinit/sysinit.h create mode 100644 pkg/mynewt-core/mynewt-core_nrf5x_hal.mk create mode 100644 pkg/mynewt-core/mynewt-core_os.mk create mode 100644 pkg/mynewt-core/mynewt-core_util.mk create mode 100644 pkg/mynewt-core/patches/0001-hw-mcu-nrf5x-adapt-NVIC-init-to-RIOT.patch create mode 100644 pkg/mynewt-core/patches/0002-kernel-os-src-riot-patches.patch create mode 100644 pkg/mynewt-core/patches/0003-hw-hal-patch-hal_timer.patch diff --git a/pkg/mynewt-core/Makefile b/pkg/mynewt-core/Makefile new file mode 100644 index 0000000000..f45bcb2425 --- /dev/null +++ b/pkg/mynewt-core/Makefile @@ -0,0 +1,46 @@ +PKG_NAME=mynewt-core +PKG_URL=https://github.com/apache/mynewt-core.git +PKG_VERSION=de203365f207dda658657a7525253e02f68503a1 +PKG_LICENSE=Apache-2.0 + +include $(RIOTBASE)/pkg/pkg.mk + +CFLAGS += -Wno-unused-parameter +CFLAGS += -Wno-unused-but-set-variable +CFLAGS += -Wno-sign-compare + +MYNEWT_CORE_MODULES := mynewt-core_os \ + mynewt-core_util \ + mynewt-core_nrf5x_hal \ + # + +MYNEWT_CORE_PATH_util = util/mem/src +MYNEWT_CORE_PATH_os = kernel/os/src + +ifneq (,$(filter nrf52,$(CPU))) + MYNEWT_CORE_PATH_nrf5x_hal = hw/mcu/nordic/nrf52xxx/src/ +endif +ifneq (,$(filter nrf51,$(CPU))) + MYNEWT_CORE_PATH_nrf5x_hal = hw/mcu/nordic/nrf51xxx/src/ +endif + +.PHONY: rm_riot_provided_headers + +all: $(filter $(MYNEWT_CORE_MODULES),$(USEMODULE)) + @true + +mynewt-core_%: rm_riot_provided_headers + "$(MAKE)" -C $(PKG_SOURCE_DIR)/$(MYNEWT_CORE_PATH_$*) -f $(RIOTPKG)/$(PKG_NAME)/$@.mk MODULE=$@ + +# The following mynewt-core headers are provided by RIOT, remove them from +# mynewt-core include paths to avoid header conflicts +MYNEWT_CORE_HAL_HEADERS = hal_gpio.h hal_spi.h +MYNEWT_CORE_OS_HEADERS = os.h mynewt.h os_dev.h os_eventq.h os_time.h +MYNEWT_CORE_HAL_HEADERS_PATH = hw/hal/include/hal +MYNEWT_CORE_OS_HEADERS_PATH = kernel/os/include/os/os_time + +rm_riot_provided_headers: + $(Q)for i in $(MYNEWT_CORE_OS_HEADERS); \ + do rm -f "$(PKG_SOURCE_DIR)/$(MYNEWT_CORE_OS_HEADERS_PATH)/$$i"; done + $(Q)for i in $(MYNEWT_CORE_HAL_HEADERS); \ + do rm -f "$(PKG_SOURCE_DIR)/$(MYNEWT_CORE_HAL_HEADERS_PATH)/$$i"; done diff --git a/pkg/mynewt-core/Makefile.dep b/pkg/mynewt-core/Makefile.dep new file mode 100644 index 0000000000..31480b59b3 --- /dev/null +++ b/pkg/mynewt-core/Makefile.dep @@ -0,0 +1,17 @@ +USEMODULE += event_callback +USEMODULE += sema +USEMODULE += ztimer +USEMODULE += ztimer_msec + +USEMODULE += mynewt-core + +DEFAULT_MODULE += auto_init_mynewt-core + +# MyNewt `os_hw_is_in_critical` function needs to know whether ISR are masked +# of if the function is being called in ISR context. There is no such function +# in RIOT except for arm (__get_PRIMASK), therefore unless a similar function +# is provided for other arch, this port is currently only enabled for those arch. +# Note: that this should not be a hindrance since nimble only works on nordic +# and uwb-core breakouts are all arm. +FEATURES_REQUIRED += arch_arm +FEATURES_BLACKLIST += arch_arm7 diff --git a/pkg/mynewt-core/Makefile.include b/pkg/mynewt-core/Makefile.include new file mode 100644 index 0000000000..3defd3ce4c --- /dev/null +++ b/pkg/mynewt-core/Makefile.include @@ -0,0 +1,16 @@ +INCLUDES += -I$(RIOTPKG)/mynewt-core/include \ + -I$(PKGDIRBASE)/mynewt-core/kernel/os/include \ + -I$(PKGDIRBASE)/mynewt-core/hw/hal/include \ + -I$(PKGDIRBASE)/mynewt-core/util/mem/include \ + -I$(PKGDIRBASE)/mynewt-core/sys/stats/stub/include \ + # + +DIRS += $(RIOTPKG)/mynewt-core/contrib \ + # + +ifneq (,$(filter nrf5%,$(CPU))) + # OS_CPUTIME is set to 32.767 Hz + CFLAGS += -DMYNEWT_VAL_OS_CPUTIME_FREQ=32768 +else + CFLAGS += -DMYNEWT_VAL_OS_CPUTIME_FREQ=CONFIG_ZTIMER_MSEC_BASE_FREQ +endif diff --git a/pkg/mynewt-core/contrib/Makefile b/pkg/mynewt-core/contrib/Makefile new file mode 100644 index 0000000000..0bb65a903f --- /dev/null +++ b/pkg/mynewt-core/contrib/Makefile @@ -0,0 +1,12 @@ +MODULE = mynewt-core + +# exclude submodule sources from *.c wildcard source selection +SRC := $(filter-out nrf5x_isr.c cputime.c,$(wildcard *.c)) + +ifneq (,$(filter nrf%,$(CPU))) + SRC += nrf5x_isr.c +else + SRC += cputime.c +endif + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/mynewt-core/contrib/callout.c b/pkg/mynewt-core/contrib/callout.c new file mode 100644 index 0000000000..c6d9414edb --- /dev/null +++ b/pkg/mynewt-core/contrib/callout.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core callout + * + * @author Francisco Molina + * @} + */ + +#include + +#include "ztimer.h" +#include "os/os.h" +#include "os/os_callout.h" + +static void _os_callout_timer_cb(void* arg) +{ + struct os_callout *c = (struct os_callout *) arg; + assert(c); + + /* post the event if there is a queue, otherwise call the callback + here */ + if (c->c_evq) { + os_eventq_put(c->c_evq, &c->c_ev); + } else { + c->c_ev.e.callback(&c->c_ev); + } +} + +void os_callout_init(struct os_callout *c, struct os_eventq *q, + os_event_fn *e_cb, void *e_arg) +{ + os_event_init(&c->c_ev, e_cb, e_arg); + c->c_evq = q; + c->timer.callback = _os_callout_timer_cb; + c->timer.arg = (void*) c; +} + +int os_callout_reset(struct os_callout *c, os_time_t ticks) +{ + ztimer_set(ZTIMER_MSEC, &c->timer, ticks); + return OS_OK; +} + +void os_callout_stop(struct os_callout *c) +{ + ztimer_remove(ZTIMER_MSEC, &(c->timer)); +} diff --git a/pkg/mynewt-core/contrib/core.c b/pkg/mynewt-core/contrib/core.c new file mode 100644 index 0000000000..9dc9e11ada --- /dev/null +++ b/pkg/mynewt-core/contrib/core.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2021 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core bootstrapping functions + * + * @author Francisco Molina + * @} + */ + +#include + +#include "os/os_cputime.h" +#include "hal/hal_timer.h" + +void mynewt_core_init(void) +{ +#if (MYNEWT_VAL_OS_CPUTIME_TIMER_NUM >= 0) && (defined(CPU_NRF51) || defined(CPU_NRF52)) + int rc = hal_timer_init(5, NULL); + assert(rc == 0); + rc = os_cputime_init(MYNEWT_VAL_OS_CPUTIME_FREQ); + assert(rc == 0); + (void) rc; +#endif +} diff --git a/pkg/mynewt-core/contrib/cputime.c b/pkg/mynewt-core/contrib/cputime.c new file mode 100644 index 0000000000..52382936ba --- /dev/null +++ b/pkg/mynewt-core/contrib/cputime.c @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief cputime implementation for non nrf5x BOARDs + * + * @author Francisco Molina + * @} + */ + +#include "os/os_cputime.h" +#include "ztimer.h" +#include "hal/hal_timer.h" + +uint32_t os_cputime_get32(void) +{ + return ztimer_now(ZTIMER_MSEC_BASE); +} + +void os_cputime_delay_ticks(uint32_t ticks) +{ + ztimer_sleep(ZTIMER_MSEC_BASE, ticks); +} + +void os_cputime_delay_usecs(uint32_t usecs) +{ + ztimer_sleep(ZTIMER_MSEC_BASE, os_cputime_usecs_to_ticks(usecs)); +} + +int os_cputime_init(uint32_t clock_freq) +{ + (void)clock_freq; + return 0; +} + +void os_cputime_timer_init(struct hal_timer *timer, hal_timer_cb fp, + void *arg) +{ + timer->timer.callback = fp; + timer->timer.arg = arg; +} + +int os_cputime_timer_start(struct hal_timer *timer, uint32_t cputime) +{ + uint32_t now = ztimer_now(ZTIMER_MSEC_BASE); + + /* taken from mynewt-core 'hal_timer' implementations, this will + only work with timeouts at most 2**32-1 away, so it will have the same + limitations as their implementation does */ + if ((int32_t)(cputime - now) <= 0) { + ztimer_set(ZTIMER_MSEC_BASE, &timer->timer, 0); + } + else { + ztimer_set(ZTIMER_MSEC_BASE, &timer->timer, cputime - now); + } + return 0; +} + +int os_cputime_timer_relative(struct hal_timer *timer, uint32_t usecs) +{ + ztimer_set(ZTIMER_MSEC_BASE, &timer->timer, os_cputime_usecs_to_ticks(usecs)); + return 0; +} + +void os_cputime_timer_stop(struct hal_timer *timer) +{ + ztimer_remove(ZTIMER_MSEC_BASE, &timer->timer); +} diff --git a/pkg/mynewt-core/contrib/mutex.c b/pkg/mynewt-core/contrib/mutex.c new file mode 100644 index 0000000000..a8f8b684d1 --- /dev/null +++ b/pkg/mynewt-core/contrib/mutex.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief Decawave Porting Layer mutex RIOT wrapper + * + * @author Francisco Molina + * @} + */ + +#include "os/os_mutex.h" + +os_error_t os_mutex_init(struct os_mutex *mu) +{ + if (!mu) { + return OS_INVALID_PARM; + } + mutex_init(&mu->mutex); + return OS_OK; +} + +os_error_t os_mutex_release(struct os_mutex *mu) +{ + if (!mu) { + return OS_INVALID_PARM; + } + + mutex_unlock(&mu->mutex); + return OS_OK; +} + +os_error_t os_mutex_pend(struct os_mutex *mu, uint32_t timeout) +{ + int rc = OS_OK; + + if (!mu) { + return OS_INVALID_PARM; + } + + if (!timeout) { + rc = mutex_trylock(&mu->mutex); + } + else { + /* TODO: no timeout equivalent */ + mutex_lock(&mu->mutex); + } + return rc; +} diff --git a/pkg/mynewt-core/contrib/nrf5x_isr.c b/pkg/mynewt-core/contrib/nrf5x_isr.c new file mode 100644 index 0000000000..23260f19a5 --- /dev/null +++ b/pkg/mynewt-core/contrib/nrf5x_isr.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2021 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core isr mapping + * + * @author Hauke Petersen + * @} + */ + + +#include "mcu/mcu.h" +#include "cpu.h" + +static void (*radio_isr_addr)(void); +static void (*rng_isr_addr)(void); +static void (*rtc0_isr_addr)(void); + +void isr_radio(void) +{ + radio_isr_addr(); +} + +void isr_rng(void) +{ + rng_isr_addr(); +} + +void isr_rtc0(void) +{ + rtc0_isr_addr(); +} + +void nrf5x_hw_set_isr(int irqn, void (*addr)(void)) +{ + switch (irqn) { + case RADIO_IRQn: + radio_isr_addr = addr; + break; + case RNG_IRQn: + rng_isr_addr = addr; + break; + case RTC0_IRQn: + rtc0_isr_addr = addr; + break; + } +} diff --git a/pkg/mynewt-core/contrib/sem.c b/pkg/mynewt-core/contrib/sem.c new file mode 100644 index 0000000000..c15fc2d019 --- /dev/null +++ b/pkg/mynewt-core/contrib/sem.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief Decawave Porting Layer semaphore RIOT wrapper + * + * @author Francisco Molina + * @} + */ + +#include + +#include "irq.h" +#include "os/os_sem.h" + +os_error_t os_sem_init(struct os_sem *sem, uint16_t tokens) +{ + sema_create(&sem->sema, tokens); + return OS_OK; +} + +os_error_t os_sem_release(struct os_sem *sem) +{ + int ret = sema_post(&sem->sema); + return (ret) ? OS_ERROR : OS_OK; +} + +os_error_t os_sem_pend(struct os_sem *sem, os_time_t timeout) +{ + int ret = sema_wait_timed_ztimer(&sem->sema, ZTIMER_MSEC, timeout); + return (ret) ? OS_ERROR : OS_OK; +} diff --git a/pkg/mynewt-core/contrib/task.c b/pkg/mynewt-core/contrib/task.c new file mode 100644 index 0000000000..f4d7bad184 --- /dev/null +++ b/pkg/mynewt-core/contrib/task.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief Decawave Porting Layer tasks RIOT wrapper + * + * @author Francisco Molina + * @} + */ + +#include "os/os_error.h" +#include "os/os_task.h" +#include "thread.h" + +#ifndef LOG_LEVEL +#define LOG_LEVEL LOG_INFO +#endif +#include "log.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int os_task_init(struct os_task *t, const char *name, os_task_func_t func, + void *arg, uint8_t prio, os_time_t sanity_itvl, + os_stack_t *stack_bottom, uint16_t stack_size) +{ + (void) sanity_itvl; + + LOG_INFO("[mynewt-core]: starting thread %s\n", name); + + kernel_pid_t pid = thread_create(stack_bottom, (int) stack_size, + prio, THREAD_CREATE_STACKTEST, + func, arg, name); + + t->pid = pid; + + return (pid) ? OS_ERROR : OS_OK;; +} + +int os_task_remove(struct os_task *t) +{ + thread_zombify(); + return thread_kill_zombie(t->pid); +} + +uint8_t os_task_count(void) +{ + return sched_num_threads; +} + +void os_task_yield(void) +{ + thread_yield(); +} + +#ifdef __cplusplus +} +#endif diff --git a/pkg/mynewt-core/doc.txt b/pkg/mynewt-core/doc.txt new file mode 100644 index 0000000000..f7c63bfd7b --- /dev/null +++ b/pkg/mynewt-core/doc.txt @@ -0,0 +1,12 @@ +/** + * @defgroup pkg_mynewt_core mynewt-core + * @ingroup pkg + * @brief Apache MyNewt package for MyNewt based packages: uwb-core, nimble + * @see https://github.com/apache/mynewt-core + */ + +# Apache MyNewt mynewt-core Package + +Packages like @ref pkg_uwb_core and @ref nimble where developed with MyNewt +as their default OS. Some of the features provided by that OS are not abstracted. +For those cases and to avoid header re-definitions mynewt-core is pulled in. diff --git a/pkg/mynewt-core/include/hal/hal_gpio.h b/pkg/mynewt-core/include/hal/hal_gpio.h new file mode 100644 index 0000000000..b09ba8beea --- /dev/null +++ b/pkg/mynewt-core/include/hal/hal_gpio.h @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_uwb_dw1000 + * @{ + * + * @file + * @brief GPIO abstraction layer RIOT adaption + * + * @author Francisco Molina + * @} + */ + +#ifndef HAL_HAL_GPIO_H +#define HAL_HAL_GPIO_H + +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Map hal_gpio_pull_t enum types to gpio_mode_t enum types + */ +enum { + /** Pull-up/down not enabled */ + HAL_GPIO_PULL_NONE = GPIO_IN, + /** Pull-up enabled */ + HAL_GPIO_PULL_UP = GPIO_IN_PU, + /** Pull-down enabled */ + HAL_GPIO_PULL_DOWN = GPIO_IN_PD +}; +/** + * @brief hal_gpio_pull type + */ +typedef gpio_mode_t hal_gpio_pull_t; + +/** + * @brief Map hal_gpio_irq_trig_t enum types to gpio_flank_t enum types + */ +enum { +#ifdef GPIO_NONE + HAL_GPIO_TRIG_NONE = GPIO_NONE, +#endif + /** IRQ occurs on rising edge */ + HAL_GPIO_TRIG_RISING = GPIO_RISING, + /** IRQ occurs on falling edge */ + HAL_GPIO_TRIG_FALLING = GPIO_FALLING, + /** IRQ occurs on either edge */ + HAL_GPIO_TRIG_BOTH = GPIO_BOTH, + /** IRQ occurs when line is low */ +#ifdef GPIO_LOW + HAL_GPIO_TRIG_LOW = GPIO_LOW, +#endif + /** IRQ occurs when line is high */ +#ifdef GPIO_HIGH + HAL_GPIO_TRIG_HIGH = GPIO_HIGH +#endif +}; +/** + * @brief hal_gpio_irq_trig type + */ +typedef gpio_flank_t hal_gpio_irq_trig_t; + +/** + * @brief Function proto for GPIO irq handler functions + */ +typedef gpio_cb_t hal_gpio_irq_handler_t; + +/** + * Initializes the specified pin as an input + * + * @param pin Pin number to set as input + * @param pull pull type + * + * @return int 0: no error; -1 otherwise. + */ +static inline int hal_gpio_init_in(gpio_t pin, hal_gpio_pull_t pull) +{ + return gpio_init(pin, pull); +} + +/** + * Initialize the specified pin as an output, setting the pin to the specified + * value. + * + * @param pin Pin number to set as output + * @param val Value to set pin + * + * @return int 0: no error; -1 otherwise. + */ +static inline int hal_gpio_init_out(gpio_t pin, int val) +{ + int res = gpio_init(pin, GPIO_OUT); + gpio_write(pin, val); + return res; +} + +/** + * Write a value (either high or low) to the specified pin. + * + * @param pin Pin to set + * @param val Value to set pin (0:low 1:high) + */ +static inline void hal_gpio_write(gpio_t pin, int val) +{ + gpio_write(pin, val); +} + +/** + * Reads the specified pin. + * + * @param pin Pin number to read + * + * @return int 0: low, 1: high + */ +static inline int hal_gpio_read(gpio_t pin) +{ + return gpio_read(pin); +} + +/** + * Toggles the specified pin + * + * @param pin Pin number to toggle + * + * @return current gpio state int 0: low, 1: high + */ +static inline int hal_gpio_toggle(gpio_t pin) +{ + gpio_toggle(pin); + return gpio_read(pin); +} + +/** + * Initialize a given pin to trigger a GPIO IRQ callback. + * + * @param pin The pin to trigger GPIO interrupt on + * @param handler The handler function to call + * @param arg The argument to provide to the IRQ handler + * @param trig The trigger mode (e.g. rising, falling) + * @param pull The mode of the pin (e.g. pullup, pulldown) + * + * @return 0 on success, non-zero error code on failure. + */ +static inline int hal_gpio_irq_init(gpio_t pin, + hal_gpio_irq_handler_t handler, + void *arg, + hal_gpio_irq_trig_t trig, + hal_gpio_pull_t pull) +{ + return gpio_init_int(pin, pull, trig, handler, arg); +} + +/** + * Release a pin from being configured to trigger IRQ on state change. + * + * @param pin The pin to release + */ +static inline void hal_gpio_irq_release(gpio_t pin) +{ + /* can't release the interrupt so ar least disable it */ + gpio_irq_disable(pin); +} + +/** + * Enable IRQs on the passed pin + * + * @param pin The pin to enable IRQs on + */ +static inline void hal_gpio_irq_enable(gpio_t pin) +{ + gpio_irq_enable(pin); +} + +/** + * Disable IRQs on the passed pin + * + * @param pin The pin to disable IRQs on + */ +static inline void hal_gpio_irq_disable(gpio_t pin) +{ + gpio_irq_disable(pin); +} + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_HAL_GPIO_H */ diff --git a/pkg/mynewt-core/include/hal/hal_spi.h b/pkg/mynewt-core/include/hal/hal_spi.h new file mode 100644 index 0000000000..da13747bb1 --- /dev/null +++ b/pkg/mynewt-core/include/hal/hal_spi.h @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_uwb_dw1000 + * @{ + * + * @file + * @brief SPI abstraction layer RIOT adaption + * + * @author Francisco Molina + * @} + */ + +#ifndef HAL_HAL_SPI_H +#define HAL_HAL_SPI_H + +#include "periph/spi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** SPI mode 0 */ +#define HAL_SPI_MODE0 (SPI_MODE_0) +/** SPI mode 1 */ +#define HAL_SPI_MODE1 (SPI_MODE_1) +/** SPI mode 2 */ +#define HAL_SPI_MODE2 (SPI_MODE_2) +/** SPI mode 3 */ +#define HAL_SPI_MODE3 (SPI_MODE_3) + +/** + * @brief Prototype for tx/rx callback + */ +typedef void (*hal_spi_txrx_cb)(void *arg, int len); + +/** + * @brief since one spi device can control multiple devices, some configuration + * can be changed on the fly from the hal + */ +struct hal_spi_settings { + /** Data mode of SPI driver, defined by HAL_SPI_MODEn */ + spi_mode_t data_mode; + /** Baudrate in kHz */ + spi_clk_t baudrate; +}; + +/** + * @brief Configure the spi. Must be called after the spi is initialized (after + * hal_spi_init is called) and when the spi is disabled (user must call + * hal_spi_disable if the spi has been enabled through hal_spi_enable prior + * to calling this function). Can also be used to reconfigure an initialized + * SPI (assuming it is disabled as described previously). + * + * @param spi_num The number of the SPI to configure. + * @param psettings The settings to configure this SPI with + * + * @return int 0 on success, non-zero error code on failure. + */ +int hal_spi_config(int spi_num, struct hal_spi_settings *psettings); + +/** + * @brief Sets the txrx callback (executed at interrupt context) when the + * buffer is transferred by the master or the slave using the non-blocking API. + * Cannot be called when the spi is enabled. This callback will also be called + * when chip select is de-asserted on the slave. + * + * NOTE: This callback is only used for the non-blocking interface and must + * be called prior to using the non-blocking API. + * + * @param spi_num SPI interface on which to set callback + * @param txrx_cb Callback function + * @param arg Argument to be passed to callback function + * + * @return int 0 on success, non-zero error code on failure. + */ +int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg); + +/** + * @brief Enables the SPI. This does not start a transmit or receive operation; + * it is used for power mgmt. Cannot be called when a SPI transfer is in + * progress. + * + * @param spi_num + * + * @return int 0 on success, non-zero error code on failure. + */ +int hal_spi_enable(int spi_num); + +/** + * @brief Disables the SPI. Used for power mgmt. It will halt any current SPI transfers + * in progress. + * + * @param spi_num + * + * @return int 0 on success, non-zero error code on failure. + */ +int hal_spi_disable(int spi_num); + +/** + * @brief Blocking interface to send a buffer and store the received values from the + * slave. The transmit and receive buffers are either arrays of 8-bit (uint8_t) + * values or 16-bit values depending on whether the spi is configured for 8 bit + * data or more than 8 bits per value. The 'cnt' parameter is the number of + * 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an + * array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise + * txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values). + * + * NOTE: these buffers are in the native endian-ness of the platform. + * + * MASTER: master sends all the values in the buffer and stores the + * stores the values in the receive buffer if rxbuf is not NULL. + * The txbuf parameter cannot be NULL. + * SLAVE: cannot be called for a slave; returns -1 + * + * @param spi_num SPI interface to use + * @param txbuf Pointer to buffer where values to transmit are stored. + * @param rxbuf Pointer to buffer to store values received from peer. + * @param cnt Number of 8-bit or 16-bit values to be transferred. + * + * @return int 0 on success, non-zero error code on failure. + */ +int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt); + +/** + * @brief Non-blocking interface to send a buffer and store received values. Can be + * used for both master and slave SPI types. The user must configure the + * callback (using hal_spi_set_txrx_cb); the txrx callback is executed at + * interrupt context when the buffer is sent. + * + * The transmit and receive buffers are either arrays of 8-bit (uint8_t) + * values or 16-bit values depending on whether the spi is configured for 8 bit + * data or more than 8 bits per value. The 'cnt' parameter is the number of + * 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an + * array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise + * txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values). + * + * NOTE: these buffers are in the native endian-ness of the platform. + * + * MASTER: master sends all the values in the buffer and stores the + * stores the values in the receive buffer if rxbuf is not NULL. + * The txbuf parameter cannot be NULL + * SLAVE: Slave "preloads" the data to be sent to the master (values + * stored in txbuf) and places received data from master in rxbuf + * (if not NULL). The txrx callback occurs when len values are + * transferred or master de-asserts chip select. If txbuf is NULL, + * the slave transfers its default byte. Both rxbuf and txbuf cannot + * be NULL. + * + * @param spi_num SPI interface to use + * @param txbuf Pointer to buffer where values to transmit are stored. + * @param rxbuf Pointer to buffer to store values received from peer. + * @param cnt Number of 8-bit or 16-bit values to be transferred. + * + * @return int 0 on success, non-zero error code on failure. + */ +int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt); + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_HAL_SPI_H */ diff --git a/pkg/mynewt-core/include/log/log.h b/pkg/mynewt-core/include/log/log.h new file mode 100644 index 0000000000..7ee5fe776e --- /dev/null +++ b/pkg/mynewt-core/include/log/log.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief System logging header for mynewt-core + * + * @author Francisco Molina + * @} + */ + +#ifndef LOG_LOG_H +#define LOG_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "log.h" + +/** + * @name Logging convenience defines wrappers + * @{ + */ +#define LOG_WARN(...) LOG(LOG_WARNING, __VA_ARGS__) +#define LOG_CRITICAL(...) LOG(LOG_ERROR, __VA_ARGS__) +#define log_register(__X, __Y, __Z, __A, __B) {} +/** @} */ + +/** + * @brief Empty log structure + */ +struct log { +}; + +#ifdef __cplusplus +} +#endif + +#endif /* LOG_LOG_H */ diff --git a/pkg/mynewt-core/include/mcu/mcu.h b/pkg/mynewt-core/include/mcu/mcu.h new file mode 100644 index 0000000000..2c3185a5c1 --- /dev/null +++ b/pkg/mynewt-core/include/mcu/mcu.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief Abstraction layer for RIOT adaption + * + * @author Francisco Molina + * @} + */ + +#ifndef MCU_MCU_H +#define MCU_MCU_H + +#include "cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Set nrf5x radio ISR callback + * + * @param[in] irqn IRQ number + * @param[in] addr the ISR callback + */ +void nrf5x_hw_set_isr(int irqn, void (*addr)(void)); + +/** + * @name Entering and exiting critical section defines + * @{ + */ +#define __HAL_DISABLE_INTERRUPTS(x) \ + do { \ + x = irq_disable(); \ + } while (0); + +#define __HAL_ENABLE_INTERRUPTS(x) \ + do { \ + if (x) { \ + irq_restore(x); \ + } \ + else { \ + irq_enable(); \ + } \ + } while (0); +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* MCU_MCU_H */ diff --git a/pkg/mynewt-core/include/os/mynewt.h b/pkg/mynewt-core/include/os/mynewt.h new file mode 100644 index 0000000000..97bf9c986d --- /dev/null +++ b/pkg/mynewt-core/include/os/mynewt.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core header + * + * @author Francisco Molina + * @} + */ + +#ifndef OS_MYNEWT_H +#define OS_MYNEWT_H + +#include +#include "syscfg/syscfg.h" +#include "sysinit/sysinit.h" +#include "os/os.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* OS_MYNEWT_H */ diff --git a/pkg/mynewt-core/include/os/os.h b/pkg/mynewt-core/include/os/os.h new file mode 100644 index 0000000000..e39c1e81ac --- /dev/null +++ b/pkg/mynewt-core/include/os/os.h @@ -0,0 +1,146 @@ +/** + * Apache Mynewt + * Copyright 2015-2021 The Apache Software Foundation + * + * This product includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + * + * Portions of this software were developed at + * Runtime Inc, copyright 2015. + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core error types + * + * @} + */ + +#ifndef OS_OS_H +#define OS_OS_H + +#include +#include + +#include "irq.h" +#include "os/os_types.h" +#include "os/os_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name MyNewt os/%.h required macros + * @{ + * + * PLEASE NOTE: Following macro definitions where copied directly from + * apache/mynewt-core and are under the copyright specified in + * the header. + * + */ +#ifndef min +#define min(a, b) ((a)<(b)?(a):(b)) +#endif + +#ifndef max +#define max(a, b) ((a)>(b)?(a):(b)) +#endif + +#define OS_ALIGN(__n, __a) ( \ + (((__n) & ((__a) - 1)) == 0) ? \ + (__n) : \ + ((__n) + ((__a) - ((__n) & ((__a) - 1)))) \ + ) +#define OS_ALIGNMENT (4) +/** @} */ + +/** + * @brief CPU status register + */ +typedef uint32_t os_sr_t; + +/** + * @name Entering and exiting critical section defines + * @{ + */ +#define OS_ENTER_CRITICAL(_sr) (_sr = os_hw_enter_critical()) +#define OS_EXIT_CRITICAL(_sr) (os_hw_exit_critical(_sr)) +#define OS_ASSERT_CRITICAL() assert(os_hw_is_in_critical()) +/** @} */ + +/** + * @brief Disable ISRs + * + * @return current isr context + */ +static inline uint32_t os_hw_enter_critical(void) +{ + uint32_t ctx = irq_disable(); + return ctx; +} + +/** + * @brief Restores ISR context + * + * @param[in] ctx ISR context to restore. + */ +static inline void os_hw_exit_critical(uint32_t ctx) +{ + irq_restore((unsigned)ctx); +} + +/** + * @brief Check if is in critical section + * + * @return true, if in critical section, false otherwise + */ +static inline bool os_hw_is_in_critical(void) +{ + return (irq_is_in() || __get_PRIMASK()); +} + +/* Mynewt components (not abstracted in NPL or DPL) */ +#include "os/endian.h" +#include "os/os_callout.h" +#include "os/os_cputime.h" +#include "os/os_dev.h" +#include "os/os_eventq.h" +#include "os/os_mbuf.h" +#include "os/os_mempool.h" +#include "os/os_mutex.h" +#include "os/os_sem.h" +#include "os/os_task.h" +#include "os/os_time.h" +#include "os/os_trace_api.h" +#include "os/queue.h" + +#if IS_USED(MODULE_NIMBLE) +#include "nimble/nimble_npl.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* OS_OS_H */ diff --git a/pkg/mynewt-core/include/os/os_dev.h b/pkg/mynewt-core/include/os/os_dev.h new file mode 100644 index 0000000000..6998d0887c --- /dev/null +++ b/pkg/mynewt-core/include/os/os_dev.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief Abstraction layer for RIOT adaption + * + * @author Francisco Molina + * @} + */ +#ifndef OS_OS_DEV_H +#define OS_OS_DEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Device structure. + */ +struct os_dev { +}; + +/** + * @brief Unused define, void cast + */ +#define OS_DEV_SETHANDLERS(__dev, __open, __close) \ + (void) __dev; \ + (void) __open; \ + (void) __close; + +#ifdef __cplusplus +} +#endif + +#endif /* OS_OS_DEV_H */ diff --git a/pkg/mynewt-core/include/os/os_eventq.h b/pkg/mynewt-core/include/os/os_eventq.h new file mode 100644 index 0000000000..6a49d058f4 --- /dev/null +++ b/pkg/mynewt-core/include/os/os_eventq.h @@ -0,0 +1,236 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core event and event queue abstraction + * + * @author Francisco Molina + * @} + */ + +#ifndef OS_OS_EVENTQ_H +#define OS_OS_EVENTQ_H + +#include + +#include "event/callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Event wrapper + */ +struct os_event +{ + event_callback_t e; /**< the event callback */ + void *arg; /**< the event argument */ +}; + +/** + * @brief Event queue wrapper + */ +struct os_eventq +{ + event_queue_t q; /**< the event queue */ +}; + +/** + * @brief Event callback function + */ +typedef void os_event_fn(struct os_event *ev); + +/** + * @brief Init a event + * + * @param[in] ev pointer to event to set + * @param[in] fn event callback function + * @param[in] arg event argument + */ +static inline void os_event_init(struct os_event *ev, os_event_fn * fn, + void *arg) +{ + /* + * Need to clear list_node manually since init function below does not do + * this. + */ + ev->e.super.list_node.next = NULL; + event_callback_init(&ev->e, (void(*)(void *))fn, ev); + ev->arg = arg; +} + +/** + * @brief Check if event is in queue + * + * @param[in] ev event to check + * + * @return true if event is queues, false otherwise + */ +static inline bool os_event_is_queued(struct os_event *ev) +{ + return (ev->e.super.list_node.next != NULL); +} + +/** + * @brief Returns event argument + * + * @param[in] ev event + */ +static inline void *os_event_get_arg(struct os_event *ev) +{ + return ev->arg; +} + +/** + * @brief Set the event argument + * + * @param[in] ev event + * @param[in] arg arg to set event + */ +static inline void os_event_set_arg(struct os_event *ev, void *arg) +{ + ev->arg = arg; +} + +/** + * @brief Runs an event + * + * @param[in] ev event to run + */ +static inline void os_event_run(struct os_event *ev) +{ + ev->e.super.handler(&ev->e.super); +} + +/** + * @brief Initialize the event queue + * + * @param[in] evq The event queue to initialize + */ +static inline void os_eventq_init(struct os_eventq *evq) +{ + event_queue_init_detached(&evq->q); +} + +/** + * @brief Check whether the event queue is initialized. + * + * @param[in] evq the event queue to check + */ +static inline int os_eventq_inited(struct os_eventq *evq) +{ + return evq->q.waiter != NULL; +} + +/** + * @brief Deinitialize an event queue + * + * @note Not supported in RIOT + * + * @param[in] evq the event queue to deinit + */ +static inline void os_eventq_deinit(struct os_eventq *evq) +{ + (void) evq; + /* Can't deinit an eventq in RIOT */ +} + +/** +* @brief Get next event from event queue + * + * @param[in] evq the event queue to pull an event from + * @param[in] tmo timeout, OS_WAIT_FOREVER to block, 0 to return immediately + * + * @return the event from the queue + */ +static inline struct os_event * os_eventq_get(struct os_eventq *evq, os_time_t tmo) +{ + if (evq->q.waiter == NULL) { + event_queue_claim(&evq->q); + } + + if (tmo == 0) { + return (struct os_event *)event_get(&evq->q); + } else if (tmo == OS_WAIT_FOREVER) { + return (struct os_event *)event_wait(&evq->q); + } else { + return (struct os_event *)event_wait_timeout_ztimer(&evq->q, + ZTIMER_MSEC, + (uint32_t)tmo); + } +} + +/** + * @brief Get next event from event queue, non-blocking + * + * @return event from the queue, or NULL if none available. + */ +static inline struct os_event * os_eventq_get_no_wait(struct os_eventq *evq) +{ + if (evq->q.waiter == NULL) { + event_queue_claim(&evq->q); + } + + return (struct os_event *) event_get(&evq->q); +} + +/** + * @brief Put an event on the event queue. + * + * @param[in] evq event queue + * @param[in] ev event to put in queue + */ +static inline void os_eventq_put(struct os_eventq *evq, struct os_event *ev) +{ + event_post(&evq->q, &ev->e.super); +} + +/** + * @brief Remove an event from the queue. + * + * @param[in] evq event queue to remove the event from + * @param[in] ev event to remove from the queue + */ +static inline void os_eventq_remove(struct os_eventq *evq, struct os_event *ev) +{ + event_cancel(&evq->q, &ev->e.super); +} + +/** + * @brief Gets and runs an event from the queue callback. + * + * @param[in] evq The event queue to pull the item off. + */ +static inline void os_eventq_run(struct os_eventq *evq) +{ + struct os_event *ev = os_eventq_get(evq, OS_WAIT_FOREVER); + os_event_run(ev); +} + +/** + * @brief Check if queue is empty + * + * @param[in] evq the event queue to check + * + * @return true if empty, false otherwise + */ +static inline bool os_eventq_is_empty(struct os_eventq *evq) +{ + return clist_count(&(evq->q.event_list)) == 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /* OS_OS_EVENTQ_H */ diff --git a/pkg/mynewt-core/include/os/os_time.h b/pkg/mynewt-core/include/os/os_time.h new file mode 100644 index 0000000000..1ca7f50a59 --- /dev/null +++ b/pkg/mynewt-core/include/os/os_time.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core time abstraction + * + * @author Francisco Molina + * @} + */ + +#ifndef OS_OS_TIME_H +#define OS_OS_TIME_H + +#include "os/os_error.h" +#include "ztimer.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Ticks per seconds, ztimer_msec is used as system timer + */ +#define OS_TICKS_PER_SEC (MS_PER_SEC) + +/** + * @brief Returns the low 32 bits of cputime. + * + * @return uint32_t The lower 32 bits of cputime + */ +static inline os_time_t os_time_get(void) +{ + return ztimer_now(ZTIMER_MSEC); +} + +/** + * @brief Converts the given number of milliseconds into cputime ticks. + * + * @param[in] ms The number of milliseconds to convert to ticks + * @param[out] out_ticks The number of ticks corresponding to 'ms' + * + * @return os_error_t OS_OK - no error + */ +static inline os_error_t os_time_ms_to_ticks(uint32_t ms, os_time_t *out_ticks) +{ + *out_ticks = ms; + return OS_OK; +} + +/** + * @brief Convert the given number of ticks into milliseconds. + * + * @param[in] ticks The number of ticks to convert to milliseconds. + * @param[out] out_ms The converted milliseconds from 'ticks' + * + * @return os_error_t OS_OK - no error + */ +static inline os_error_t os_time_ticks_to_ms(os_time_t ticks, uint32_t *out_ms) +{ + *out_ms = ticks; + return OS_OK; +} + +/** + * @brief Converts the given number of milliseconds into cputime ticks. + * + * @param[in] ms The number of milliseconds to convert to ticks + * + * @return uint32_t The number of ticks corresponding to 'ms' + */ +static inline os_time_t os_time_ms_to_ticks32(uint32_t ms) +{ + return ms; +} + +/** + * @brief Convert the given number of ticks into milliseconds. + * + * @param[in] ticks The number of ticks to convert to milliseconds. + * + * @return uint32_t The number of milliseconds corresponding to 'ticks' + */ +static inline os_time_t os_time_ticks_to_ms32(os_time_t ticks) +{ + return ticks; +} + +/** + * @brief Wait until the number of ticks has elapsed, BLOICKING. + * + * @param[in] ticks The number of ticks to wait. + */ +static inline void os_time_delay(os_time_t ticks) +{ + if (irq_is_in()) { + ztimer_spin(ZTIMER_MSEC, ticks); + } + else { + ztimer_sleep(ZTIMER_MSEC, ticks); + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* OS_OS_TIME_H */ diff --git a/pkg/mynewt-core/include/os/os_types.h b/pkg/mynewt-core/include/os/os_types.h new file mode 100644 index 0000000000..819f093e83 --- /dev/null +++ b/pkg/mynewt-core/include/os/os_types.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core types + * + * @author Francisco Molina + * @} + */ + +#ifndef OS_OS_TYPES_H +#define OS_OS_TYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Error codes not abstracted in mynewt-core/kernel/os + * @{ + */ +#define SYS_EINVAL (-2) +#define SYS_ENOMEM (-1) +/** @} */ + +/** + * @name Macro to wait forever on events and mutexes + * @{ + */ +#define OS_TIMEOUT_NEVER (UINT32_MAX) +#define OS_WAIT_FOREVER (OS_TIMEOUT_NEVER) +/** @} */ + +/** + * @brief time type + */ +typedef uint32_t os_time_t; + +/** + * @brief stack buffer type + */ +typedef char os_stack_t; + +#ifdef __cplusplus +} +#endif + +#endif /* OS_OS_TYPES_H */ diff --git a/pkg/mynewt-core/include/syscfg/syscfg.h b/pkg/mynewt-core/include/syscfg/syscfg.h new file mode 100644 index 0000000000..b546f9c19f --- /dev/null +++ b/pkg/mynewt-core/include/syscfg/syscfg.h @@ -0,0 +1,122 @@ +/** + * Apache Mynewt + * Copyright 2015-2021 The Apache Software Foundation + * + * This product includes software developed at + * The Apache Software Foundation (http://www.apache.org/). + * + * Portions of this software were developed at + * Runtime Inc, copyright 2015. + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief mynewt-core system configurations + * + * @} + */ + +#ifndef SYSCFG_SYSCFG_H +#define SYSCFG_SYSCFG_H + +#include "kernel_defines.h" + +/** + * @name MyNewt header inclusion macro definitions + * @{ + * + * PLEASE NOTE: Following macro definitions where copied directly from + * apache/mynewt-core and are under the copyright specified in + * the header. + * + * This macro exists to ensure code includes this header when needed. If code + * checks the existence of a setting directly via ifdef without including this + * header, the setting macro will silently evaluate to 0. In contrast, an + * attempt to use these macros without including this header will result in a + * compiler error. + */ +#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name +#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val +/** @} */ + +/** + * @brief TIMER 5 (RTC_DEV0) will be mynewt-core OS_CPUTIME timer + */ +#ifndef MYNEWT_VAL_OS_CPUTIME_TIMER_NUM +#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (5) +#endif + +/** + * @brief Enable TIMER 5 (RTC_DEV0) + */ +#ifndef MYNEWT_VAL_TIMER_5 +#define MYNEWT_VAL_TIMER_5 (1) +#endif + +#if IS_USED(MODULE_NIMBLE) +/*** @mynewt-nimble */ +#undef MYNEWT_VAL +#undef MYNEWT_VAL_CHOICE +#include "npl_sycfg.h" +#endif + +#if IS_USED(MODULE_UWB_CORE) +/*** @decawave-mynewt-core/hw/drivers/uwb */ +#include "dpl_syscfg/syscfg_uwb.h" + +/*** @decawave-mynewt-core/lib/twr_ds */ +#include "dpl_syscfg/syscfg_twr_ds.h" + +/*** @decawave-mynewt-core/lib/twr_ds_ext */ +#include "dpl_syscfg/syscfg_twr_ds_ext.h" + +/*** @decawave-mynewt-core/lib/twr_ss */ +#include "dpl_syscfg/syscfg_twr_ss.h" + +/*** @decawave-mynewt-core/lib/twr_ss_ack */ +#include "dpl_syscfg/syscfg_twr_ss_ack.h" + +/*** @decawave-mynewt-core/lib/twr_ss_ext */ +#include "dpl_syscfg/syscfg_twr_ss_ext.h" + +/*** @decawave-mynewt-core/lib/uwb_rng */ +#include "dpl_syscfg/syscfg_uwb_rng.h" + +/*** @decawave-mynewt-core/sys/uwbcfg */ +#include "dpl_syscfg/syscfg_uwbcfg.h" +#endif + +#if IS_USED(MODULE_UWB_DW1000) +/*** @decawave-uwb-dw1000/hw/drivers/uwb/uwb_dw1000 */ +#include "syscfg_uwb_dw1000.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* SYSCFG_SYSCFG_H */ diff --git a/pkg/mynewt-core/include/sysinit/sysinit.h b/pkg/mynewt-core/include/sysinit/sysinit.h new file mode 100644 index 0000000000..7c65fd56f6 --- /dev/null +++ b/pkg/mynewt-core/include/sysinit/sysinit.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_mynewt_core + * @{ + * + * @file + * @brief sysinit abstraction layer for RIOT adaption + * + * @author Francisco Molina + * @} + */ + +#ifndef SYSINIT_SYSINIT_H +#define SYSINIT_SYSINIT_H + +#include "assert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief assert macro + */ +#define SYSINIT_PANIC_ASSERT(rc) assert(rc); + +/** + * @brief empty definition + */ +#define SYSINIT_ASSERT_ACTIVE() + +#ifdef __cplusplus +} +#endif + +#endif /* SYSINIT_SYSINIT_H */ diff --git a/pkg/mynewt-core/mynewt-core_nrf5x_hal.mk b/pkg/mynewt-core/mynewt-core_nrf5x_hal.mk new file mode 100644 index 0000000000..b1f2145380 --- /dev/null +++ b/pkg/mynewt-core/mynewt-core_nrf5x_hal.mk @@ -0,0 +1,5 @@ +MODULE = mynewt-core_nrf5x_hal + +SRC := hal_timer.c + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/mynewt-core/mynewt-core_os.mk b/pkg/mynewt-core/mynewt-core_os.mk new file mode 100644 index 0000000000..8077bdeabe --- /dev/null +++ b/pkg/mynewt-core/mynewt-core_os.mk @@ -0,0 +1,15 @@ +MODULE = mynewt-core_os + +SRC := \ + endian.c \ + os_mbuf.c \ + os_mempool.c \ + os_msys.c \ + os_cputime_pwr2.c \ + # + +ifneq (,$(filter nrf%,$(CPU))) + SRC += os_cputime.c +endif + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/mynewt-core/mynewt-core_util.mk b/pkg/mynewt-core/mynewt-core_util.mk new file mode 100644 index 0000000000..eb4abdce05 --- /dev/null +++ b/pkg/mynewt-core/mynewt-core_util.mk @@ -0,0 +1,5 @@ +MODULE = mynewt-core_util + +SRC := mem.c + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/mynewt-core/patches/0001-hw-mcu-nrf5x-adapt-NVIC-init-to-RIOT.patch b/pkg/mynewt-core/patches/0001-hw-mcu-nrf5x-adapt-NVIC-init-to-RIOT.patch new file mode 100644 index 0000000000000000000000000000000000000000..de1c0ba6c37afa0cf1799629ee6a2464a95a567a GIT binary patch literal 2272 zcmeHIT~FIE6n*!vxMD9YZ9eQYX(*-8hS~s7rexd@41J z#0+Q`!mwZefQ2C?CrHzW6O(DKDqdn@p>zfZQcUZo!JPZNI3&lJ6@5q32D%4FGlOtO zfyVt9`4VV_NJmEV@i)P3AHJL)UB3SaG>E>!9d=5W>hR|{gQQL9s85~{1VL=8`6`}$@ z$@I0z@pK{Ts)Vts)K#O^#0Z646yiSMH3`X;l;C;Ss6GoGPWOW1@hcOF(z#ebwzoGH zNzBK-9|_5ORAwPc3zJUAHR{!M3APAcU3)M9kFho$xP^avFc=Vcqckt(xqySLa&7S^ zhwDLMj4n50J7pD2@3gqZ+#TYr2zJ~Q@M)#0RNpA>Hd~vUnBbz1HFxl(uf6z9IyX@C zNr^g^j+K>46nXVz_hAfaio8$iBXUs}ClKty@ZvMfOleDdHxsZM5O5E*TU=v2?A?R(~3F0Y#e z2)Knpj#ZV73*iK{p%NBVsnRHW2UxNW+@Rq~gF_3p&U9kkau!RMa6~tpPOO94uvR!>x4B`EYCUKj*_|e8wJp_T&<9@0+E(DEarl;KHa|-)M0Z zw<-G*8;+}4ZBy^iPEBgWHN3?SRUN`HbZawX=`_q*KA}JU8~Xl|`>mnz!$z3TdVWaA EFF+Z^?f?J) literal 0 HcmV?d00001 diff --git a/pkg/mynewt-core/patches/0002-kernel-os-src-riot-patches.patch b/pkg/mynewt-core/patches/0002-kernel-os-src-riot-patches.patch new file mode 100644 index 0000000000000000000000000000000000000000..68ad996c3e6acef669071c82ebfb5480a1fcaa29 GIT binary patch literal 7985 zcmbtZc~jd+7X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BOwlCXMyz5S~0 zlI9K!RDTV8=JT-ycS`HCXT6HX`;H5A9?#o;NKZO|(-;Pb2VN&Uyg z9eUe4?o(J341r14Pa@x5Tv)5^1SLYomxq_S-jFPpxY5M#&rRiOEH*T)@QJNl&?6ygMM`2d*>-FZa{T@O${0;JZH|NC)DsDs$bd8NXV$Ile}+Wn)!2A#aefQ??s48BV-lM2)R_WGyz>SiAW19<)V zTeUy1_8sZa>w09ve4}(lsWN%jy+cI=+X^yD192>>qS5v+zz2i1g5I_VpUI-Lw5X;_ ziz*7oO9BNJhV}iklqvLwPpytcGU&I;A+PTSXAEEn+SH9OO^s*m?2z$kayQo(p!2dR zQfiN#!ql-2E<3qAZv++dzj*{$61#HSDk zN$%XheJ<&{&~4s{D14|St>ZscHB@965WugbHF-Q$bl6 Date: Mon, 5 Jul 2021 14:30:34 +0200 Subject: [PATCH 2/5] pkg/uwb-dw1000: use mynewt-core pkg --- pkg/uwb-dw1000/Makefile | 3 +- pkg/uwb-dw1000/Makefile.dep | 5 +- pkg/uwb-dw1000/include/hal/hal_gpio.h | 197 ------------------ pkg/uwb-dw1000/include/hal/hal_spi.h | 169 --------------- pkg/uwb-dw1000/include/hal/hal_timer.h | 45 ---- ...de-dw1000-dw1000_dev-add-linked-list.patch | Bin 894 -> 894 bytes ...0_hal-send-spi-cmd-and-data-separetl.patch | Bin 2402 -> 2412 bytes ...0_hal-define-even-if-DW1000_DEVICE_0.patch | Bin 1004 -> 1004 bytes ...1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch} | Bin 810 -> 810 bytes ...0_hal-replace-OS_-_CRTICAL-with-DPL_.patch | Bin 1101 -> 0 bytes ...00_dev-use-gpio_t-types-for-dev_cfg.patch} | Bin 1310 -> 1310 bytes ...000_mac-avoid-conflict-with-msp430-N.patch | Bin 1810 -> 0 bytes 12 files changed, 3 insertions(+), 416 deletions(-) delete mode 100644 pkg/uwb-dw1000/include/hal/hal_gpio.h delete mode 100644 pkg/uwb-dw1000/include/hal/hal_spi.h delete mode 100644 pkg/uwb-dw1000/include/hal/hal_timer.h rename pkg/uwb-dw1000/patches/{0005-uwb_dw1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch => 0004-uwb_dw1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch} (80%) delete mode 100644 pkg/uwb-dw1000/patches/0004-uwb_dw1000-dw1000_hal-replace-OS_-_CRTICAL-with-DPL_.patch rename pkg/uwb-dw1000/patches/{0006-dw1000-dw1000_dev-use-gpio_t-types-for-dev_cfg.patch => 0005-dw1000-dw1000_dev-use-gpio_t-types-for-dev_cfg.patch} (90%) delete mode 100644 pkg/uwb-dw1000/patches/0007-uwb_dw1000-dw1000_mac-avoid-conflict-with-msp430-N.patch diff --git a/pkg/uwb-dw1000/Makefile b/pkg/uwb-dw1000/Makefile index cccafb6b37..9c08e859cc 100644 --- a/pkg/uwb-dw1000/Makefile +++ b/pkg/uwb-dw1000/Makefile @@ -1,10 +1,11 @@ PKG_NAME=uwb-dw1000 PKG_URL=https://github.com/Decawave/uwb-dw1000/ -PKG_VERSION=6eaa85e6d429450d19a6ddeb2de05303016c0dd2 +PKG_VERSION=d44078a96349b7a40e9c2393ea83ca4c2d53ab92 PKG_LICENSE=Apache-2.0 include $(RIOTBASE)/pkg/pkg.mk +CFLAGS += -Wno-enum-compare CFLAGS += -Wno-address-of-packed-member CFLAGS += -Wno-enum-conversion CFLAGS += -Wno-maybe-uninitialized diff --git a/pkg/uwb-dw1000/Makefile.dep b/pkg/uwb-dw1000/Makefile.dep index b64241bd0b..2f7e3f9ec4 100644 --- a/pkg/uwb-dw1000/Makefile.dep +++ b/pkg/uwb-dw1000/Makefile.dep @@ -1,13 +1,10 @@ USEMODULE += uwb-dw1000_hal DEFAULT_MODULE += auto_init_uwb-dw1000 -USEMODULE += xtimer +USEPKG += mynewt-core FEATURES_REQUIRED += periph_gpio_irq FEATURES_REQUIRED += periph_spi # Some of the pkg operation would overflow on 16bit FEATURES_REQUIRED += arch_32bit - -# LLVM ARM shows issues with missing definitions for stdatomic -TOOLCHAINS_BLACKLIST += llvm diff --git a/pkg/uwb-dw1000/include/hal/hal_gpio.h b/pkg/uwb-dw1000/include/hal/hal_gpio.h deleted file mode 100644 index b09ba8beea..0000000000 --- a/pkg/uwb-dw1000/include/hal/hal_gpio.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_dw1000 - * @{ - * - * @file - * @brief GPIO abstraction layer RIOT adaption - * - * @author Francisco Molina - * @} - */ - -#ifndef HAL_HAL_GPIO_H -#define HAL_HAL_GPIO_H - -#include "periph/gpio.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Map hal_gpio_pull_t enum types to gpio_mode_t enum types - */ -enum { - /** Pull-up/down not enabled */ - HAL_GPIO_PULL_NONE = GPIO_IN, - /** Pull-up enabled */ - HAL_GPIO_PULL_UP = GPIO_IN_PU, - /** Pull-down enabled */ - HAL_GPIO_PULL_DOWN = GPIO_IN_PD -}; -/** - * @brief hal_gpio_pull type - */ -typedef gpio_mode_t hal_gpio_pull_t; - -/** - * @brief Map hal_gpio_irq_trig_t enum types to gpio_flank_t enum types - */ -enum { -#ifdef GPIO_NONE - HAL_GPIO_TRIG_NONE = GPIO_NONE, -#endif - /** IRQ occurs on rising edge */ - HAL_GPIO_TRIG_RISING = GPIO_RISING, - /** IRQ occurs on falling edge */ - HAL_GPIO_TRIG_FALLING = GPIO_FALLING, - /** IRQ occurs on either edge */ - HAL_GPIO_TRIG_BOTH = GPIO_BOTH, - /** IRQ occurs when line is low */ -#ifdef GPIO_LOW - HAL_GPIO_TRIG_LOW = GPIO_LOW, -#endif - /** IRQ occurs when line is high */ -#ifdef GPIO_HIGH - HAL_GPIO_TRIG_HIGH = GPIO_HIGH -#endif -}; -/** - * @brief hal_gpio_irq_trig type - */ -typedef gpio_flank_t hal_gpio_irq_trig_t; - -/** - * @brief Function proto for GPIO irq handler functions - */ -typedef gpio_cb_t hal_gpio_irq_handler_t; - -/** - * Initializes the specified pin as an input - * - * @param pin Pin number to set as input - * @param pull pull type - * - * @return int 0: no error; -1 otherwise. - */ -static inline int hal_gpio_init_in(gpio_t pin, hal_gpio_pull_t pull) -{ - return gpio_init(pin, pull); -} - -/** - * Initialize the specified pin as an output, setting the pin to the specified - * value. - * - * @param pin Pin number to set as output - * @param val Value to set pin - * - * @return int 0: no error; -1 otherwise. - */ -static inline int hal_gpio_init_out(gpio_t pin, int val) -{ - int res = gpio_init(pin, GPIO_OUT); - gpio_write(pin, val); - return res; -} - -/** - * Write a value (either high or low) to the specified pin. - * - * @param pin Pin to set - * @param val Value to set pin (0:low 1:high) - */ -static inline void hal_gpio_write(gpio_t pin, int val) -{ - gpio_write(pin, val); -} - -/** - * Reads the specified pin. - * - * @param pin Pin number to read - * - * @return int 0: low, 1: high - */ -static inline int hal_gpio_read(gpio_t pin) -{ - return gpio_read(pin); -} - -/** - * Toggles the specified pin - * - * @param pin Pin number to toggle - * - * @return current gpio state int 0: low, 1: high - */ -static inline int hal_gpio_toggle(gpio_t pin) -{ - gpio_toggle(pin); - return gpio_read(pin); -} - -/** - * Initialize a given pin to trigger a GPIO IRQ callback. - * - * @param pin The pin to trigger GPIO interrupt on - * @param handler The handler function to call - * @param arg The argument to provide to the IRQ handler - * @param trig The trigger mode (e.g. rising, falling) - * @param pull The mode of the pin (e.g. pullup, pulldown) - * - * @return 0 on success, non-zero error code on failure. - */ -static inline int hal_gpio_irq_init(gpio_t pin, - hal_gpio_irq_handler_t handler, - void *arg, - hal_gpio_irq_trig_t trig, - hal_gpio_pull_t pull) -{ - return gpio_init_int(pin, pull, trig, handler, arg); -} - -/** - * Release a pin from being configured to trigger IRQ on state change. - * - * @param pin The pin to release - */ -static inline void hal_gpio_irq_release(gpio_t pin) -{ - /* can't release the interrupt so ar least disable it */ - gpio_irq_disable(pin); -} - -/** - * Enable IRQs on the passed pin - * - * @param pin The pin to enable IRQs on - */ -static inline void hal_gpio_irq_enable(gpio_t pin) -{ - gpio_irq_enable(pin); -} - -/** - * Disable IRQs on the passed pin - * - * @param pin The pin to disable IRQs on - */ -static inline void hal_gpio_irq_disable(gpio_t pin) -{ - gpio_irq_disable(pin); -} - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_HAL_GPIO_H */ diff --git a/pkg/uwb-dw1000/include/hal/hal_spi.h b/pkg/uwb-dw1000/include/hal/hal_spi.h deleted file mode 100644 index da13747bb1..0000000000 --- a/pkg/uwb-dw1000/include/hal/hal_spi.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_dw1000 - * @{ - * - * @file - * @brief SPI abstraction layer RIOT adaption - * - * @author Francisco Molina - * @} - */ - -#ifndef HAL_HAL_SPI_H -#define HAL_HAL_SPI_H - -#include "periph/spi.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** SPI mode 0 */ -#define HAL_SPI_MODE0 (SPI_MODE_0) -/** SPI mode 1 */ -#define HAL_SPI_MODE1 (SPI_MODE_1) -/** SPI mode 2 */ -#define HAL_SPI_MODE2 (SPI_MODE_2) -/** SPI mode 3 */ -#define HAL_SPI_MODE3 (SPI_MODE_3) - -/** - * @brief Prototype for tx/rx callback - */ -typedef void (*hal_spi_txrx_cb)(void *arg, int len); - -/** - * @brief since one spi device can control multiple devices, some configuration - * can be changed on the fly from the hal - */ -struct hal_spi_settings { - /** Data mode of SPI driver, defined by HAL_SPI_MODEn */ - spi_mode_t data_mode; - /** Baudrate in kHz */ - spi_clk_t baudrate; -}; - -/** - * @brief Configure the spi. Must be called after the spi is initialized (after - * hal_spi_init is called) and when the spi is disabled (user must call - * hal_spi_disable if the spi has been enabled through hal_spi_enable prior - * to calling this function). Can also be used to reconfigure an initialized - * SPI (assuming it is disabled as described previously). - * - * @param spi_num The number of the SPI to configure. - * @param psettings The settings to configure this SPI with - * - * @return int 0 on success, non-zero error code on failure. - */ -int hal_spi_config(int spi_num, struct hal_spi_settings *psettings); - -/** - * @brief Sets the txrx callback (executed at interrupt context) when the - * buffer is transferred by the master or the slave using the non-blocking API. - * Cannot be called when the spi is enabled. This callback will also be called - * when chip select is de-asserted on the slave. - * - * NOTE: This callback is only used for the non-blocking interface and must - * be called prior to using the non-blocking API. - * - * @param spi_num SPI interface on which to set callback - * @param txrx_cb Callback function - * @param arg Argument to be passed to callback function - * - * @return int 0 on success, non-zero error code on failure. - */ -int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg); - -/** - * @brief Enables the SPI. This does not start a transmit or receive operation; - * it is used for power mgmt. Cannot be called when a SPI transfer is in - * progress. - * - * @param spi_num - * - * @return int 0 on success, non-zero error code on failure. - */ -int hal_spi_enable(int spi_num); - -/** - * @brief Disables the SPI. Used for power mgmt. It will halt any current SPI transfers - * in progress. - * - * @param spi_num - * - * @return int 0 on success, non-zero error code on failure. - */ -int hal_spi_disable(int spi_num); - -/** - * @brief Blocking interface to send a buffer and store the received values from the - * slave. The transmit and receive buffers are either arrays of 8-bit (uint8_t) - * values or 16-bit values depending on whether the spi is configured for 8 bit - * data or more than 8 bits per value. The 'cnt' parameter is the number of - * 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an - * array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise - * txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values). - * - * NOTE: these buffers are in the native endian-ness of the platform. - * - * MASTER: master sends all the values in the buffer and stores the - * stores the values in the receive buffer if rxbuf is not NULL. - * The txbuf parameter cannot be NULL. - * SLAVE: cannot be called for a slave; returns -1 - * - * @param spi_num SPI interface to use - * @param txbuf Pointer to buffer where values to transmit are stored. - * @param rxbuf Pointer to buffer to store values received from peer. - * @param cnt Number of 8-bit or 16-bit values to be transferred. - * - * @return int 0 on success, non-zero error code on failure. - */ -int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt); - -/** - * @brief Non-blocking interface to send a buffer and store received values. Can be - * used for both master and slave SPI types. The user must configure the - * callback (using hal_spi_set_txrx_cb); the txrx callback is executed at - * interrupt context when the buffer is sent. - * - * The transmit and receive buffers are either arrays of 8-bit (uint8_t) - * values or 16-bit values depending on whether the spi is configured for 8 bit - * data or more than 8 bits per value. The 'cnt' parameter is the number of - * 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an - * array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise - * txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values). - * - * NOTE: these buffers are in the native endian-ness of the platform. - * - * MASTER: master sends all the values in the buffer and stores the - * stores the values in the receive buffer if rxbuf is not NULL. - * The txbuf parameter cannot be NULL - * SLAVE: Slave "preloads" the data to be sent to the master (values - * stored in txbuf) and places received data from master in rxbuf - * (if not NULL). The txrx callback occurs when len values are - * transferred or master de-asserts chip select. If txbuf is NULL, - * the slave transfers its default byte. Both rxbuf and txbuf cannot - * be NULL. - * - * @param spi_num SPI interface to use - * @param txbuf Pointer to buffer where values to transmit are stored. - * @param rxbuf Pointer to buffer to store values received from peer. - * @param cnt Number of 8-bit or 16-bit values to be transferred. - * - * @return int 0 on success, non-zero error code on failure. - */ -int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt); - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_HAL_SPI_H */ diff --git a/pkg/uwb-dw1000/include/hal/hal_timer.h b/pkg/uwb-dw1000/include/hal/hal_timer.h deleted file mode 100644 index a3b72c3bb5..0000000000 --- a/pkg/uwb-dw1000/include/hal/hal_timer.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_dw1000 - * @{ - * - * @file - * @brief Timer abstraction layer RIOT adaption - * - * @author Francisco Molina - * @} - */ - -#ifndef HAL_HAL_TIMER_H -#define HAL_HAL_TIMER_H - -#include "xtimer.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief HAL timer callback - */ -typedef xtimer_callback_t hal_timer_cb; - -/** - * @brief The HAL timer structure. - */ -struct hal_timer { - xtimer_t timer; /**< the timer */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_HAL_TIMER_H */ diff --git a/pkg/uwb-dw1000/patches/0001-uwb_dw1000-include-dw1000-dw1000_dev-add-linked-list.patch b/pkg/uwb-dw1000/patches/0001-uwb_dw1000-include-dw1000-dw1000_dev-add-linked-list.patch index 9b39d60598ea771e9e7177e3de3a496afb420bf1..8a6587220b34a034aada11ad5b468169446ef5e5 100644 GIT binary patch delta 54 zcmeyz_K!{1ttdZNAuZL=&>+Rq*f1$A(Ja|0$-pQ%$(%8~GB`L+w#KOeLz}(C- Jb)#+|GXU^95V8OO diff --git a/pkg/uwb-dw1000/patches/0002-uwb_dw1000-dw1000_hal-send-spi-cmd-and-data-separetl.patch b/pkg/uwb-dw1000/patches/0002-uwb_dw1000-dw1000_hal-send-spi-cmd-and-data-separetl.patch index 38356d4e375870e0819b8fd907dcb578b6a0125d..0e5bfec6cb62732053804e086a0d4a435c8a3dab 100644 GIT binary patch delta 136 zcmaDP^hQY6ttdZN!8p-4%`(}<(!kQx+{_}yC?(m_z#`4a#2`7*z$i7<($XT?IK?u_ za-;4XMgb#ZO9L}wQ$4*TLrc?SBjd?88MjRCV^W{IjmefHKFl>J*wf!{azER}%}1D1 anJ{EF_p=>k;^ETO?lb9 delta 128 zcmaDO^hik8ttdZN!6Gf$%-AR;&Dg@iAk{J{+0@wF%q+l> zVx#UHMuB8YLj&`)L_NJE3)56%qr}NK8MiPhOx9;p2a;iIwv%VGUEF+%Ih6@naPw@o VqfC4XT)MgnTt<3E7J3F;TmXutBW3^q diff --git a/pkg/uwb-dw1000/patches/0003-uwb_dw1000-dw1000_hal-define-even-if-DW1000_DEVICE_0.patch b/pkg/uwb-dw1000/patches/0003-uwb_dw1000-dw1000_hal-define-even-if-DW1000_DEVICE_0.patch index c103f8d71b374abd69a848e35c259e27447a68f5..f3355e05f3dd9f8c9c041d482e8e575f40243232 100644 GIT binary patch delta 92 zcmaFE{)S!GttdZNA;l~y**wWI)!fu5%{axx#LyziFg492)!4+$BGn?v$iUn@(L6Q9 vaHFm{lZ>IIX|j>Ao}Q(VnT4UHv4Ww2ftiU3m#(g^LgHjYCY{Y|m>d`Z(@z*! delta 92 zcmaFE{)S!GttdZNAvML&)WpIp&D_G$AkjE2Ey=*d$Sm2=)HpdcEy>cd`Z+F}_F diff --git a/pkg/uwb-dw1000/patches/0005-uwb_dw1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch b/pkg/uwb-dw1000/patches/0004-uwb_dw1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch similarity index 80% rename from pkg/uwb-dw1000/patches/0005-uwb_dw1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch rename to pkg/uwb-dw1000/patches/0004-uwb_dw1000-dw1000_hal-os_sr_t-by-dpl_sr_t.patch index 0c48acdbd152da79e7b2961f54bafeeaa94a25e0..8878c563419d4b4ef3725c33dc9b0f6b1ddcd31b 100644 GIT binary patch delta 81 zcmZ3*wu(*HttdZN!6en#!XzohGTAga$uP;-B-z5)+%Vb1IMu=^F(t*!+#bKD9PMB&CJ-?z&O=7*~r*1Eh#n0DA~f)!Xnku le4=gzqv^(FOpF4?2ByZAiKcpbCdp}OCZ?8~cQ6()0sy0t7MK74 diff --git a/pkg/uwb-dw1000/patches/0004-uwb_dw1000-dw1000_hal-replace-OS_-_CRTICAL-with-DPL_.patch b/pkg/uwb-dw1000/patches/0004-uwb_dw1000-dw1000_hal-replace-OS_-_CRTICAL-with-DPL_.patch deleted file mode 100644 index 26c64f4c2753b8de3fe62c2c569463991d30a059..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1101 zcmbtT-*1~R5PtVxaW9j|2*D5tAziyx{h>w6)-27#q-nB@xg=f*AZ(ge+Wz<1r0FJY zdx(ZWhrc_2=lkw_(^OlCq8KTrVLncxJmsr6i*S^r!*Gl=K`{(5Ni&*o_)wK_hcyHV zP&(;e2q_K7jiH&qO~Xqem8eW$AxjQ#R=Dl{&Ra1M#TmKc8f~2HLlD75yEfZH3PC&x z(n&Z1*Q_YHYqM`C^aQ@lFP4|@AoAm{(C#vp?*dAxzc*~diwQJX7hE9R-mzEga1>WxUSt4z)BVfV#CWd z=6wi3mI@m!t5P{`&jL9XxL4F@#G2WG_6W>S!8 zcx{!`JpzYkUFiytH^mdfN2yQto*x8=XG2VzuRkuY7pB$wwmPcmoeHS)^>YhQm^H=U>;dV!KA_ml(xrS@waNsIKVYxGTCd|68>0gCjO5 z?qNQgL1rdKmM~p>diyL&UKdQ%t(IG4X2|#xYZVIR#O5a0Q~%QC^K|)7S^o4rtI`NK r1)D?RmNjOGxq2zvNMq20G+fz{ckG7KPV3wE#$~3AgoAKApoIJcfwe>E diff --git a/pkg/uwb-dw1000/patches/0006-dw1000-dw1000_dev-use-gpio_t-types-for-dev_cfg.patch b/pkg/uwb-dw1000/patches/0005-dw1000-dw1000_dev-use-gpio_t-types-for-dev_cfg.patch similarity index 90% rename from pkg/uwb-dw1000/patches/0006-dw1000-dw1000_dev-use-gpio_t-types-for-dev_cfg.patch rename to pkg/uwb-dw1000/patches/0005-dw1000-dw1000_dev-use-gpio_t-types-for-dev_cfg.patch index f8f865639228f7aeffbb9e6b9e6d54c0355ff078..d276e65dd00b8a46fc2024fad3452f1899ad3554 100644 GIT binary patch delta 60 zcmbQoHIGZjttdZN!NS5KEj2kUE!iY3F)=MQ&B8FzATil2H8CwE+1w<}EX^?4(%2|z PqD}>~slMsP<>f2@P~8(x delta 60 zcmbQoHIGZjttdZNA=Sdjz&tI{AjvW{IW;-iG}SQ0G}SoSBrVl2DcQu*Fv%pv+{D6S PqD}>~nZDV^<>f2@GGh{1 diff --git a/pkg/uwb-dw1000/patches/0007-uwb_dw1000-dw1000_mac-avoid-conflict-with-msp430-N.patch b/pkg/uwb-dw1000/patches/0007-uwb_dw1000-dw1000_mac-avoid-conflict-with-msp430-N.patch deleted file mode 100644 index 30b0dfd633285669fd7d195979a7a5dce12e9799..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1810 zcmb7EVNcsI5dH37aTC&%&?dE=v|(j1scCON`^xvIUmhfAOks!WcY?BIvS<)U>F7JAP6-Zg>X^i@Ku$- zBA|5Ket=WT$P{VDFs+hYnpzeJ%uJrZTdfxD-N{n=GCL-xNu$Q_O{IN^;InKnn^Rz; zF$>3>Ll2)Q`MR9_RI(Yv_shxE`;QO}q93rlnThm%q_5v_5d8&Sa4An3Rl<(7Y$m#42 z_D)A(XgB?$+61=?FRFiX0vmQA?fWz zxcOwT`0u28ag5-26F36L%HkcjbE{Uq9dfMS6Env0OJm(Egbw&4Q82L; zH2)u}-Si4k$RUz6bvEl$?oQ7AhuXTkMq;hwa|C>gfxEjnp34oka?!TKPK?b4QnPaG zMB!c*%gn*~iY=y<;u#E1SZ*C~)TemD=uxpin`EE zn`KQIh0e;ws}B>)zo)WV-FxS>Z=?GU-=0O>dA5z% Date: Mon, 5 Jul 2021 14:30:50 +0200 Subject: [PATCH 3/5] pkg/uwb-core: use mynewt-core pkg --- pkg/uwb-core/Makefile | 3 +- pkg/uwb-core/Makefile.dep | 14 ++-- pkg/uwb-core/Makefile.include | 8 +- pkg/uwb-core/contrib/uwb_core.c | 8 +- pkg/uwb-core/contrib/uwb_core_init.c | 48 +++++------ pkg/uwb-core/dpl/Makefile | 3 - pkg/uwb-core/dpl/dpl_callout.c | 58 -------------- pkg/uwb-core/dpl/dpl_mutex.c | 58 -------------- pkg/uwb-core/dpl/dpl_sem.c | 60 -------------- pkg/uwb-core/dpl/dpl_task.c | 68 ---------------- pkg/uwb-core/include/dpl/dpl.h | 1 - pkg/uwb-core/include/dpl/dpl_callout.h | 29 ++++--- pkg/uwb-core/include/dpl/dpl_cputime.h | 35 +++----- pkg/uwb-core/include/dpl/dpl_error.h | 32 ++++---- pkg/uwb-core/include/dpl/dpl_eventq.h | 56 +++++-------- pkg/uwb-core/include/dpl/dpl_mutex.h | 22 +++-- pkg/uwb-core/include/dpl/dpl_os.h | 38 +++------ pkg/uwb-core/include/dpl/dpl_sem.h | 27 ++++--- pkg/uwb-core/include/dpl/dpl_tasks.h | 32 +++++--- pkg/uwb-core/include/dpl/dpl_time.h | 24 ++---- pkg/uwb-core/include/dpl/dpl_types.h | 12 +-- .../include/{mcu/mcu.h => dpl/queue.h} | 10 +-- .../{syscfg => dpl_syscfg}/syscfg_twr_ds.h | 6 +- .../syscfg_twr_ds_ext.h | 6 +- .../{syscfg => dpl_syscfg}/syscfg_twr_ss.h | 6 +- .../syscfg_twr_ss_ack.h | 6 +- .../syscfg_twr_ss_ext.h | 6 +- .../{syscfg => dpl_syscfg}/syscfg_uwb.h | 8 +- .../{syscfg => dpl_syscfg}/syscfg_uwb_rng.h | 6 +- .../{syscfg => dpl_syscfg}/syscfg_uwbcfg.h | 6 +- pkg/uwb-core/include/log/dpl_log.h | 48 ----------- pkg/uwb-core/include/os/os.h | 30 ------- pkg/uwb-core/include/os/os_dev.h | 52 ------------ pkg/uwb-core/include/stats/stats.h | 33 -------- pkg/uwb-core/include/syscfg/syscfg.h | 75 ------------------ pkg/uwb-core/include/sysinit/sysinit.h | 38 --------- ...use-RIOT-specific-uwb_dev_idx_lookup.patch | Bin 787 -> 795 bytes ...n-src-use-fmt-to-avoid-newlib-issue.patch} | Bin 1461 -> 1461 bytes ...002-lib-twr_-enable-stats-optionally.patch | Bin 28840 -> 0 bytes ...-use-DPL_ENOENT-instead-of-OS_ENOENT.patch | Bin 640 -> 0 bytes ...-uwb_rng-always-set-rssi-to-vrssi-0.patch} | Bin 1346 -> 1346 bytes .../0004-porting-dpl-add-riot-files.patch | Bin 0 -> 14226 bytes ...-use-DPL_ENOENT-instead-of-OS_ENOENT.patch | Bin 685 -> 0 bytes ...wb-include-uwb-add-UWB_ROLE_TAG-role.patch | Bin 0 -> 911 bytes ..._log.h-instaed-of-log.h-to-avoid-con.patch | Bin 2711 -> 0 bytes .../0008-porting-dpl-add-riot-files.patch | Bin 37259 -> 0 bytes 46 files changed, 209 insertions(+), 763 deletions(-) delete mode 100644 pkg/uwb-core/dpl/Makefile delete mode 100644 pkg/uwb-core/dpl/dpl_callout.c delete mode 100644 pkg/uwb-core/dpl/dpl_mutex.c delete mode 100644 pkg/uwb-core/dpl/dpl_sem.c delete mode 100644 pkg/uwb-core/dpl/dpl_task.c rename pkg/uwb-core/include/{mcu/mcu.h => dpl/queue.h} (83%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_twr_ds.h (90%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_twr_ds_ext.h (90%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_twr_ss.h (90%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_twr_ss_ack.h (90%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_twr_ss_ext.h (89%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_uwb.h (95%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_uwb_rng.h (91%) rename pkg/uwb-core/include/{syscfg => dpl_syscfg}/syscfg_uwbcfg.h (97%) delete mode 100644 pkg/uwb-core/include/log/dpl_log.h delete mode 100644 pkg/uwb-core/include/os/os.h delete mode 100644 pkg/uwb-core/include/os/os_dev.h delete mode 100644 pkg/uwb-core/include/stats/stats.h delete mode 100644 pkg/uwb-core/include/syscfg/syscfg.h delete mode 100644 pkg/uwb-core/include/sysinit/sysinit.h rename pkg/uwb-core/patches/{0006-lib-json-src-use-fmt-to-avoid-newlib-issue.patch => 0002-lib-json-src-use-fmt-to-avoid-newlib-issue.patch} (91%) delete mode 100644 pkg/uwb-core/patches/0002-lib-twr_-enable-stats-optionally.patch delete mode 100644 pkg/uwb-core/patches/0003-lib-tofdb-use-DPL_ENOENT-instead-of-OS_ENOENT.patch rename pkg/uwb-core/patches/{0007-lib-uwb_rng-always-set-rssi-to-vrssi-0.patch => 0003-lib-uwb_rng-always-set-rssi-to-vrssi-0.patch} (90%) create mode 100644 pkg/uwb-core/patches/0004-porting-dpl-add-riot-files.patch delete mode 100644 pkg/uwb-core/patches/0004-sys-uwbcfg-use-DPL_ENOENT-instead-of-OS_ENOENT.patch create mode 100644 pkg/uwb-core/patches/0005-hw-drivers-uwb-include-uwb-add-UWB_ROLE_TAG-role.patch delete mode 100644 pkg/uwb-core/patches/0005-treewide-use-dpl_log.h-instaed-of-log.h-to-avoid-con.patch delete mode 100644 pkg/uwb-core/patches/0008-porting-dpl-add-riot-files.patch diff --git a/pkg/uwb-core/Makefile b/pkg/uwb-core/Makefile index 0e03c05e7a..70b987aeeb 100644 --- a/pkg/uwb-core/Makefile +++ b/pkg/uwb-core/Makefile @@ -1,10 +1,11 @@ PKG_NAME=uwb-core PKG_URL=https://github.com/Decawave/uwb-core -PKG_VERSION=8ffba63755a932a89d841872ce5bdf35b9c78777 +PKG_VERSION=66f468659ec3353cf7fd6f2bd14f3a6cef397f4e PKG_LICENSE=Apache-2.0 include $(RIOTBASE)/pkg/pkg.mk +CFLAGS += -Wno-enum-compare CFLAGS += -Wno-implicit-int CFLAGS += -Wno-int-conversion CFLAGS += -Wno-strict-prototypes diff --git a/pkg/uwb-core/Makefile.dep b/pkg/uwb-core/Makefile.dep index d23cc1dcab..b4f0c0355a 100644 --- a/pkg/uwb-core/Makefile.dep +++ b/pkg/uwb-core/Makefile.dep @@ -3,9 +3,6 @@ USEMODULE += uwb-core_contrib DEFAULT_MODULE += auto_init_uwb-core -USEMODULE += sema -USEMODULE += event_callback -USEMODULE += xtimer USEMODULE += fmt FEATURES_REQUIRED += periph_gpio_irq @@ -25,12 +22,17 @@ ifneq (,$(filter uwb-core_uwbcfg,$(USEMODULE))) USEMODULE += uwb-core_config endif +ifneq (,$(filter uwb-core_dpl,$(USEMODULE))) + USEPKG += mynewt-core + USEMODULE += mynewt-core_os + ifneq (,$(filter nrf%,$(CPU))) + USEMODULE += mynewt-core_nrf5x_hal + endif +endif + # Some stdlib functions used by the pkg are not in avr-gcc FEATURES_BLACKLIST += arch_avr8 # uwb-core has specific compilation sources when compiling kernel # libraries these introduce additional compilation issues that have not # been addressed in this port FEATURES_BLACKLIST += arch_native - -# LLVM ARM shows issues with missing definitions for stdatomic -TOOLCHAINS_BLACKLIST += llvm diff --git a/pkg/uwb-core/Makefile.include b/pkg/uwb-core/Makefile.include index 6eb2f5f9ca..95a7b949c0 100644 --- a/pkg/uwb-core/Makefile.include +++ b/pkg/uwb-core/Makefile.include @@ -14,9 +14,7 @@ INCLUDES += -I$(PKGDIRBASE)/uwb-core/hw/drivers/uwb/include/ \ -I$(RIOTPKG)/uwb-core/include \ # -DIRS += $(RIOTPKG)/uwb-core/dpl \ - $(RIOTPKG)/uwb-core/contrib \ - # +PSEUDOMODULES += uwb-core_dpl -# A cflag to indicate in pkg code that we are building for RIOT -CFLAGS += -DRIOT +DIRS += $(RIOTPKG)/uwb-core/contrib \ + # diff --git a/pkg/uwb-core/contrib/uwb_core.c b/pkg/uwb-core/contrib/uwb_core.c index bc275d325c..dfde98d1dc 100644 --- a/pkg/uwb-core/contrib/uwb_core.c +++ b/pkg/uwb-core/contrib/uwb_core.c @@ -17,13 +17,14 @@ * @} */ -#include - #include "thread.h" #include "event.h" #include "event/callback.h" #include "uwb_core.h" +#include "os/os_cputime.h" +#include "hal/hal_timer.h" + #ifndef UWB_CORE_STACKSIZE #define UWB_CORE_STACKSIZE (THREAD_STACKSIZE_LARGE) #endif @@ -35,11 +36,10 @@ static char _stack_uwb_core[UWB_CORE_STACKSIZE]; static event_queue_t _queue; -atomic_uint dpl_in_critical = 0; - static void *_uwb_core_thread(void *arg) { (void)arg; + event_queue_init(&_queue); event_loop(&_queue); /* never reached */ diff --git a/pkg/uwb-core/contrib/uwb_core_init.c b/pkg/uwb-core/contrib/uwb_core_init.c index 62a84093de..d6b8ad0815 100644 --- a/pkg/uwb-core/contrib/uwb_core_init.c +++ b/pkg/uwb-core/contrib/uwb_core_init.c @@ -45,35 +45,35 @@ void uwb_core_init(void) uwb_dw1000_set_buffs(&dev, _dw1000_tx_buffer, _dw1000_rx_buffer); /* setup dw1000 device */ uwb_dw1000_setup(&dev, (void *) &dw1000_params[0]); - /* this will start a thread handling dw1000 device*/ + /* this will start a thread handling dw1000 device */ uwb_dw1000_config_and_start(&dev); /* init uwb pkg's */ - if (IS_USED(MODULE_UWB_CORE_RNG)) { - extern void uwb_rng_pkg_init(void); - uwb_rng_pkg_init(); - } +#if IS_USED(MODULE_UWB_CORE_RNG) + extern void uwb_rng_pkg_init(void); + uwb_rng_pkg_init(); +#endif /* uwb configuration module */ - if (IS_USED(MODULE_UWB_CORE_UWBCFG)) { - extern int uwbcfg_pkg_init(void); - uwbcfg_pkg_init(); - } +#if IS_USED(MODULE_UWB_CORE_UWBCFG) + extern int uwbcfg_pkg_init(void); + uwbcfg_pkg_init(); +#endif /* ranging algorithms */ - if (IS_USED(MODULE_UWB_CORE_RNG)) { - twr_ss_pkg_init(); - } - if (IS_USED(MODULE_UWB_CORE_RNG)) { - twr_ss_ack_pkg_init(); - } - if (IS_USED(MODULE_UWB_CORE_RNG)) { - twr_ss_ext_pkg_init(); - } - if (IS_USED(MODULE_UWB_CORE_RNG)) { - twr_ds_pkg_init(); - } - if (IS_USED(MODULE_UWB_CORE_RNG)) { - twr_ds_ext_pkg_init(); - } +#if IS_USED(MODULE_UWB_CORE_TWR_SS) + twr_ss_pkg_init(); +#endif +#if IS_USED(MODULE_UWB_CORE_TWR_SS_ACK) + twr_ss_ack_pkg_init(); +#endif +#if IS_USED(MODULE_UWB_CORE_TWR_SS_EXT) + twr_ss_ext_pkg_init(); +#endif +#if IS_USED(MODULE_UWB_CORE_TWR_DS) + twr_ds_pkg_init(); +#endif +#if IS_USED(MODULE_UWB_CORE_TWR_DS_EXT) + twr_ds_ext_pkg_init(); +#endif } diff --git a/pkg/uwb-core/dpl/Makefile b/pkg/uwb-core/dpl/Makefile deleted file mode 100644 index 6f5935a4a6..0000000000 --- a/pkg/uwb-core/dpl/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = uwb-core_dpl - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/uwb-core/dpl/dpl_callout.c b/pkg/uwb-core/dpl/dpl_callout.c deleted file mode 100644 index 232eaead62..0000000000 --- a/pkg/uwb-core/dpl/dpl_callout.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief uwb-core DPL (Decawave Porting Layer) callout - * - * @author Francisco Molina - * @} - */ - -#include - -#include "xtimer.h" -#include "dpl/dpl_callout.h" - -static void _dpl_callout_timer_cb(void* arg) -{ - struct dpl_callout *c = (struct dpl_callout *) arg; - assert(c); - - /* post the event if there is a queue, otherwise call the callback - here */ - if (c->c_q) { - dpl_eventq_put(c->c_q, &c->c_e); - } else { - c->c_e.e.callback(&c->c_e); - } -} - -void dpl_callout_init(struct dpl_callout *c, struct dpl_eventq *q, - dpl_event_fn *e_cb, void *e_arg) -{ - dpl_event_init(&c->c_e, e_cb, e_arg); - c->c_q = q; - c->timer.callback = _dpl_callout_timer_cb; - c->timer.arg = (void*) c; -} - -dpl_error_t dpl_callout_reset(struct dpl_callout *c, dpl_time_t ticks) -{ - xtimer_ticks32_t val = {.ticks32 = ticks}; - xtimer_set(&(c->timer), xtimer_usec_from_ticks(val)); - return DPL_OK; -} - -void dpl_callout_stop(struct dpl_callout *c) -{ - xtimer_remove(&(c->timer)); -} diff --git a/pkg/uwb-core/dpl/dpl_mutex.c b/pkg/uwb-core/dpl/dpl_mutex.c deleted file mode 100644 index 40a4ec9542..0000000000 --- a/pkg/uwb-core/dpl/dpl_mutex.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief Decawave Porting Layer mutex RIOT wrapper - * - * @author Francisco Molina - * @} - */ - -#include "mutex.h" -#include "dpl/dpl_mutex.h" - -dpl_error_t dpl_mutex_init(struct dpl_mutex *mu) -{ - if (!mu) { - return DPL_INVALID_PARAM; - } - mutex_init(&mu->mutex); - return DPL_OK; -} - -dpl_error_t dpl_mutex_release(struct dpl_mutex *mu) -{ - if (!mu) { - return DPL_INVALID_PARAM; - } - - mutex_unlock(&mu->mutex); - return DPL_OK; -} - -dpl_error_t dpl_mutex_pend(struct dpl_mutex *mu, uint32_t timeout) -{ - int rc = DPL_OK; - - if (!mu) { - return DPL_INVALID_PARAM; - } - - if (!timeout) { - rc = mutex_trylock(&mu->mutex); - } - else { - /* TODO: no timeout equivalent */ - mutex_lock(&mu->mutex); - } - return rc; -} diff --git a/pkg/uwb-core/dpl/dpl_sem.c b/pkg/uwb-core/dpl/dpl_sem.c deleted file mode 100644 index a6e2c39437..0000000000 --- a/pkg/uwb-core/dpl/dpl_sem.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief Decawave Porting Layer semaphore RIOT wrapper - * - * @author Francisco Molina - * @} - */ - -#include - -#include "irq.h" -#include "dpl/dpl_sem.h" - -dpl_error_t dpl_sem_init(struct dpl_sem *sem, uint16_t tokens) -{ - if (!sem) { - return DPL_INVALID_PARAM; - } - - sema_create(&sem->sema, tokens); - return DPL_OK; -} - -dpl_error_t dpl_sem_release(struct dpl_sem *sem) -{ - int ret; - - if (!sem) { - return DPL_INVALID_PARAM; - } - - ret = sema_post(&sem->sema); - - return (ret) ? DPL_ERROR : DPL_OK; -} - -uint16_t dpl_sem_get_count(struct dpl_sem *sem) -{ - unsigned state = irq_disable(); - unsigned int value = sem->sema.value; - irq_restore(state); - return value; -} - -dpl_error_t dpl_sem_pend(struct dpl_sem *sem, dpl_time_t timeout) -{ - int ret = sema_wait_timed(&sem->sema, timeout); - return (ret) ? DPL_ERROR : DPL_OK; -} diff --git a/pkg/uwb-core/dpl/dpl_task.c b/pkg/uwb-core/dpl/dpl_task.c deleted file mode 100644 index eba30fc540..0000000000 --- a/pkg/uwb-core/dpl/dpl_task.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief Decawave Porting Layer tasks RIOT wrapper - * - * @author Francisco Molina - * @} - */ - -#include "dpl/dpl_error.h" -#include "dpl/dpl_tasks.h" -#include "thread.h" - -#ifndef LOG_LEVEL -#define LOG_LEVEL LOG_INFO -#endif -#include "log.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int dpl_task_init(struct dpl_task *t, const char *name, dpl_task_func_t func, - void *arg, uint8_t prio, dpl_time_t sanity_itvl, - dpl_stack_t *stack_bottom, uint16_t stack_size) -{ - (void) sanity_itvl; - - LOG_INFO("dpl: starting thread %s\n", name); - - kernel_pid_t pid = thread_create(stack_bottom, (int) stack_size, - prio, THREAD_CREATE_STACKTEST, - func, arg, name); - - t->pid = pid; - - return (pid) ? DPL_ERROR : DPL_OK;; -} - -int dpl_task_remove(struct dpl_task *t) -{ - thread_zombify(); - return thread_kill_zombie(t->pid); -} - -uint8_t dpl_task_count(void) -{ - return sched_num_threads; -} - -void dpl_task_yield(void) -{ - thread_yield(); -} - -#ifdef __cplusplus -} -#endif diff --git a/pkg/uwb-core/include/dpl/dpl.h b/pkg/uwb-core/include/dpl/dpl.h index 79612a6140..309ea1343b 100644 --- a/pkg/uwb-core/include/dpl/dpl.h +++ b/pkg/uwb-core/include/dpl/dpl.h @@ -32,7 +32,6 @@ #include "dpl/dpl_tasks.h" #include "dpl/dpl_time.h" #include "kernel_defines.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/pkg/uwb-core/include/dpl/dpl_callout.h b/pkg/uwb-core/include/dpl/dpl_callout.h index 5759522fc7..b524238347 100644 --- a/pkg/uwb-core/include/dpl/dpl_callout.h +++ b/pkg/uwb-core/include/dpl/dpl_callout.h @@ -23,23 +23,17 @@ #ifndef DPL_DPL_CALLOUT_H #define DPL_DPL_CALLOUT_H -#include "xtimer.h" - -#include "dpl/dpl_types.h" -#include "dpl/dpl_eventq.h" -#include "dpl/dpl_error.h" +#include "os/os_callout.h" #ifdef __cplusplus extern "C" { #endif /** - * @brief callout structure + * @brief dpl callout wrapper */ struct dpl_callout { - xtimer_t timer; /**< timer */ - struct dpl_event c_e; /**< callout event */ - struct dpl_eventq *c_q; /**< callout event queue */ + struct os_callout co; /**< the callout */ }; /** @@ -56,8 +50,11 @@ struct dpl_callout { * @param[in] e_cb callback function * @param[in] e_arg callback function argument */ -void dpl_callout_init(struct dpl_callout *c, struct dpl_eventq *q, - dpl_event_fn *e_cb, void *e_arg); +static inline void dpl_callout_init(struct dpl_callout *c, struct dpl_eventq *q, + dpl_event_fn *e_cb, void *e_arg) +{ + os_callout_init(&c->co, &q->evq, (os_event_fn *) e_cb, e_arg); +} /** * @brief Reset the callout to fire off in 'ticks' ticks. @@ -67,14 +64,20 @@ void dpl_callout_init(struct dpl_callout *c, struct dpl_eventq *q, * * @return 0 on success, non-zero on failure */ -dpl_error_t dpl_callout_reset(struct dpl_callout *c, dpl_time_t ticks); +static inline dpl_error_t dpl_callout_reset(struct dpl_callout *c, dpl_time_t ticks) +{ + return (dpl_error_t) os_callout_reset(&c->co, ticks); +} /** * @brief Stops the callout from firing. * * @param[in] c the callout to stop */ -void dpl_callout_stop(struct dpl_callout *c); +static inline void dpl_callout_stop(struct dpl_callout *c) +{ + os_callout_stop(&c->co); +} #ifdef __cplusplus } diff --git a/pkg/uwb-core/include/dpl/dpl_cputime.h b/pkg/uwb-core/include/dpl/dpl_cputime.h index e5ee6b27f1..e299fbd429 100644 --- a/pkg/uwb-core/include/dpl/dpl_cputime.h +++ b/pkg/uwb-core/include/dpl/dpl_cputime.h @@ -24,10 +24,7 @@ extern "C" { #endif -#include - -#include "xtimer.h" -#include "hal/hal_timer.h" +#include "os/os_cputime.h" /** * Returns the low 32 bits of cputime. @@ -36,7 +33,7 @@ extern "C" { */ static inline uint32_t dpl_cputime_get32(void) { - return xtimer_now().ticks32; + return os_cputime_get32(); } /** @@ -48,7 +45,7 @@ static inline uint32_t dpl_cputime_get32(void) */ static inline uint32_t dpl_cputime_usecs_to_ticks(uint32_t usecs) { - return xtimer_ticks_from_usec(usecs).ticks32; + return os_cputime_usecs_to_ticks(usecs); } /** @@ -60,8 +57,7 @@ static inline uint32_t dpl_cputime_usecs_to_ticks(uint32_t usecs) */ static inline uint32_t dpl_cputime_ticks_to_usecs(uint32_t ticks) { - xtimer_ticks32_t val = {.ticks32 = ticks}; - return xtimer_usec_from_ticks(val); + return os_cputime_ticks_to_usecs(ticks); } /** @@ -71,8 +67,7 @@ static inline uint32_t dpl_cputime_ticks_to_usecs(uint32_t ticks) */ static inline void dpl_cputime_delay_ticks(uint32_t ticks) { - xtimer_ticks32_t val = {.ticks32 = ticks}; - xtimer_tsleep32((xtimer_ticks32_t) val); + os_cputime_delay_ticks(ticks); } /** @@ -82,7 +77,7 @@ static inline void dpl_cputime_delay_ticks(uint32_t ticks) */ static inline void dpl_cputime_delay_usecs(uint32_t usecs) { - xtimer_usleep(usecs); + os_cputime_delay_usecs(usecs); } /** @@ -95,8 +90,7 @@ static inline void dpl_cputime_delay_usecs(uint32_t usecs) static inline void dpl_cputime_timer_init(struct hal_timer *timer, hal_timer_cb fp, void *arg) { - timer->timer.callback = fp; - timer->timer.arg = arg; + os_cputime_timer_init(timer, fp, arg); } /** @@ -107,15 +101,14 @@ static inline void dpl_cputime_timer_init(struct hal_timer *timer, hal_timer_cb * * @param timer Pointer to timer to start. Cannot be NULL. * @param cputime The cputime at which the timer should expire. - * + *time * @return int 0 on success; EINVAL if timer already started or timer struct * invalid * */ static inline int dpl_cputime_timer_start(struct hal_timer *timer, uint32_t cputime) { - xtimer_set(&timer->timer, xtimer_now_usec() + cputime); - return 0; + return os_cputime_timer_start(timer, cputime); } /** @@ -132,13 +125,7 @@ static inline int dpl_cputime_timer_start(struct hal_timer *timer, uint32_t cput */ static inline int dpl_cputime_timer_relative(struct hal_timer *timer, uint32_t usecs) { - uint32_t now = xtimer_now_usec(); - if (now > usecs) { - xtimer_set(&timer->timer, now); - } else { - xtimer_set(&timer->timer, 0); - } - return 0; + return os_cputime_timer_relative(timer, usecs); } /** @@ -152,7 +139,7 @@ static inline int dpl_cputime_timer_relative(struct hal_timer *timer, uint32_t u */ static inline void dpl_cputime_timer_stop(struct hal_timer *timer) { - xtimer_remove(&timer->timer); + os_cputime_timer_stop(timer); } #ifdef __cplusplus diff --git a/pkg/uwb-core/include/dpl/dpl_error.h b/pkg/uwb-core/include/dpl/dpl_error.h index 212a32efed..24c46e60ea 100644 --- a/pkg/uwb-core/include/dpl/dpl_error.h +++ b/pkg/uwb-core/include/dpl/dpl_error.h @@ -24,29 +24,31 @@ extern "C" { #endif +#include "os/os_error.h" + /** * @brief DPL error types */ enum dpl_error { - DPL_OK = 0, - DPL_ENOMEM = 1, - DPL_EINVAL = 2, - DPL_INVALID_PARAM = 3, - DPL_MEM_NOT_ALIGNED = 4, - DPL_BAD_MUTEX = 5, - DPL_TIMEOUT = 6, - DPL_ERR_IN_ISR = 7, - DPL_ERR_PRIV = 8, - DPL_OS_NOT_STARTED = 9, - DPL_ENOENT = 10, - DPL_EBUSY = 11, - DPL_ERROR = 12, + DPL_OK = OS_OK, + DPL_ENOMEM = OS_ENOMEM, + DPL_EINVAL = OS_EINVAL, + DPL_INVALID_PARAM = OS_INVALID_PARM, + DPL_MEM_NOT_ALIGNED = OS_MEM_NOT_ALIGNED, + DPL_BAD_MUTEX = OS_BAD_MUTEX, + DPL_TIMEOUT = OS_TIMEOUT, + DPL_ERR_IN_ISR = OS_ERR_IN_ISR, + DPL_ERR_PRIV = OS_ERR_PRIV, + DPL_OS_NOT_STARTED = OS_NOT_STARTED, + DPL_ENOENT = OS_ENOENT, + DPL_EBUSY = OS_EBUSY, + DPL_ERROR = OS_ERROR , }; /** - * @brief dep error type + * @brief dpl error type */ -typedef enum dpl_error dpl_error_t; +typedef os_error_t dpl_error_t; #ifdef __cplusplus } diff --git a/pkg/uwb-core/include/dpl/dpl_eventq.h b/pkg/uwb-core/include/dpl/dpl_eventq.h index 5244879339..3108acde82 100644 --- a/pkg/uwb-core/include/dpl/dpl_eventq.h +++ b/pkg/uwb-core/include/dpl/dpl_eventq.h @@ -22,8 +22,8 @@ #include +#include "os/os_eventq.h" #include "uwb_core.h" -#include "event/callback.h" #ifdef __cplusplus extern "C" { @@ -32,18 +32,15 @@ extern "C" { /** * @brief dpl event wrapper */ -struct dpl_event -{ - event_callback_t e; /**< the event callback */ - void *arg; /**< the event argument */ +struct dpl_event { + struct os_event ev; /**< the envent */ }; /** * @brief dpl event queue wrapper */ -struct dpl_eventq -{ - event_queue_t q; /**< the event queue */ +struct dpl_eventq { + struct os_eventq evq; /**< the event queue */ }; /** @@ -61,13 +58,7 @@ typedef void dpl_event_fn(struct dpl_event *ev); static inline void dpl_event_init(struct dpl_event *ev, dpl_event_fn * fn, void *arg) { - /* - * Need to clear list_node manually since init function below does not do - * this. - */ - ev->e.super.list_node.next = NULL; - event_callback_init(&ev->e, (void(*)(void *))fn, ev); - ev->arg = arg; + os_event_init(&ev->ev, (os_event_fn*) fn, arg); } /** @@ -79,7 +70,7 @@ static inline void dpl_event_init(struct dpl_event *ev, dpl_event_fn * fn, */ static inline bool dpl_event_is_queued(struct dpl_event *ev) { - return (ev->e.super.list_node.next != NULL); + return os_event_is_queued(&ev->ev); } /** @@ -89,7 +80,7 @@ static inline bool dpl_event_is_queued(struct dpl_event *ev) */ static inline void *dpl_event_get_arg(struct dpl_event *ev) { - return ev->arg; + return os_event_get_arg(&ev->ev); } /** @@ -100,7 +91,7 @@ static inline void *dpl_event_get_arg(struct dpl_event *ev) */ static inline void dpl_event_set_arg(struct dpl_event *ev, void *arg) { - ev->arg = arg; + os_event_set_arg(&ev->ev, arg); } /** @@ -110,7 +101,7 @@ static inline void dpl_event_set_arg(struct dpl_event *ev, void *arg) */ static inline void dpl_event_run(struct dpl_event *ev) { - ev->e.super.handler(&ev->e.super); + os_event_run(&ev->ev); } /** @@ -120,7 +111,7 @@ static inline void dpl_event_run(struct dpl_event *ev) */ static inline void dpl_eventq_init(struct dpl_eventq *evq) { - event_queue_init_detached(&evq->q); + os_eventq_init(&evq->evq); } /** @@ -130,7 +121,7 @@ static inline void dpl_eventq_init(struct dpl_eventq *evq) */ static inline int dpl_eventq_inited(struct dpl_eventq *evq) { - return evq->q.waiter != NULL; + return os_eventq_inited(&evq->evq); } /** @@ -155,11 +146,7 @@ static inline void dpl_eventq_deinit(struct dpl_eventq *evq) */ static inline struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq) { - if (evq->q.waiter == NULL) { - event_queue_claim(&evq->q); - } - - return (struct dpl_event *) event_wait(&evq->q); + return (struct dpl_event *) os_eventq_get(&evq->evq, DPL_WAIT_FOREVER); } /** @@ -169,11 +156,7 @@ static inline struct dpl_event * dpl_eventq_get(struct dpl_eventq *evq) */ static inline struct dpl_event * dpl_eventq_get_no_wait(struct dpl_eventq *evq) { - if (evq->q.waiter == NULL) { - event_queue_claim(&evq->q); - } - - return (struct dpl_event *) event_get(&evq->q); + return (struct dpl_event *) os_eventq_get_no_wait(&evq->evq); } /** @@ -184,7 +167,7 @@ static inline struct dpl_event * dpl_eventq_get_no_wait(struct dpl_eventq *evq) */ static inline void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev) { - event_post(&evq->q, &ev->e.super); + os_eventq_put(&evq->evq, &ev->ev); } /** @@ -195,7 +178,7 @@ static inline void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_event *ev) */ static inline void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *ev) { - event_cancel(&evq->q, &ev->e.super); + os_eventq_remove(&evq->evq, &ev->ev); } /** @@ -205,8 +188,7 @@ static inline void dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_event *e */ static inline void dpl_eventq_run(struct dpl_eventq *evq) { - struct dpl_event *ev = dpl_eventq_get(evq); - dpl_event_run(ev); + os_eventq_run(&evq->evq); } /** @@ -218,7 +200,7 @@ static inline void dpl_eventq_run(struct dpl_eventq *evq) */ static inline bool dpl_eventq_is_empty(struct dpl_eventq *evq) { - return clist_count(&(evq->q.event_list)) == 0; + return os_eventq_is_empty(&evq->evq); } /** @@ -231,7 +213,7 @@ static inline bool dpl_eventq_is_empty(struct dpl_eventq *evq) */ static inline struct dpl_eventq * dpl_eventq_dflt_get(void) { - return (struct dpl_eventq*) uwb_core_get_eventq(); + return (struct dpl_eventq *) uwb_core_get_eventq(); } #ifdef __cplusplus diff --git a/pkg/uwb-core/include/dpl/dpl_mutex.h b/pkg/uwb-core/include/dpl/dpl_mutex.h index 667a5201d7..cb38b4f7db 100644 --- a/pkg/uwb-core/include/dpl/dpl_mutex.h +++ b/pkg/uwb-core/include/dpl/dpl_mutex.h @@ -20,10 +20,7 @@ #ifndef DPL_DPL_MUTEX_H #define DPL_DPL_MUTEX_H -#include "dpl_types.h" -#include "dpl_error.h" - -#include "mutex.h" +#include "os/os_mutex.h" #ifdef __cplusplus extern "C" { @@ -33,7 +30,7 @@ extern "C" { * @brief dpl mutex wrapper */ struct dpl_mutex { - mutex_t mutex; /**< the mutex */ + struct os_mutex mu; /**< the mutex */ }; /** @@ -41,7 +38,10 @@ struct dpl_mutex { * * @param[out] mu pre-allocated mutex structure, must not be NULL. */ -dpl_error_t dpl_mutex_init(struct dpl_mutex *mu); +static inline dpl_error_t dpl_mutex_init(struct dpl_mutex *mu) +{ + return (dpl_error_t) os_mutex_init(&mu->mu); +} /** * @brief Pend (wait) for a mutex. @@ -55,7 +55,10 @@ dpl_error_t dpl_mutex_init(struct dpl_mutex *mu); * DPL_INVALID_PARM mutex passed in was NULL * DPL_OK no error */ -dpl_error_t dpl_mutex_pend(struct dpl_mutex *mu, dpl_time_t timeout); +static inline dpl_error_t dpl_mutex_pend(struct dpl_mutex *mu, dpl_time_t timeout) +{ + return (dpl_error_t) os_mutex_pend(&mu->mu, timeout); +} /** * @@ -65,7 +68,10 @@ dpl_error_t dpl_mutex_pend(struct dpl_mutex *mu, dpl_time_t timeout); * DPL_INVALID_PARM mutex was NULL * DPL_OK no error */ -dpl_error_t dpl_mutex_release(struct dpl_mutex *mu); +static inline dpl_error_t dpl_mutex_release(struct dpl_mutex *mu) +{ + return (dpl_error_t) os_mutex_release(&mu->mu); +} #ifdef __cplusplus } diff --git a/pkg/uwb-core/include/dpl/dpl_os.h b/pkg/uwb-core/include/dpl/dpl_os.h index 62d703a18a..adfdcd5b99 100644 --- a/pkg/uwb-core/include/dpl/dpl_os.h +++ b/pkg/uwb-core/include/dpl/dpl_os.h @@ -11,7 +11,7 @@ * @{ * * @file - * @brief uwb-core DPL (Decawave Porting Layer) error types + * @brief uwb-core DPL (Decawave Porting Layer) os abstraction layer * * @author Francisco Molina * @} @@ -20,12 +20,7 @@ #ifndef DPL_DPL_OS_H #define DPL_DPL_OS_H -#include -#include -#include - -#include "irq.h" -#include "dpl/dpl_types.h" +#include "os/os.h" #ifdef __cplusplus extern "C" { @@ -35,20 +30,15 @@ extern "C" { * @name Entering and exiting critical section defines * @{ */ -#define DPL_ENTER_CRITICAL(_sr) (_sr = dpl_hw_enter_critical()) -#define DPL_EXIT_CRITICAL(_sr) (dpl_hw_exit_critical(_sr)) -#define DPL_ASSERT_CRITICAL() assert(dpl_hw_is_in_critical()) +#define DPL_ENTER_CRITICAL(_sr) (_sr = os_hw_enter_critical()) +#define DPL_EXIT_CRITICAL(_sr) (os_hw_exit_critical(_sr)) +#define DPL_ASSERT_CRITICAL() assert(os_hw_is_in_critical()) /** @} */ -/** - * @brief variable to check if ISR are disabled - */ -extern atomic_uint dpl_in_critical; - /** * @brief CPU status register */ -typedef uint32_t dpl_sr_t; +typedef os_sr_t dpl_sr_t; /** * @brief Disable ISRs @@ -57,10 +47,7 @@ typedef uint32_t dpl_sr_t; */ static inline uint32_t dpl_hw_enter_critical(void) { - uint32_t ctx = irq_disable(); - unsigned int count = atomic_load(&dpl_in_critical); - atomic_store(&dpl_in_critical, count + 1); - return ctx; + return os_hw_enter_critical(); } /** @@ -70,9 +57,7 @@ static inline uint32_t dpl_hw_enter_critical(void) */ static inline void dpl_hw_exit_critical(uint32_t ctx) { - unsigned int count = atomic_load(&dpl_in_critical); - atomic_store(&dpl_in_critical, count - 1); - irq_restore((unsigned)ctx); + os_hw_exit_critical(ctx); } /** @@ -82,12 +67,7 @@ static inline void dpl_hw_exit_critical(uint32_t ctx) */ static inline bool dpl_hw_is_in_critical(void) { - /* - * XXX Currently RIOT does not support an API for finding out if interrupts - * are currently disabled, hence in a critical section in this context. - * So for now, we use this global variable to keep this state for us. - */ - return (atomic_load(&dpl_in_critical) > 0); + return os_hw_is_in_critical(); } #ifdef __cplusplus diff --git a/pkg/uwb-core/include/dpl/dpl_sem.h b/pkg/uwb-core/include/dpl/dpl_sem.h index 4184199556..56d6713021 100644 --- a/pkg/uwb-core/include/dpl/dpl_sem.h +++ b/pkg/uwb-core/include/dpl/dpl_sem.h @@ -22,10 +22,7 @@ #include -#include "dpl_types.h" -#include "dpl_error.h" - -#include "sema.h" +#include "os/os_sem.h" #ifdef __cplusplus extern "C" { @@ -35,7 +32,7 @@ extern "C" { * @brief dpl semaphore wrapper */ struct dpl_sem { - sema_t sema; /**< the semaphore */ + struct os_sem sem; /**< the semaphore */ }; /** @@ -48,7 +45,10 @@ struct dpl_sem { * DPL_INVALID_PARM Semaphore passed in was NULL. * DPL_OK no error. */ -dpl_error_t dpl_sem_init(struct dpl_sem *sem, uint16_t tokens); +static inline dpl_error_t dpl_sem_init(struct dpl_sem *sem, uint16_t tokens) +{ + return (dpl_error_t) os_sem_init(&sem->sem, tokens); +} /** * @brief Pend (wait) for a semaphore. @@ -64,7 +64,10 @@ dpl_error_t dpl_sem_init(struct dpl_sem *sem, uint16_t tokens); * DPL_TIMEOUT semaphore was owned by another task and timeout=0 * DPL_OK no error */ -dpl_error_t dpl_sem_pend(struct dpl_sem *sem, dpl_time_t timeout); +static inline dpl_error_t dpl_sem_pend(struct dpl_sem *sem, dpl_time_t timeout) +{ + return (dpl_error_t) os_sem_pend(&sem->sem, timeout); +} /** * @brief Release a semaphore. @@ -75,12 +78,18 @@ dpl_error_t dpl_sem_pend(struct dpl_sem *sem, dpl_time_t timeout); * DPL_INVALID_PARM semaphore passed in was NULL. * DPL_OK no error */ -dpl_error_t dpl_sem_release(struct dpl_sem *sem); +static inline dpl_error_t dpl_sem_release(struct dpl_sem *sem) +{ + return (dpl_error_t) os_sem_release(&sem->sem); +} /** * @brief Get current semaphore's count */ -uint16_t dpl_sem_get_count(struct dpl_sem *sem); +static inline int16_t dpl_sem_get_count(struct dpl_sem *sem) +{ + return os_sem_get_count(&sem->sem); +} #ifdef __cplusplus } diff --git a/pkg/uwb-core/include/dpl/dpl_tasks.h b/pkg/uwb-core/include/dpl/dpl_tasks.h index 62b2139aaf..e92b7442e8 100644 --- a/pkg/uwb-core/include/dpl/dpl_tasks.h +++ b/pkg/uwb-core/include/dpl/dpl_tasks.h @@ -20,10 +20,7 @@ #ifndef DPL_DPL_TASKS_H #define DPL_DPL_TASKS_H -#include "dpl_types.h" - -#include "sched.h" -#include "thread.h" +#include "os/os_task.h" #ifdef __cplusplus extern "C" { @@ -33,13 +30,13 @@ extern "C" { * @brief dpl task wrapper */ struct dpl_task { - kernel_pid_t pid; /**< the process id */ + struct os_task t; /**< os task */ }; /** * @brief dpl task function */ -typedef thread_task_func_t dpl_task_func_t; +typedef os_task_func_t dpl_task_func_t; /** * @brief Initialize a task. @@ -60,28 +57,39 @@ typedef thread_task_func_t dpl_task_func_t; * * @return 0 on success, non-zero on failure. */ -int dpl_task_init(struct dpl_task *t, const char *name, dpl_task_func_t func, +static inline int dpl_task_init(struct dpl_task *t, const char *name, dpl_task_func_t func, void *arg, uint8_t prio, dpl_time_t sanity_itvl, - dpl_stack_t *stack_bottom, uint16_t stack_size); - + dpl_stack_t *stack_bottom, uint16_t stack_size) +{ + return os_task_init(&t->t, name, func, arg, prio, sanity_itvl, stack_bottom, stack_size); +} /** * @brief removes specified task * * NOTE: This interface is currently experimental and not ready for common use */ -int dpl_task_remove(struct dpl_task *t); +static inline int dpl_task_remove(struct dpl_task *t) +{ + return os_task_remove(&t->t); +} /** * @brief Return the number of tasks initialized. * * @return number of tasks initialized */ -uint8_t dpl_task_count(void); +static inline uint8_t dpl_task_count(void) +{ + return os_task_count(); +} /** * @brief Lets current thread yield. */ -void dpl_task_yield(void); +static inline void dpl_task_yield(void) +{ + return os_task_yield(); +} #ifdef __cplusplus } diff --git a/pkg/uwb-core/include/dpl/dpl_time.h b/pkg/uwb-core/include/dpl/dpl_time.h index 192ccc5dd9..4432bf1ea9 100644 --- a/pkg/uwb-core/include/dpl/dpl_time.h +++ b/pkg/uwb-core/include/dpl/dpl_time.h @@ -20,17 +20,12 @@ #ifndef DPL_DPL_TIME_H #define DPL_DPL_TIME_H -#include "xtimer.h" +#include "os/os_time.h" #ifdef __cplusplus extern "C" { #endif -/** - * @brief DPL ticks per seconds - */ -#define DPL_TICKS_PER_SEC (XTIMER_HZ) - /** * @brief Returns the low 32 bits of cputime. * @@ -38,7 +33,7 @@ extern "C" { */ static inline dpl_time_t dpl_time_get(void) { - return xtimer_now().ticks32; + return os_time_get(); } /** @@ -51,8 +46,7 @@ static inline dpl_time_t dpl_time_get(void) */ static inline dpl_error_t dpl_time_ms_to_ticks(uint32_t ms, dpl_time_t *out_ticks) { - *out_ticks = xtimer_ticks_from_usec(ms * US_PER_MS).ticks32; - return DPL_OK; + return (dpl_error_t) os_time_ms_to_ticks(ms, out_ticks); } /** @@ -65,9 +59,7 @@ static inline dpl_error_t dpl_time_ms_to_ticks(uint32_t ms, dpl_time_t *out_tick */ static inline dpl_error_t dpl_time_ticks_to_ms(dpl_time_t ticks, uint32_t *out_ms) { - xtimer_ticks32_t val = {.ticks32 = ticks}; - *out_ms = xtimer_usec_from_ticks(val) * US_PER_MS; - return DPL_OK; + return (dpl_error_t) os_time_ticks_to_ms(ticks, out_ms); } /** @@ -79,7 +71,7 @@ static inline dpl_error_t dpl_time_ticks_to_ms(dpl_time_t ticks, uint32_t *out_ */ static inline dpl_time_t dpl_time_ms_to_ticks32(uint32_t ms) { - return xtimer_ticks_from_usec(ms * US_PER_MS).ticks32; + return os_time_ms_to_ticks32(ms); } /** @@ -91,8 +83,7 @@ static inline dpl_time_t dpl_time_ms_to_ticks32(uint32_t ms) */ static inline dpl_time_t dpl_time_ticks_to_ms32(dpl_time_t ticks) { - xtimer_ticks32_t val = {.ticks32 = ticks}; - return xtimer_usec_from_ticks(val) * US_PER_MS; + return os_time_ticks_to_ms32(ticks); } /** @@ -102,8 +93,7 @@ static inline dpl_time_t dpl_time_ticks_to_ms32(dpl_time_t ticks) */ static inline void dpl_time_delay(dpl_time_t ticks) { - xtimer_ticks32_t val = {.ticks32 = ticks}; - xtimer_tsleep32((xtimer_ticks32_t) val); + return os_time_delay(ticks); } #ifdef __cplusplus diff --git a/pkg/uwb-core/include/dpl/dpl_types.h b/pkg/uwb-core/include/dpl/dpl_types.h index a8d9eeb767..4009bf0c89 100644 --- a/pkg/uwb-core/include/dpl/dpl_types.h +++ b/pkg/uwb-core/include/dpl/dpl_types.h @@ -23,6 +23,8 @@ #include #include +#include "os/os_types.h" + #ifdef __cplusplus extern "C" { #endif @@ -38,26 +40,26 @@ extern "C" { * @name Macro to wait forever on events and mutexes * @{ */ -#define DPL_TIMEOUT_NEVER (UINT32_MAX) -#define DPL_WAIT_FOREVER (DPL_TIMEOUT_NEVER) +#define DPL_TIMEOUT_NEVER (OS_TIMEOUT_NEVER) +#define DPL_WAIT_FOREVER (OS_WAIT_FOREVER) /** @} */ /** * @name Decawave porting layer (DPL) stack alignment requirement * @{ */ -#define DPL_STACK_ALIGNMENT (4) +#define DPL_STACK_ALIGNMENT (OS_ALIGNMENT) /** @} */ /** * @brief dpl time type */ -typedef uint32_t dpl_time_t; +typedef os_time_t dpl_time_t; /** * @brief dpl stack buffer type */ -typedef char dpl_stack_t; +typedef os_stack_t dpl_stack_t; /** * @brief dpl float 32 type diff --git a/pkg/uwb-core/include/mcu/mcu.h b/pkg/uwb-core/include/dpl/queue.h similarity index 83% rename from pkg/uwb-core/include/mcu/mcu.h rename to pkg/uwb-core/include/dpl/queue.h index e58aa6c3ed..84e9da9ae1 100644 --- a/pkg/uwb-core/include/mcu/mcu.h +++ b/pkg/uwb-core/include/dpl/queue.h @@ -17,17 +17,17 @@ * @} */ -#ifndef MCU_MCU_H -#define MCU_MCU_H +#ifndef DPL_QUEUE_H +#define DPL_QUEUE_H + +#include "os/os_queue.h" #ifdef __cplusplus extern "C" { #endif -/* empty header */ - #ifdef __cplusplus } #endif -#endif /* MCU_MCU_H */ +#endif /* DPL_QUEUE_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_twr_ds.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ds.h similarity index 90% rename from pkg/uwb-core/include/syscfg/syscfg_twr_ds.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ds.h index 54345c88ac..350b64c6c6 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_twr_ds.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ds.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_TWR_DS_H -#define SYSCFG_SYSCFG_TWR_DS_H +#ifndef DPL_SYSCFG_SYSCFG_TWR_DS_H +#define DPL_SYSCFG_SYSCFG_TWR_DS_H #ifdef __cplusplus extern "C" { @@ -50,4 +50,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_TWR_DS_H */ +#endif /* DPL_SYSCFG_SYSCFG_TWR_DS_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_twr_ds_ext.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ds_ext.h similarity index 90% rename from pkg/uwb-core/include/syscfg/syscfg_twr_ds_ext.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ds_ext.h index 9163686515..36a3fc7fcb 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_twr_ds_ext.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ds_ext.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_TWR_DS_EXT_H -#define SYSCFG_SYSCFG_TWR_DS_EXT_H +#ifndef DPL_SYSCFG_SYSCFG_TWR_DS_EXT_H +#define DPL_SYSCFG_SYSCFG_TWR_DS_EXT_H #ifdef __cplusplus extern "C" { @@ -50,4 +50,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_TWR_DS_EXT_H */ +#endif /* DPL_SYSCFG_SYSCFG_TWR_DS_EXT_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_twr_ss.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss.h similarity index 90% rename from pkg/uwb-core/include/syscfg/syscfg_twr_ss.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss.h index e730ecba8d..55c8a41126 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_twr_ss.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_TWR_SS_H -#define SYSCFG_SYSCFG_TWR_SS_H +#ifndef DPL_SYSCFG_SYSCFG_TWR_SS_H +#define DPL_SYSCFG_SYSCFG_TWR_SS_H #ifdef __cplusplus extern "C" { @@ -50,4 +50,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_TWR_SS_H */ +#endif /* DPL_SYSCFG_SYSCFG_TWR_SS_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_twr_ss_ack.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss_ack.h similarity index 90% rename from pkg/uwb-core/include/syscfg/syscfg_twr_ss_ack.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss_ack.h index 5371159033..e1af338fad 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_twr_ss_ack.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss_ack.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_TWR_SS_ACK_H -#define SYSCFG_SYSCFG_TWR_SS_ACK_H +#ifndef DPL_SYSCFG_SYSCFG_TWR_SS_ACK_H +#define DPL_SYSCFG_SYSCFG_TWR_SS_ACK_H #ifdef __cplusplus extern "C" { @@ -50,4 +50,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_TWR_SS_ACK_H */ +#endif /* DPL_SYSCFG_SYSCFG_TWR_SS_ACK_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_twr_ss_ext.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss_ext.h similarity index 89% rename from pkg/uwb-core/include/syscfg/syscfg_twr_ss_ext.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss_ext.h index 3fe15820e8..4d3b335d3f 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_twr_ss_ext.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_twr_ss_ext.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_TWR_SS_EXT_H -#define SYSCFG_SYSCFG_TWR_SS_EXT_H +#ifndef DPL_SYSCFG_SYSCFG_TWR_SS_EXT_H +#define DPL_SYSCFG_SYSCFG_TWR_SS_EXT_H #ifdef __cplusplus extern "C" { @@ -50,4 +50,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_TWR_SS_EXT_H */ +#endif /* DPL_SYSCFG_SYSCFG_TWR_SS_EXT_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_uwb.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_uwb.h similarity index 95% rename from pkg/uwb-core/include/syscfg/syscfg_uwb.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_uwb.h index 48ac7b849d..3ebe026879 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_uwb.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_uwb.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_UWB_H -#define SYSCFG_SYSCFG_UWB_H +#ifndef DPL_SYSCFG_SYSCFG_UWB_H +#define DPL_SYSCFG_SYSCFG_UWB_H #ifdef __cplusplus extern "C" { @@ -50,7 +50,7 @@ extern "C" { * @brief Enable init messages showing each package has been initialised */ #ifndef MYNEWT_VAL_UWB_PKG_INIT_LOG -#define MYNEWT_VAL_UWB_PKG_INIT_LOG (1) +#define MYNEWT_VAL_UWB_PKG_INIT_LOG (0) #endif /** @@ -141,4 +141,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_UWB_H */ +#endif /* DPL_SYSCFG_SYSCFG_UWB_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_uwb_rng.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_uwb_rng.h similarity index 91% rename from pkg/uwb-core/include/syscfg/syscfg_uwb_rng.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_uwb_rng.h index 572ceccad6..d56f75c93d 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_uwb_rng.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_uwb_rng.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_UWB_RNG_H -#define SYSCFG_SYSCFG_UWB_RNG_H +#ifndef DPL_SYSCFG_SYSCFG_UWB_RNG_H +#define DPL_SYSCFG_SYSCFG_UWB_RNG_H #ifdef __cplusplus extern "C" { @@ -64,4 +64,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_UWB_RNG_H */ +#endif /* DPL_SYSCFG_SYSCFG_UWB_RNG_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg_uwbcfg.h b/pkg/uwb-core/include/dpl_syscfg/syscfg_uwbcfg.h similarity index 97% rename from pkg/uwb-core/include/syscfg/syscfg_uwbcfg.h rename to pkg/uwb-core/include/dpl_syscfg/syscfg_uwbcfg.h index 543a746784..45e27a7e9c 100644 --- a/pkg/uwb-core/include/syscfg/syscfg_uwbcfg.h +++ b/pkg/uwb-core/include/dpl_syscfg/syscfg_uwbcfg.h @@ -18,8 +18,8 @@ * @} */ -#ifndef SYSCFG_SYSCFG_UWBCFG_H -#define SYSCFG_SYSCFG_UWBCFG_H +#ifndef DPL_SYSCFG_SYSCFG_UWBCFG_H +#define DPL_SYSCFG_SYSCFG_UWBCFG_H #ifdef __cplusplus extern "C" { @@ -238,4 +238,4 @@ extern "C" { } #endif -#endif /* SYSCFG_SYSCFG_UWBCFG_H */ +#endif /* DPL_SYSCFG_SYSCFG_UWBCFG_H */ diff --git a/pkg/uwb-core/include/log/dpl_log.h b/pkg/uwb-core/include/log/dpl_log.h deleted file mode 100644 index 34ab483832..0000000000 --- a/pkg/uwb-core/include/log/dpl_log.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief System logging header for uwb-core - * - * @author Francisco Molina - * @} - */ - -#ifndef LOG_DPL_LOG_H -#define LOG_DPL_LOG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "log.h" - -/** - * @name Logging convenience defines wrappers - * @{ - */ -#define LOG_WARN(...) LOG(LOG_WARNING, __VA_ARGS__) -#define LOG_CRITICAL(...) LOG(LOG_ERROR, __VA_ARGS__) -#define log_register(__X, __Y, __Z, __A, __B) {} -/** @} */ - -/** - * @brief Empty log structure - */ -struct log { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* LOG_DPL_LOG_H */ diff --git a/pkg/uwb-core/include/os/os.h b/pkg/uwb-core/include/os/os.h deleted file mode 100644 index c9cff4a40e..0000000000 --- a/pkg/uwb-core/include/os/os.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief Abstraction layer for RIOT adaption - * - * @author Francisco Molina - * @} - */ -#ifndef OS_OS_H -#define OS_OS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* OS_OS_H */ diff --git a/pkg/uwb-core/include/os/os_dev.h b/pkg/uwb-core/include/os/os_dev.h deleted file mode 100644 index f1068749fb..0000000000 --- a/pkg/uwb-core/include/os/os_dev.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief Abstraction layer for RIOT adaption - * - * @author Francisco Molina - * @} - */ -#ifndef OS_OS_DEV_H -#define OS_OS_DEV_H - -#include "dpl/dpl.h" -#include "dpl/queue.h" - -#include "net/ieee802154.h" -#include "net/netdev.h" -#include "net/netdev/ieee802154.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Device structure. - */ -struct os_dev { - netdev_ieee802154_t netdev; /**< Netdev parent struct */ -}; - -/** - * @brief Unused define, void cast - */ -#define OS_DEV_SETHANDLERS(__dev, __open, __close) \ - (void) __dev; \ - (void) __open; \ - (void) __close; - -#ifdef __cplusplus -} -#endif - -#endif /* OS_OS_DEV_H */ diff --git a/pkg/uwb-core/include/stats/stats.h b/pkg/uwb-core/include/stats/stats.h deleted file mode 100644 index 1be9452c1c..0000000000 --- a/pkg/uwb-core/include/stats/stats.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief Abstraction layer for RIOT adaption - * - * @author Francisco Molina - * @} - */ - -#ifndef STATS_STATS_H -#define STATS_STATS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* empty header */ - -#ifdef __cplusplus -} -#endif - -#endif /* STATS_STATS_H */ diff --git a/pkg/uwb-core/include/syscfg/syscfg.h b/pkg/uwb-core/include/syscfg/syscfg.h deleted file mode 100644 index 7d412928b7..0000000000 --- a/pkg/uwb-core/include/syscfg/syscfg.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief uwb-core system configurations - * - * @author Francisco Molina - * @} - */ - -#ifndef SYSCFG_SYSCFG_H -#define SYSCFG_SYSCFG_H - -#include "kernel_defines.h" - -/** - * @name MyNewt header inclusion macro definitions - * @{ - * - * This macro exists to ensure code includes this header when needed. If code - * checks the existence of a setting directly via ifdef without including this - * header, the setting macro will silently evaluate to 0. In contrast, an - * attempt to use these macros without including this header will result in a - * compiler error. - */ -#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name -#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val -/** @} */ - - -/*** @decawave-uwb-core/hw/drivers/uwb */ -#include "syscfg_uwb.h" - -/*** @decawave-uwb-core/lib/twr_ds */ -#include "syscfg_twr_ds.h" - -/*** @decawave-uwb-core/lib/twr_ds_ext */ -#include "syscfg_twr_ds_ext.h" - -/*** @decawave-uwb-core/lib/twr_ss */ -#include "syscfg_twr_ss.h" - -/*** @decawave-uwb-core/lib/twr_ss_ack */ -#include "syscfg_twr_ss_ack.h" - -/*** @decawave-uwb-core/lib/twr_ss_ext */ -#include "syscfg_twr_ss_ext.h" - -/*** @decawave-uwb-core/lib/uwb_rng */ -#include "syscfg_uwb_rng.h" - -/*** @decawave-uwb-core/sys/uwbcfg */ -#include "syscfg_uwbcfg.h" - -/*** @decawave-uwb-dw1000/hw/drivers/uwb/uwb_dw1000 */ -#include "syscfg_uwb_dw1000.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SYSCFG_SYSCFG_H */ diff --git a/pkg/uwb-core/include/sysinit/sysinit.h b/pkg/uwb-core/include/sysinit/sysinit.h deleted file mode 100644 index c340c1c2fc..0000000000 --- a/pkg/uwb-core/include/sysinit/sysinit.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2020 Inria - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup pkg_uwb_core - * @{ - * - * @file - * @brief sysinit abstraction layer for RIOT adaption - * - * @author Francisco Molina - * @} - */ - -#ifndef SYSINIT_SYSINIT_H -#define SYSINIT_SYSINIT_H - -#include "assert.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief DPL assert macro - */ -#define SYSINIT_PANIC_ASSERT(rc) assert(rc); - -#ifdef __cplusplus -} -#endif - -#endif /* SYSINIT_SYSINIT_H */ diff --git a/pkg/uwb-core/patches/0001-uwb-uwb.c-use-RIOT-specific-uwb_dev_idx_lookup.patch b/pkg/uwb-core/patches/0001-uwb-uwb.c-use-RIOT-specific-uwb_dev_idx_lookup.patch index 0af7be3d937e4b7a6b56c8eabce6e475ada933d3..8b46dc0c65a4443d75a1aa87768f50f8901f1247 100644 GIT binary patch delta 84 zcmbQtHk(b?ttdZN!6+#u(by~{H8su1z{JcrG1bJ<(#X=n+|)3|FxAxDG%Y#Nz|zFR oV4`jnqv^yIXW1%uTZE6bb}EiEE0~5@0M}+yDKZ zo(C`h1{6tAN~+c@6(7L7(B0GBXS!$fYB9fJfgjjG+Yg8KXlS)vr)hV`e#;M?_ShY} z4aaQ+9k*pS+1vSyorl-VZZpd|T;rpTE96DXLk6%{hd^!Ag7{rI{UqAH*M?W&>Y5R9J zoeZDG9~a(}Ll(~b;WT7X?8gzCU&oXA%%4s_RVoJu2bHAYD0&(#0$yhn)dN<1ePIoo z?dvZzAYa*bK1IR!qWT5JSYzA)yZ9leSd-o#q>^fNPrFGNGxGkPpmE$^|UH*dC> zUF5pt*U&F|YsuaWoynTU9!;I)JEGs(!>#B{)HHTPge`Oyr7VofSjfbar4*z}rCo6T z8T#@3;6p;ZD59U*Bk`eih=Mw+M6p$!nL5%111%T?qiJH5D7r;wS-B9+q;kP9=jgF? z^3j+!k_j}LkqP-*Bj6Y2ijJhn%a4pOCash*FCnMhVdKd(j975#&o06dv`N!ulUWol zNEt-c{kVN&URK`n%a`n+Y1bggcz0a(@@0knEu3Mz>1SpCZ<8^5``c;% zmx1@cy_4$TmoxA9+&dri2IqT~eg5g4_m2j2>1h(xudYF;u zXX*n_phnCIcHBQYF_vQ&o<_!J;K3*yPi7%gg!kT@9#uW>*F8y8`kARyV{{i4!)X+* zs{i>b72-UHAtA0!0ydn_r)+WKDUx`>uo}gSWe~IF$Dub0|6or@?Bg10B$u!Jz?;nC za546S5Cwu^wD+vSl2%KLUZDNxU%#{G>~n==vhCC`)Al=Eh$eo^L9JCik>9V>^MNLE zE2Q(_7U?wK&kKOw8A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k%ZPr%|)kpm!t+_kgDX%}nrU~T&U z89R~0Q)u8K3tM1$w0mlyB?$aR6Y&qfZFgJlxNIp*_`eAtD#Dgr>twQU_Qe_}V1T6L z65Iv0p#J(NVdSgtts5t008EH7Bj9?H_T?GtE zQmu5pm;ezuO2&OabmM;0(oE7#_Wiz7)3^_z38fhq6=h8MB4%);5juyCNY*xmL^jTw zgEN9NniEL0oAfEauMq$q3{ysgjJcp(3SCy*u~b{X=n%Zp$4|bZ}zH=~@~mHK(HB za7d$(`VAtdz1wXgw;Zc(<8dcwce-oXskDg|#wjht{SUF~?1%`+);aC^6vP6|8W|X_ z!_VC67S>1;4R&{TgHv{e&p~X&>!^Qnf}HB!4=4R&Ed@V&*w;}woni+A&WT&_1=w&( zXWK>7d5m+&un7&v$Q6$lv&!PI1xJCjMBbgDYx;VsC?nmNVXN7+#x00P({EYhlEc0r zf+ejKB&4Jq2?-7mL}&u<4lRwPi4MnadavJ}zph5LB^(NMY1=Is8% z9-Myb7-%t;!z)us4V{Wp-%|6iq7Gj|DjxElU-l&q!JlX=u|W-=yL; zE)NcVPkgeSo~}-IQ9H5y&f8*P19DB?(PTd3-fvgr%3y;r{{IN3mF`+`!kXMFzF|5! z9UBIfN=hSD?sCE3(l=X^lH)zxp7;+YnS=D1*-H%?y(?|5rstgL(uhTAtxR!)wp`8B z1WnAK^prELI-ej#uPdpXB$B~y^J>M!8F5_;{pQngxcDmx+=d>O~ zYJ<(bf;an4vLG5#^knP(8=FbBq8&e9cZU*LI$P-B%BPCFn~W-hBKTDatoT1IApv(R zz5&L;!I!%XYOPPj%$8|L%yJgtABzPOI^%pY8)EPCDBbp4)E!#!aZu^yTBIBP4TW$PHEmm=`-=l6-D*q1}WAthO diff --git a/pkg/uwb-core/patches/0003-lib-tofdb-use-DPL_ENOENT-instead-of-OS_ENOENT.patch b/pkg/uwb-core/patches/0003-lib-tofdb-use-DPL_ENOENT-instead-of-OS_ENOENT.patch deleted file mode 100644 index 774f3d5191ac916a1bddf8dd267a80d32bdd37c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 640 zcmZ`$(Q4Z;6n)oMoX4h)97(a`#4ROdZ5V883hCPz!IorK!*kI<6u}NUH-}7c-`8YU0y51-l2Z{8670~I zKdlZqzCYi;eEN*#BKv{Hm5b0;rd;IcPZkf)UyqMZ`^TpjIDZPZFla065C2HUIOpub zb?WrlA8Y)9LPTAO$~6}HweYnyG}91eyWm=X70m{0Y-2~rXN(zFRp7jK0mWjP=Q6qc zKhK;u_BZTGuZ2wGI5SzgNfe|IwCrKjj}loFMffOny9HP4d4_0w2|6DzZs}OtaHQ(0 zCrYl4G_o<>90Ob`g4fiXFPki!SKtM<{@#`Pn;} R_Ft$$Q5;OgY8?y4{sN4bw_*SQ diff --git a/pkg/uwb-core/patches/0007-lib-uwb_rng-always-set-rssi-to-vrssi-0.patch b/pkg/uwb-core/patches/0003-lib-uwb_rng-always-set-rssi-to-vrssi-0.patch similarity index 90% rename from pkg/uwb-core/patches/0007-lib-uwb_rng-always-set-rssi-to-vrssi-0.patch rename to pkg/uwb-core/patches/0003-lib-uwb_rng-always-set-rssi-to-vrssi-0.patch index 9277b171f463565fb512f7d84f2032a74d6c4e84..ae7f32636560c6a015f371643907d52c672859da 100644 GIT binary patch delta 61 zcmX@ab%;yXttdZN!Ne>jEh#P4$kfy@#WXF&&>$t%JSD}#($p-`ILXM+Al1yk*dW=& QWTI{bv$4ME#uc+z07S68|~=E4Fmn7%RxOFxX&g?u`g zd)wahS>?!0)jkd9sz$rik1nx#r$NouesgEP(WK2rv(cyw=A(ZrFWskKUUi0tFQ`?2 z@*B;fI1R!{-JebO$@P7TgD9nOFjYyVvbD8Uv1ioz%X$!c)48weUKEaliTSmCP9JEu z{ggIW|E!>s#9p@8BkSh_(cZ46Q=uKr3wh^mI8lC$T2FQ;2onXiqcEv%u2;y5738Oj z$X5hG+pX4}nZDa%o6}0g55{BK+L{C@xphl_pVrRk&QmL)x)P~vi7G+ptM_mZ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Fz*&uF@edls)eRn}uYRP*zcwBhgy9)W0`ZU$ia+vtsYHML zQH#QylxXlQ=IICAUwrr=>^-AqX&Mt;u^kUvTk@Y9RdyuWSVu`KFZ3*tK9ZV3u_ew} z$)zn9oblJr%U*xM;A=h9`MI=;S-2~saHu`_(|uWOwoAJfcx|@J%<|aha|XLom} z#O?;an3L#QE&IX=M`*MCZY)^v|8}eB)a_R8*8gR{7Ul&A7R={(z~*1gvwlupWLmR~ zYBGz&<@n>s*rX;s%Z~UNK=3~Nv%=M^ctDtYv+F8Xv?kQ;4QxJ92fDa!wAfpsY^Y{u gGnfQOW~Q6LZm*AW7TuP{u)9KobobjLwtneVcF(HLk3OujW9f;}K z(ZB5c(hkw4z#kCBkz{f1`&{zbe1X6yopC-GzDy;K1NO7V Ab^rhX diff --git a/pkg/uwb-core/patches/0005-hw-drivers-uwb-include-uwb-add-UWB_ROLE_TAG-role.patch b/pkg/uwb-core/patches/0005-hw-drivers-uwb-include-uwb-add-UWB_ROLE_TAG-role.patch new file mode 100644 index 0000000000000000000000000000000000000000..196b545a5a85c97f3db74d46b80b343b6d5667a4 GIT binary patch literal 911 zcma)4T~FIE6n*!vIMZH0A&HZwO_rgFtiX6!OGTOXFin-?+)$6yMu`JV+y46;7!Par zfn{0O);;H*d#+Dgvq7DuRU}4IWUrzqD<|VbjABV*oYhImM`@byB$iQ%nbBC%4P3~1 z{;&~q9V|^D^t-7VQ3;Vk=R9ZHDMMIoJR24pae7m|he}A&N zEZ(6t4Ke2XKKlo5zy@o4M+A?#qgD+;u7$p$%ISmB9ko^&z31&SR;jv%?_Vhk5&m7w zFVgbADNN~#?h$8cOvxk&xbrbB3C@5?k__6PQHOb+hiB9}I)XpR4kqy2nZjM|*Bh#+ z2I+nSXT*x`E$Pm6yHXXtG5pwhUD?+R3}N^J$8@VC;lkP6G4G`#Qks4r0iM<#zjwXy zeGJG$6w(>kLBP$4VFx;$E>^Q*d3kc-@Q=`F3p#C#yv9s)mRi)Ngy+wh_+Tw{oojYiaWS8soeye<^{6=6;&=3gmTS`< ZxW2W~{>GHUXX~}HZqi_J5N82r>?ihT65;>= literal 0 HcmV?d00001 diff --git a/pkg/uwb-core/patches/0005-treewide-use-dpl_log.h-instaed-of-log.h-to-avoid-con.patch b/pkg/uwb-core/patches/0005-treewide-use-dpl_log.h-instaed-of-log.h-to-avoid-con.patch deleted file mode 100644 index a9388932ad4098fbd8f3ab1a9195f342211229dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2711 zcmbtW?{C^V6#eeM;%ZNt+6N?Y2n5(x!P?SJT7L-I?ZeZPl{hx_lqMBPx;?%9@$cGc zfjsJVWl@X6^|{Bn$JZxJm-#IW`biuHJnRm;gJjT;x-pl%0ga?j!(ce1T*!Xcmjcf6 z4CdkvXb7G+GJoKE9wk$x8NqZJWn2|JM_{V52;NI^YwpGscX)b0j-pa%oN5CNU{WnG z-S>d@MwE`cKD6+gN9I-hP4IFAe_c+l4o{)yhJQo36ym!|Fuf`SBzGxG^M!K*Dl5uJ zB#=v}17!};eXbG$JkMmRcu7d7(;<+m*u9Ig+o&kT(k+&J{mtR<6Q~C*eIZ!Gi+>8Y z`i@d847R>SV14}r@S$acvAdZNFq{E z2Ri$NBuYx?bQY?F$bG(w`1yIFvPArVi2B_i?mLe3lc5w6OZWOgpk;b#1%d*>ORJ2> z(DBQ*o>mqMrSi@q6E@JekXFF>?+;i9L`vGY+ zqpKEatfYHFE!=uAD{VZ-n{|7v?wp%9#MIMm>jv@7fC22fQgNtMR?X+U4K4imy>gLHkn@? z&tPvz_p#y!%;g#TbUwY!u+W_z!oYrU*oLz_*!O&e>1rFtvgR$n9Gv5|^$ zS@BZ49O$h!t>gaLbO)Ph#rpU>WoHkL5b&TM4us?IkPkx*N=zO6LvZK^o5|n6l7FI8Z_T_IF z&h??)zUnvZmW$OqHU~pO+bMm^c4f32-d18G j0bh0^t8U?6V%}ZYj`OP-J3Rg1weiOX5a00!jz`FUruQmK diff --git a/pkg/uwb-core/patches/0008-porting-dpl-add-riot-files.patch b/pkg/uwb-core/patches/0008-porting-dpl-add-riot-files.patch deleted file mode 100644 index 300f04078bffe122d88a021c589dc95da90c8f09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 37259 zcmeHQdsiDrmj63^iW<*MEHEIz1V1LpT7WP*gONuPPP{X7G>z1NHbSkmBnXq_yYKHl zs=KNmdSEAW_MFv8EYV%})_vEls@v5kadd0GIyl%1FL(M^2fh6l{hjdntKELM|NQ04 z7rhtz&+*sZ%Y)}%?e3d*(a5yJvDtlLc6MI#e`arIXLs!cXkMF>I2iQ?lU{^|!@(#p zUtfi{{OirEx7{0lyLKE*!`G%W3pdSka~|CRdT+<9ob+tbpzBWO>Z{k5THCKaSI9XfU+S*!kTU6<0buj7; zXZ^6+i$+(2YyH~3F~6AS2d~Vt%x4Y)^jZCJ7S2Kd)8`lS)!tV*1d6W!&m`{I-g}Hd z|M|t3m(Ll`8pOf8nBGk=x(@rB=GBWAW-ywBU^^O3D$mx}OfL>0KXV)PLjyq_?C&ql z^lHEk!^;7>9ImbP2Uk~SYwLP2H9^%;+3qxA*(K z{mX+_WE-a15AUj@*>Jc9C7BgEdh^C??QHItXSt&?&0w3;cyKwJ;=)i+ zn&3JP!`pB)oopMpTgdp&o1Ml{ow;TN{lP>4LBjoDdV@xTiMfyBAIueS!9xbrc`$?# z;leGG!jN%z9mIY35;`A0#DnXbsfq4KVLZ7RjL~Cgvp){5-~v~s+iibr zcR}_^<8Ak}iyOE)7=`&8tv1va{jyR$l`I^PzW>CF4;kyR}h$%Ik zhPO=Ao1c{kB147+^K}@tIM!?(&bG`9!HlhF5o`pY6 zAvE*k=!rr9e+)+mjBC%BEAs}P-#3l(PQ7(rJL{e{j*si-EGM*7fsl;4?`q$7j~lJ- zas7Sg^oy5YR5xJuKbbxp<%Y~1crdz|DU49WoCQ9wy{mW6>gQinULtPgajqA1_yHsl z$lg~6nY)awU4LI|)jG}A7f-5Bh$D~U^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i93wa1lKr2lTPQQ_a3+P7#*Aqi-Sz@#JavGJ2{FM=N#(! zyf~QeK8k;kL&y4ZMllZDq4z1qIMo-VaMyVI9*&HpQ_zz0j!kqw!WqyvgE4yS5I5}; zOAftV2AGqMam?LAG*fmQ&Q&0r<^!E34Yv2TcW}hF9<}#GZ$H6Qg23sNB6?AYoWQ8~ zaqwd=98c+tL_UmY5a8t>OtW$r8bt##KPr~!5@!+N95&|09+{`j^xR5DVQ!|=@#|{! z{{DVDU}bGb@pW}5LZ4L6AYPo_vIVlKJ;Pj#hE$0fhd<76P9wj7OOIc~>&meZ#)mAj zy7(kZkU@tFL$rD*s5J&xSz-qyI7=kBcN_3w+T8sUK2rFJIjprCZ5%7x=$z7FujvWG zdWP;XPA_Vn^YOMg7?wf*igS1|XTkB1Fgl!bi1WMo2uM2m5if>u49ikMODUT82R4~&oR5uD!C^G%vB`4OB){K>txFCZ&GE;FJ?Uw#quy|aS4KY(@3u~U^MuO0 z_1@Q$X@3xH-+Y_7hF2aA^H+z1%iKl0w)2`VIxiXIlkU?K=;c`?T%^~(Ku&XCZUTEu z-eI!#>}SXqA6$FBhga+ZhrXp1R}S{&%E7)~lYU^+F)k<|rt5#up7ETJTqKOw5nK!J zc2`g=rqb03Odszs)Dv2?c@HOj($T^vSXJ%3q(jf~@hwLIT2& zTtO()Xo#gHmCu*N0bb!qZxx_c^r75ygRav;+tYvSJoT8N78!=h3|VSC7`+gFLZx?bE3Rmet99zLz6+ zqhh_QnD^8OFY%hQAJiy4`#;$Cjrw3eG3(#hu9 Date: Mon, 5 Jul 2021 14:31:14 +0200 Subject: [PATCH 4/5] pkg/nimble: allow using mynewt-core pkg --- pkg/nimble/Makefile | 4 +- pkg/nimble/Makefile.dep | 15 +- pkg/nimble/Makefile.include | 12 +- pkg/nimble/nimble.porting.mk | 5 + pkg/nimble/npl/include/nimble/nimble_npl_os.h | 571 ++++++++++++++++++ ...rc-nimble_port-riot-initializes-time.patch | Bin 0 -> 727 bytes ...l-riot-add-namespaced-syscfg-symlink.patch | Bin 0 -> 677 bytes 7 files changed, 601 insertions(+), 6 deletions(-) create mode 100644 pkg/nimble/nimble.porting.mk create mode 100644 pkg/nimble/npl/include/nimble/nimble_npl_os.h create mode 100644 pkg/nimble/patches/0001-porting-nimble-src-nimble_port-riot-initializes-time.patch create mode 100644 pkg/nimble/patches/0002-porting-npl-riot-add-namespaced-syscfg-symlink.patch diff --git a/pkg/nimble/Makefile b/pkg/nimble/Makefile index 28e4797fbc..11d7c071a7 100644 --- a/pkg/nimble/Makefile +++ b/pkg/nimble/Makefile @@ -30,12 +30,12 @@ SUBMODS := $(filter-out $(IGNORE),$(filter nimble_%,$(USEMODULE))) all: $(SUBMODS) -# blue code and RIOT port modules +# glue code and RIOT port modules nimble_riot_contrib: $(QQ)"$(MAKE)" -C $(TDIR)/contrib/ nimble_porting_nimble: - $(QQ)"$(MAKE)" -C $(PDIR)/porting/nimble/src/ -f $(RIOTBASE)/Makefile.base MODULE=$@ + $(QQ)"$(MAKE)" -C $(PDIR)/porting/nimble/src/ -f $(RIOTPKG)/$(PKG_NAME)/nimble.porting.mk MODULE=$@ nimble_npl_riot: $(QQ)"$(MAKE)" -C $(PDIR)/porting/npl/riot/src/ -f $(RIOTBASE)/Makefile.base MODULE=$@ diff --git a/pkg/nimble/Makefile.dep b/pkg/nimble/Makefile.dep index 7a34d5942a..73f305fe65 100644 --- a/pkg/nimble/Makefile.dep +++ b/pkg/nimble/Makefile.dep @@ -11,7 +11,20 @@ USEMODULE += nimble_riot_contrib # RIOT port USEMODULE += nimble_porting_nimble -USEMODULE += nimble_npl_riot + +# NOTE: this dependency depends on inclusion order, for it to work properly +# mynewt-core should be selected as nimble backend as early as possible, +# i.e. at the application level. +ifneq (,$(filter mynewt-core,$(USEPKG))) + USEMODULE += mynewt-core_os + USEMODULE += mynewt-core_util + USEMODULE += mynewt-core_nrf5x_hal +else + # uwb-% requires mynewt-core so is incompatible with nimble_npl_riot + ifeq (,$(filter uwb%,$(USEPKG))) + USEMODULE += nimble_npl_riot + endif +endif # if nothing else is specified, we build the host and controller ifeq (,$(filter nimble_host nimble_controller,$(USEMODULE))) diff --git a/pkg/nimble/Makefile.include b/pkg/nimble/Makefile.include index b28dad166e..21e4649de3 100644 --- a/pkg/nimble/Makefile.include +++ b/pkg/nimble/Makefile.include @@ -7,7 +7,12 @@ INCLUDES += -I$(RIOTPKG)/nimble/contrib/include INCLUDES += $(NIMIBASE)/nimble/include # include the RIOT NPL headers -INCLUDES += $(NIMIBASE)/porting/npl/riot/include +ifneq (,$(filter nimble_npl_riot,$(USEMODULE))) + INCLUDES += $(NIMIBASE)/porting/npl/riot/include +else + INCLUDES += $(NIMIBASE)/porting/npl/riot/include/npl_syscfg + INCLUDES += -I$(RIOTPKG)/nimble/npl/include +endif INCLUDES += $(NIMIBASE)/porting/nimble/include # include nimble controller headers @@ -15,8 +20,9 @@ ifneq (,$(filter nimble_controller,$(USEMODULE))) INCLUDES += $(NIMIBASE)/nimble/controller/include # set environment CFLAGS += -DNIMBLE_CFG_CONTROLLER=1 - CFLAGS += -DMYNEWT_VAL_OS_CPUTIME_FREQ=32768 - + ifneq (,$(filter nimble_npl_riot,$(USEMODULE))) + CFLAGS += -DMYNEWT_VAL_OS_CPUTIME_FREQ=32768 + endif ifneq (,$(filter nimble_drivers_nrf5x,$(USEMODULE))) INCLUDES += $(NIMIBASE)/nimble/drivers/$(CPU_FAM)/include endif diff --git a/pkg/nimble/nimble.porting.mk b/pkg/nimble/nimble.porting.mk new file mode 100644 index 0000000000..84cb2c3609 --- /dev/null +++ b/pkg/nimble/nimble.porting.mk @@ -0,0 +1,5 @@ +ifneq (,$(filter mynewt-core,$(USEMODULE))) + SRC = nimble_port.c +endif + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/nimble/npl/include/nimble/nimble_npl_os.h b/pkg/nimble/npl/include/nimble/nimble_npl_os.h new file mode 100644 index 0000000000..b223388f2c --- /dev/null +++ b/pkg/nimble/npl/include/nimble/nimble_npl_os.h @@ -0,0 +1,571 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_nimble + * @{ + * + * @file + * @brief Mynewt-Nimble Porting layer wrappers + * + * @author Hauke Petersen + * @} + */ + +#ifndef NIMBLE_NIMBLE_NPL_OS_H +#define NIMBLE_NIMBLE_NPL_OS_H + +#include +#include +#include "os/os.h" +#include "mcu/mcu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name BLE NPL layer macros + * @{ + */ +#define BLE_NPL_OS_ALIGNMENT (OS_ALIGNMENT) +#define BLE_NPL_TIME_FOREVER (OS_WAIT_FOREVER) +/** @} */ + +/** + * @brief time type + */ +typedef uint32_t ble_npl_time_t; +/** + * @brief time type + */ +typedef int32_t ble_npl_stime_t; + +/** + * @brief ble_npl event wrapper + */ +struct ble_npl_event { + struct os_event ev; /**< the event */ +}; + +/** + * @brief ble_npl event queue wrapper + */ +struct ble_npl_eventq { + struct os_eventq evq; /**< the event queue */ +}; + +/** + * @brief ble_npl callout wrapper + */ +struct ble_npl_callout { + uint32_t ticks; /**< the callout set timeout */ + struct os_callout co; /**< the callout */ +}; + +/** + * @brief ble_npl mutex wrapper + */ +struct ble_npl_mutex { + struct os_mutex mu; /**< mutex */ +}; + +/** + * @brief ble_npl semaphore wrapper + */ +struct ble_npl_sem { + struct os_sem sem; /**< semaphore */ +}; + +/** + * @brief Not used in RIOT + * + * @return Always true + */ +static inline bool ble_npl_os_started(void) +{ + return true; +} + +/** + * @brief Init a event + * + * @param[in] ev pointer to event to set + * @param[in] fn event callback function + * @param[in] arg event argument + */ +static inline void ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn, + void *arg) +{ + os_event_init(&ev->ev, (os_event_fn *)fn, arg); +} + +/** + * @brief Check if event is in queue + * + * @param[in] ev event to check + * + * @return true if event is queues, false otherwise + */ +static inline bool ble_npl_event_is_queued(struct ble_npl_event *ev) +{ + return os_event_is_queued(&ev->ev); +} + +/** + * @brief Runs an event + * + * @param[in] ev event to run + */ +static inline void *ble_npl_event_get_arg(struct ble_npl_event *ev) +{ + return os_event_get_arg(&ev->ev); +} + +/** + * @brief Set the vent arg + * + * @param[in] ev event + * @param[in] arg arg to set event + */ +static inline void ble_npl_event_set_arg(struct ble_npl_event *ev, void *arg) +{ + os_event_set_arg(&ev->ev, arg); +} + +/** + * @brief Runs an event + * + * @param[in] ev event to run + */ +static inline void ble_npl_event_run(struct ble_npl_event *ev) +{ + os_event_run(&ev->ev); +} + +/** + * @brief Initialize the event queue + * + * @param[in] evq The event queue to initialize + */ +static inline void ble_npl_eventq_init(struct ble_npl_eventq *evq) +{ + os_eventq_init(&evq->evq); +} + +/** + * @brief Check whether the event queue is initialized. + * + * @param[in] evq the event queue to check + */ +static inline int ble_npl_eventq_inited(struct ble_npl_eventq *evq) +{ + return os_eventq_inited(&evq->evq); +} + +/** + * @brief Deinitialize an event queue + * + * @note Not supported in RIOT + * + * @param[in] evq the event queue to deinit + */ +static inline void ble_npl_eventq_deinit(struct ble_npl_eventq *evq) +{ + (void)evq; + /* Can't deinit an eventq in RIOT */ +} + +/** + * @brief Get next event from event queue, blocking. + * + * @param[in] evq the event queue to pull an event from + * @param[in] tmo timeout, NPL_TIME_FOREVER to block, 0 to return immediately + * + * @return the event from the queue + */ +static inline struct ble_npl_event *ble_npl_eventq_get(struct ble_npl_eventq *evq, + ble_npl_time_t tmo) +{ + return (struct ble_npl_event *)os_eventq_get(&evq->evq, tmo); +} + +/** + * @brief Get next event from event queue, non-blocking + * + * @param[in] evq the event queue to pull an event from + * + * @return event from the queue, or NULL if none available. + */ +static inline struct ble_npl_event *ble_npl_eventq_get_no_wait(struct ble_npl_eventq *evq) +{ + return (struct ble_npl_event *)os_eventq_get_no_wait(&evq->evq); +} + +/** + * @brief Put an event on the event queue. + * + * @param[in] evq event queue + * @param[in] ev event to put in queue + */ +static inline void ble_npl_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev) +{ + os_eventq_put(&evq->evq, &ev->ev); +} + +/** + * @brief Remove an event from the queue. + * + * @param[in] evq event queue to remove the event from + * @param[in] ev event to remove from the queue + */ +static inline void ble_npl_eventq_remove(struct ble_npl_eventq *evq, struct ble_npl_event *ev) +{ + os_eventq_remove(&evq->evq, &ev->ev); +} + +/** + * @brief Gets and runs an event from the queue callback. + * + * @param[in] evq The event queue to pull the item off. + */ +static inline void ble_npl_eventq_run(struct ble_npl_eventq *evq) +{ + os_eventq_run(&evq->evq); +} + +/** + * @brief Check if queue is empty + * + * @param[in] evq the event queue to check + * + * @return true if empty, false otherwise + */ +static inline bool ble_npl_eventq_is_empty(struct ble_npl_eventq *evq) +{ + return os_eventq_is_empty(&evq->evq); +} + +/** + * @brief Initializes a mutex object. + * + * @param[out] mu pre-allocated mutex structure, must not be NULL. + */ +static inline ble_npl_error_t ble_npl_mutex_init(struct ble_npl_mutex *mu) +{ + return (ble_npl_error_t)os_mutex_init(&mu->mu); +} + +/** + * @brief Pend (wait) for a mutex. + * + * @param[in] mu Pointer to mutex. + * @param[in] timeout Timeout, in os ticks. + * A timeout of 0 means do not wait if not available. + * A timeout of OS_TIMEOUT_NEVER means wait forever. + * + * @return ble_npl_error_t + * BLE_NPL_INVALID_PARM mutex passed in was NULL + * BLE_NPL_OK no error + */ +static inline ble_npl_error_t ble_npl_mutex_pend(struct ble_npl_mutex *mu, ble_npl_time_t timeout) +{ + return (ble_npl_error_t)os_mutex_pend(&mu->mu, timeout); +} + +/** + * + * @brief Release a mutex. + * + * @return ble_npl_error_t + * BLE_NPL_INVALID_PARM mutex was NULL + * BLE_NPL_OK no error + */ +static inline ble_npl_error_t ble_npl_mutex_release(struct ble_npl_mutex *mu) +{ + return (ble_npl_error_t)os_mutex_release(&mu->mu); +} + +/** + * @brief Initialize a semaphore + * + * @param[in] sem pointer to semaphore + * @param[in] tokens # of tokens the semaphore should contain initially. + * + * @return ble_npl_error_t + * BLE_NPL_INVALID_PARM Semaphore passed in was NULL. + * BLE_NPL_OK no error. + */ +static inline ble_npl_error_t ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens) +{ + return (ble_npl_error_t)os_sem_init(&sem->sem, tokens); +} + +/** + * @brief Pend (wait) for a semaphore. + * + * @param[in] sem pointer to semaphore. + * @param[in] timeout timeout, in os ticks. + * A timeout of 0 means do not wait if not available. + * A timeout of BLE_NPL_TIMEOUT_NEVER means wait forever. + * + * + * @return ble_npl_error_t + * BLE_NPL_INVALID_PARM semaphore passed in was NULL. + * BLE_NPL_TIMEOUT semaphore was owned by another task and timeout=0 + * BLE_NPL_OK no error + */ +static inline ble_npl_error_t ble_npl_sem_pend(struct ble_npl_sem *sem, ble_npl_time_t timeout) +{ + return (ble_npl_error_t)os_sem_pend(&sem->sem, timeout); +} + +/** + * @brief Release a semaphore. + * + * @param[in] sem pointer to the semaphore to be released + * + * @return ble_npl_error_t + * BLE_NPL_INVALID_PARM semaphore passed in was NULL. + * BLE_NPL_OK no error + */ +static inline ble_npl_error_t ble_npl_sem_release(struct ble_npl_sem *sem) +{ + return (ble_npl_error_t)os_sem_release(&sem->sem); +} + +/** + * @brief Get current semaphore's count + */ +static inline uint16_t ble_npl_sem_get_count(struct ble_npl_sem *sem) +{ + return os_sem_get_count(&sem->sem); +} + +/** + * @brief Initialize a callout. + * + * Callouts are used to schedule events in the future onto an event + * queue. Callout timers are scheduled using the ble_npl_callout_reset() + * function. When the timer expires, an event is posted to the event + * queue specified in ble_npl_callout_init(). The event argument given here + * is posted in the ev_arg field of that event. + * + * @param[out] c callout to initialize + * @param[in] q event queue to queue event in + * @param[in] e_cb callback function + * @param[in] e_arg callback function argument + */ +static inline void ble_npl_callout_init(struct ble_npl_callout *c, struct ble_npl_eventq *q, + ble_npl_event_fn *e_cb, void *e_arg) +{ + os_callout_init(&c->co, &q->evq, (os_event_fn *)e_cb, e_arg); +} + +/** + * @brief Reset the callout to fire off in 'ticks' ticks. + * + * @param[in] c callout to reset + * @param[in] ticks number of ticks to wait before posting an event + * + * @return 0 on success, non-zero on failure + */ +static inline ble_npl_error_t ble_npl_callout_reset(struct ble_npl_callout *c, ble_npl_time_t ticks) +{ + uint32_t state = os_hw_enter_critical(); + + c->ticks = ztimer_now(ZTIMER_MSEC) + ticks; + os_callout_reset(&c->co, ticks); + os_hw_exit_critical(state); + return BLE_NPL_OK; +} + +/** + * @brief Stops the callout from firing. + * + * @param[in] c the callout to stop + */ +static inline void ble_npl_callout_stop(struct ble_npl_callout *c) +{ + os_callout_stop(&c->co); +} + +/** + * @brief Check if callout is active + * + * @param[in] c the callout to check + * + * @return true if active, false otherwise + */ +static inline bool ble_npl_callout_is_active(struct ble_npl_callout *c) +{ + return ztimer_is_set(ZTIMER_MSEC, &c->co.timer); +} + +/** + * @brief Get the callout set ticks + * + * @param[in] co the callout to check + */ +static inline ble_npl_time_t ble_npl_callout_get_ticks(struct ble_npl_callout *co) +{ + return co->ticks; +} + +/** + * @brief Get the remaining ticks for callout expire + * + * @param[in] co the callout to check + * @param[in] time ignored + * + * @return remaining ticks + */ +static inline ble_npl_time_t ble_npl_callout_remaining_ticks(struct ble_npl_callout *co, + ble_npl_time_t time) +{ + (void)time; + ztimer_now_t now = ztimer_now(ZTIMER_MSEC); + return (ble_npl_time_t)(co->ticks - now); +} + +/** + * @brief Set the callout event argument + * + * @param[in] co the callout + * @param[in] arg callback function argument + */ +static inline void ble_npl_callout_set_arg(struct ble_npl_callout *co, void *arg) +{ + co->co.c_ev.arg = arg; +} + +/** + * @brief Returns the low 32 bits of cputime. + * + * @return uint32_t The lower 32 bits of cputime + */ +static inline ble_npl_time_t ble_npl_time_get(void) +{ + return os_time_get(); +} + +/** + * @brief Converts the given number of milliseconds into cputime ticks. + * + * @param[in] ms The number of milliseconds to convert to ticks + * @param[out] out_ticks The number of ticks corresponding to 'ms' + * + * @return ble_npl_error_t BLE_NPL_OK - no error + */ +static inline ble_npl_error_t ble_npl_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks) +{ + return (ble_npl_error_t)os_time_ms_to_ticks(ms, out_ticks); +} + +/** + * @brief Convert the given number of ticks into milliseconds. + * + * @param[in] ticks The number of ticks to convert to milliseconds. + * @param[out] out_ms The converted milliseconds from 'ticks' + * + * @return ble_npl_error_t BLE_NPL_OK - no error + */ +static inline ble_npl_error_t ble_npl_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms) +{ + return (ble_npl_error_t)os_time_ticks_to_ms(ticks, out_ms); +} + +/** + * @brief Converts the given number of milliseconds into cputime ticks. + * + * @param[in] ms The number of milliseconds to convert to ticks + * + * @return uint32_t The number of ticks corresponding to 'ms' + */ +static inline ble_npl_time_t ble_npl_time_ms_to_ticks32(uint32_t ms) +{ + return os_time_ms_to_ticks32(ms); +} + +/** + * @brief Convert the given number of ticks into milliseconds. + * + * @param[in] ticks The number of ticks to convert to milliseconds. + * + * @return uint32_t The number of milliseconds corresponding to 'ticks' + */ +static inline ble_npl_time_t ble_npl_time_ticks_to_ms32(ble_npl_time_t ticks) +{ + return os_time_ticks_to_ms32(ticks); +} +/** + * @brief Wait until the number of ticks has elapsed, BLOICKING. + * + * @param[in] ticks The number of ticks to wait. + */ +static inline void ble_npl_time_delay(ble_npl_time_t ticks) +{ + return os_time_delay(ticks); +} + +/** + * @brief Disable ISRs + * + * @return current isr context + */ +static inline uint32_t ble_npl_hw_enter_critical(void) +{ + return os_hw_enter_critical(); +} + +/** + * @brief Restores ISR context + * + * @param[in] ctx ISR context to restore. + */ +static inline void ble_npl_hw_exit_critical(uint32_t ctx) +{ + os_hw_exit_critical(ctx); +} + +/** + * @brief Check if is in critical section + * + * @return true, if in critical section, false otherwise + */ +static inline bool ble_npl_hw_is_in_critical(void) +{ + return os_hw_is_in_critical(); +} + +/** + * @brief Return current thread PID + * + * @return PID + */ +static inline void *ble_npl_get_current_task_id(void) +{ + return (void *)(uint32_t)thread_getpid(); +} + +/** + * @brief Set nrf5x radio ISR callback + * + * @param[in] irqn IRQ number + * @param[in] addr the ISR callback + */ +static inline void ble_npl_hw_set_isr(int irqn, void (*addr)(void)) +{ + nrf5x_hw_set_isr(irqn, addr); +} + +#ifdef __cplusplus +} +#endif + +#endif /* NIMBLE_NIMBLE_NPL_OS_H */ diff --git a/pkg/nimble/patches/0001-porting-nimble-src-nimble_port-riot-initializes-time.patch b/pkg/nimble/patches/0001-porting-nimble-src-nimble_port-riot-initializes-time.patch new file mode 100644 index 0000000000000000000000000000000000000000..2649714097cb0a11635eeaf1d8b40d9fb2b010dc GIT binary patch literal 727 zcma)(QE!_t6oudYE3VX+Mg(Gm37Ab&x-{7)k)%pfP17_XFedQ?CIV7b)ArwYfogqQ zYgv}<>+c-AZ3&UMpibDSAnWu=<6jeMRaeI%e2b4lc)xC1sZtGf^ZoR3>T6fNsN|xKMHYAPSSc#7@;FgY%HH2u+8!Ca> zF3~jDjXD@VnV3HIK4`plG@P?`G2HYw?46#eInk_8;lt7=w33izv)(jPArpy>-7eh& znYqFJ=Qnq6-$NDZD~@rTeb^V_*cYRZ=~Y{cpa+_c+K|QcdopgH!jPoDGnVH$`v+C{ zVEV< Date: Mon, 5 Jul 2021 14:31:52 +0200 Subject: [PATCH 5/5] examples/twr_aloha: use ZTIMER_MSEC --- examples/twr_aloha/Makefile | 1 + examples/twr_aloha/control.c | 13 ++++++------- examples/twr_aloha/control.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/twr_aloha/Makefile b/examples/twr_aloha/Makefile index 9a03b53c5f..88f6a82a0f 100644 --- a/examples/twr_aloha/Makefile +++ b/examples/twr_aloha/Makefile @@ -28,6 +28,7 @@ USEMODULE += uwb-core_twr_ds_ext USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps +USEMODULE += ztimer_usec # Set the device role: 0x0 for tag, 0x4 for an anchor DW1000_ROLE ?= 0x00 diff --git a/examples/twr_aloha/control.c b/examples/twr_aloha/control.c index 492584cbb6..c0cba17926 100644 --- a/examples/twr_aloha/control.c +++ b/examples/twr_aloha/control.c @@ -29,7 +29,6 @@ #include "shell_commands.h" #include "shell.h" -#include "xtimer.h" static struct dpl_callout _rng_req_callout; static uint8_t _ranging_enabled_flag; @@ -46,7 +45,7 @@ static int _range_cli_cmd(int argc, char **argv) if (!strcmp(argv[1], "start")) { printf("Start ranging\n"); - dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_US); + dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_MS); _ranging_enabled_flag = 1; } else if (!strcmp(argv[1], "stop")) { @@ -150,12 +149,12 @@ static void _slot_complete_cb(struct dpl_event *ev) } /** - * @brief An event callback to send range request every RANGE_REQUEST_T_US. + * @brief An event callback to send range request every RANGE_REQUEST_T_MS. * On every request it will switch the used ranging algorithm. */ static void uwb_ev_cb(struct dpl_event *ev) { - struct uwb_rng_instance *rng = (struct uwb_rng_instance *)ev->arg; + struct uwb_rng_instance *rng = (struct uwb_rng_instance *)ev->ev.arg; struct uwb_dev *inst = rng->dev_inst; if (inst->role & UWB_ROLE_ANCHOR) { @@ -195,7 +194,7 @@ static void uwb_ev_cb(struct dpl_event *ev) /* reset the callback if ranging is enabled */ if (_ranging_enabled_flag) { - dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_US); + dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_MS); } } @@ -211,7 +210,7 @@ void init_ranging(void) _uwb_mac_cbs.inst_ptr = rng; uwb_mac_append_interface(udev, &_uwb_mac_cbs); - uint32_t utime = xtimer_now_usec(); + uint32_t utime = ztimer_now(ZTIMER_USEC); printf("{\"utime\": %" PRIu32 ",\"exec\": \"%s\"}\n", utime, __FILE__); printf("{\"device_id\"=\"%" PRIx32 "\"", udev->device_id); @@ -235,7 +234,7 @@ void init_ranging(void) dpl_callout_init(&_rng_req_callout, dpl_eventq_dflt_get(), uwb_ev_cb, rng); - dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_US); + dpl_callout_reset(&_rng_req_callout, RANGE_REQUEST_T_MS); dpl_event_init(&_slot_event, _slot_complete_cb, rng); /* Apply config */ diff --git a/examples/twr_aloha/control.h b/examples/twr_aloha/control.h index 2c3e467d91..1d5557b4a3 100644 --- a/examples/twr_aloha/control.h +++ b/examples/twr_aloha/control.h @@ -37,8 +37,8 @@ extern "C" { /** * @brief Range request period */ -#ifndef RANGE_REQUEST_T_US -#define RANGE_REQUEST_T_US (40 * US_PER_MS) +#ifndef RANGE_REQUEST_T_MS +#define RANGE_REQUEST_T_MS (40) #endif /**