pkg/uwb-core: initial import
This commit is contained in:
parent
cc0d8a83f1
commit
3622c2da07
53
pkg/uwb-core/Makefile
Normal file
53
pkg/uwb-core/Makefile
Normal file
@ -0,0 +1,53 @@
|
||||
PKG_NAME=uwb-core
|
||||
PKG_URL=https://github.com/Decawave/uwb-core
|
||||
PKG_VERSION=8ffba63755a932a89d841872ce5bdf35b9c78777
|
||||
PKG_LICENSE=Apache-2.0
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
CFLAGS += -Wno-implicit-int
|
||||
CFLAGS += -Wno-int-conversion
|
||||
CFLAGS += -Wno-strict-prototypes
|
||||
CFLAGS += -Wno-maybe-uninitialized
|
||||
CFLAGS += -Wno-missing-braces
|
||||
CFLAGS += -Wno-missing-declarations
|
||||
CFLAGS += -Wno-missing-field-initializers
|
||||
CFLAGS += -Wno-old-style-definition
|
||||
CFLAGS += -Wno-return-type
|
||||
CFLAGS += -Wno-sign-compare
|
||||
CFLAGS += -Wno-unused-but-set-variable
|
||||
CFLAGS += -Wno-unused-parameter
|
||||
CFLAGS += -Wno-unused-variable
|
||||
CFLAGS += -fms-extensions
|
||||
|
||||
ifneq (,$(filter llvm,$(TOOLCHAIN)))
|
||||
CFLAGS += -Wno-microsoft-anon-tag
|
||||
endif
|
||||
|
||||
IGNORE_MODULES := uwb-core_dpl \
|
||||
uwb-core_config \
|
||||
uwb-core_contrib \
|
||||
#
|
||||
|
||||
UWB_CORE_MODULES := $(filter-out $(IGNORE_MODULES),$(filter uwb-core%,$(USEMODULE)))
|
||||
|
||||
UWB_CORE_PATH_dsp = lib/dsp/src
|
||||
UWB_CORE_PATH_uwb_json = lib/json/src
|
||||
UWB_CORE_PATH_uwbcfg = sys/uwbcfg/src/
|
||||
UWB_CORE_PATH_rng = lib/uwb_rng/src
|
||||
UWB_CORE_PATH_rng_math = lib/rng_math/src
|
||||
UWB_CORE_PATH_twr_ss = lib/twr_ss/src
|
||||
UWB_CORE_PATH_twr_ss_ack = lib/twr_ss_ack/src
|
||||
UWB_CORE_PATH_twr_ss_ext = lib/twr_ss_ext/src
|
||||
UWB_CORE_PATH_twr_ds = lib/twr_ds/src
|
||||
UWB_CORE_PATH_twr_ds_ext = lib/twr_ds_ext/src
|
||||
|
||||
all: $(UWB_CORE_MODULES)
|
||||
"$(MAKE)" -C $(PKG_SOURCE_DIR)/hw/drivers/uwb/src -f $(RIOTBASE)/Makefile.base MODULE=$(PKG_NAME)
|
||||
|
||||
uwb-core_config:
|
||||
"$(MAKE)" -C $(PKG_SOURCE_DIR)/porting/dpl/riot/src -f $(RIOTBASE)/Makefile.base MODULE=$@
|
||||
|
||||
uwb-core_uwbcfg: uwb-core_config
|
||||
uwb-core_%:
|
||||
"$(MAKE)" -C $(PKG_SOURCE_DIR)/$(UWB_CORE_PATH_$*) -f $(RIOTBASE)/Makefile.base MODULE=$@
|
||||
36
pkg/uwb-core/Makefile.dep
Normal file
36
pkg/uwb-core/Makefile.dep
Normal file
@ -0,0 +1,36 @@
|
||||
USEMODULE += uwb-core_dpl
|
||||
USEMODULE += uwb-core_contrib
|
||||
|
||||
DEFAULT_MODULE += auto_init_uwb-core
|
||||
|
||||
USEMODULE += sema
|
||||
USEMODULE += event_callback
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += fmt
|
||||
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
|
||||
ifneq (,$(filter uwb-core_twr_%,$(USEMODULE)))
|
||||
USEMODULE += uwb-core_rng
|
||||
endif
|
||||
|
||||
ifneq (,$(filter uwb-core_rng,$(USEMODULE)))
|
||||
USEMODULE += uwb-core_rng_math
|
||||
USEMODULE += uwb-core_dsp
|
||||
USEMODULE += uwb-core_uwb_json
|
||||
endif
|
||||
|
||||
ifneq (,$(filter uwb-core_uwbcfg,$(USEMODULE)))
|
||||
USEMODULE += uwb-core_config
|
||||
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
|
||||
22
pkg/uwb-core/Makefile.include
Normal file
22
pkg/uwb-core/Makefile.include
Normal file
@ -0,0 +1,22 @@
|
||||
INCLUDES += -I$(PKGDIRBASE)/uwb-core/hw/drivers/uwb/include/ \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/euclid/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/dsp/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/json/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/rng_math/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/twr_ss/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/twr_ss_ext/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/twr_ss_ack/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/twr_ds/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/twr_ds_ext/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/lib/uwb_rng/include \
|
||||
-I$(PKGDIRBASE)/uwb-core/porting/dpl/riot/include/ \
|
||||
-I$(PKGDIRBASE)/uwb-core/sys/uwbcfg/include \
|
||||
-I$(RIOTPKG)/uwb-core/include \
|
||||
#
|
||||
|
||||
DIRS += $(RIOTPKG)/uwb-core/dpl \
|
||||
$(RIOTPKG)/uwb-core/contrib \
|
||||
#
|
||||
|
||||
# A cflag to indicate in pkg code that we are building for RIOT
|
||||
CFLAGS += -DRIOT
|
||||
9
pkg/uwb-core/contrib/Makefile
Normal file
9
pkg/uwb-core/contrib/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
MODULE = uwb-core_contrib
|
||||
|
||||
SRC = uwb_core.c
|
||||
|
||||
ifneq (,$(filter auto_init_uwb-core,$(USEMODULE)))
|
||||
SRC += uwb_core_init.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
61
pkg/uwb-core/contrib/uwb_core.c
Normal file
61
pkg/uwb-core/contrib/uwb_core.c
Normal file
@ -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_uwb_core
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief uwb-core bootstrapping functions
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdatomic.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "event.h"
|
||||
#include "event/callback.h"
|
||||
#include "uwb_core.h"
|
||||
|
||||
#ifndef UWB_CORE_STACKSIZE
|
||||
#define UWB_CORE_STACKSIZE (THREAD_STACKSIZE_LARGE)
|
||||
#endif
|
||||
#ifndef UWB_CORE_PRIO
|
||||
#define UWB_CORE_PRIO (THREAD_PRIORITY_MAIN - 5)
|
||||
#endif
|
||||
|
||||
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 */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_queue_t *uwb_core_get_eventq(void)
|
||||
{
|
||||
return &_queue;
|
||||
}
|
||||
|
||||
void uwb_core_riot_init(void)
|
||||
{
|
||||
thread_create(_stack_uwb_core, sizeof(_stack_uwb_core),
|
||||
UWB_CORE_PRIO,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_uwb_core_thread, NULL,
|
||||
"uwb_core");
|
||||
}
|
||||
79
pkg/uwb-core/contrib/uwb_core_init.c
Normal file
79
pkg/uwb-core/contrib/uwb_core_init.c
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 bootstrapping core
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
#include "dpl/dpl.h"
|
||||
#include "uwb_core.h"
|
||||
|
||||
#include "uwb_dw1000.h"
|
||||
#include "uwb_dw1000_params.h"
|
||||
|
||||
#include "twr_ss/twr_ss.h"
|
||||
#include "twr_ss_ext/twr_ss_ext.h"
|
||||
#include "twr_ss_ack/twr_ss_ack.h"
|
||||
#include "twr_ds/twr_ds.h"
|
||||
#include "twr_ds_ext/twr_ds_ext.h"
|
||||
|
||||
static dw1000_dev_instance_t dev;
|
||||
static uint8_t _dw1000_rx_buffer[MYNEWT_VAL(UWB_RX_BUFFER_SIZE)];
|
||||
static uint8_t _dw1000_tx_buffer[MYNEWT_VAL(DW1000_HAL_SPI_BUFFER_SIZE)];
|
||||
|
||||
void uwb_core_init(void)
|
||||
{
|
||||
/* this will start the thread handling the event queue for uwb-core */
|
||||
uwb_core_riot_init();
|
||||
/* inits the dw1000 devices linked list */
|
||||
uwb_dw1000_init();
|
||||
/* set preallocated buffers to avoid malloc/calloc */
|
||||
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*/
|
||||
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();
|
||||
}
|
||||
|
||||
/* uwb configuration module */
|
||||
if (IS_USED(MODULE_UWB_CORE_UWBCFG)) {
|
||||
extern int uwbcfg_pkg_init(void);
|
||||
uwbcfg_pkg_init();
|
||||
}
|
||||
|
||||
/* 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();
|
||||
}
|
||||
}
|
||||
121
pkg/uwb-core/doc.txt
Normal file
121
pkg/uwb-core/doc.txt
Normal file
@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @defgroup pkg_uwb_core Device driver model for the Decawave Impulse Radio-Ultra Wideband (IR-UWB) transceiver(s)
|
||||
* @ingroup pkg
|
||||
* @brief Hardware and architecture agnostic platform for IoT
|
||||
* Location Based Services (LBS)
|
||||
* @see https://github.com/Decawave/uwb-core
|
||||
*/
|
||||
|
||||
# Decawave uwb-core RIOT Port
|
||||
|
||||
The distribution https://github.com/decawave/uwb-core contains the
|
||||
device driver model for the Decawave Impulse Radio-Ultra Wideband
|
||||
(IR-UWB) transceiver(s). The driver includes hardware abstraction
|
||||
layers (HAL), media access control (MAC) layer, Ranging Services (RNG).
|
||||
The uwb-core driver and RIOT combine to create a hardware and
|
||||
architecture agnostic platform for IoT Location Based Services (LBS).
|
||||
|
||||
## Abstraction details
|
||||
|
||||
uwb-core is meant as a hardware and architecture agnostic library. It
|
||||
was developed with MyNewt as its default OS, but its abstractions are
|
||||
well defined which makes it easy to use with another OS.
|
||||
|
||||
A porting layer DPL (Decawave Porting Layer) has been implemented that
|
||||
wraps around OS functionalities and modules: mutex, semaphores, threads,
|
||||
etc.. In most cases the mapping is direct although some specific
|
||||
functionalities might not be supported.
|
||||
|
||||
Since the library was used on top of mynewt most configuration values
|
||||
are prefixed with `MYNEWT_VAL_%`, all configurations can be found under
|
||||
`pkg/uwb-core/include/syscfg`.
|
||||
|
||||
In MyNewt there is always a default event thread, since we don't have
|
||||
this in RIOT when using this pkg an event thread is started which will
|
||||
run as this default event thread.
|
||||
|
||||
To work this library needs to be built on top of an UWB device
|
||||
implementing the `uwb` api (see [uwb](https://github.com/Decawave/uwb-core/tree/master/hw/drivers/uwb).
|
||||
This port uses [uwb-dw1000](https://github.com/Decawave/uwb-dw1000) as
|
||||
device driver for dw1000 modules.
|
||||
|
||||
The library can be used by directly including the different module headers.
|
||||
|
||||
## Current support
|
||||
|
||||
uwb-core comes with many utility libraries, only ranging related libraries
|
||||
are described here. For more info refer to [uwb-core](https://github.com/Decawave/uwb-core).
|
||||
|
||||
- uwb-core_uwb: The uwb-core driver implements the MAC layers and
|
||||
exports a MAC extension interface for additional services.
|
||||
In the case of this port the api implementation is provided mainly by
|
||||
the uwb-dw1000 pkg.
|
||||
|
||||
- uwb-core_rng: ranging base class, provides the api to perform ranging.
|
||||
It can use any of the twr_% ranging algorithms mentioned below,
|
||||
for details on each algorithm refer to the pertinent literature.
|
||||
|
||||
- uwb-core_twr_ss: single side two way ranging
|
||||
|
||||
- uwb-core_twr_ss_ack: : single side two way ranging using hardware
|
||||
generated ACK as the response.
|
||||
|
||||
- uwb-core_twr_ss_ext: single side two way ranging with extended frames.
|
||||
|
||||
- uwb-core_twr_ds: double side two-way ranging
|
||||
|
||||
- uwb-core_twr_ds_ext: double side wo way ranging with extended frames.
|
||||
|
||||
## Usage example
|
||||
|
||||
The most simple examples would be a tdoa blinking tag, here the device
|
||||
is considered awake.
|
||||
|
||||
```c
|
||||
// IEEE 802.15.4e standard blink
|
||||
ieee_blink_frame_t tdoa_blink_frame = {
|
||||
.fctrl = 0xC5, /* frame type (0xC5 for a blink) using 64-bit addressing */
|
||||
.seq_num = 0, /* sequence number, incremented for each new frame. */
|
||||
.long_address = 0, /* device ID */
|
||||
};
|
||||
// Set device address
|
||||
tdoa_blink_frame.long_address = udev->my_long_address;
|
||||
// Write tx data and start transmission
|
||||
uwb_write_tx(udev, tdoa_blink_frame.array, 0, sizeof(ieee_blink_frame_t));
|
||||
uwb_start_tx(udev);
|
||||
// Increase sequence number
|
||||
tdoa_blink_frame.seq_num++;
|
||||
```
|
||||
|
||||
The following can be wrapped into a timer callback to setup a blinking tag.
|
||||
|
||||
For more examples check the [uwb-apps](https://github.com/Decawave/uwb-apps)
|
||||
repository as well as [examples/twr_aloha](https://github.com/RIOT-OS/RIOT/tree/master/examples/twr-aloha)
|
||||
|
||||
## Watchout!
|
||||
|
||||
uwb-core uses anonymous structures, therefore any application using this
|
||||
pkg must also set at application level:
|
||||
|
||||
CFLAGS += -fms-extensions
|
||||
|
||||
If building with llvm then also `CFLAGS += -Wno-microsoft-anon-tag` must
|
||||
be added, although it is currently blacklisted because of missing stdatomic
|
||||
definitions.
|
||||
|
||||
## Todos
|
||||
|
||||
The uwb-core pkg comes with a wide range of feature that are currently
|
||||
untested and not supported in this port, these will be incrementally
|
||||
included:
|
||||
|
||||
- [ ] `uwb_cpp`: Clock Calibration Packet (CCP) Service
|
||||
- [ ] `tdma`: uwb-core offers TDMA support
|
||||
- [ ] `uwb_wcs`: Wireless Clock Synchronization (WCS) Service
|
||||
- [ ] `rtdoa`: Reverse Time Difference of Arrival profiles
|
||||
- [ ] `cir`: Circular impulse response
|
||||
- [ ] `nrng`: N-ranges support
|
||||
- [ ] other modules in `lib`
|
||||
|
||||
uwb-core uses dynamic allocation for some of its internal modules. It
|
||||
would be nice to make this optional when possible.
|
||||
3
pkg/uwb-core/dpl/Makefile
Normal file
3
pkg/uwb-core/dpl/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = uwb-core_dpl
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
58
pkg/uwb-core/dpl/dpl_callout.c
Normal file
58
pkg/uwb-core/dpl/dpl_callout.c
Normal file
@ -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_uwb_core
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief uwb-core DPL (Decawave Porting Layer) callout
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#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));
|
||||
}
|
||||
58
pkg/uwb-core/dpl/dpl_mutex.c
Normal file
58
pkg/uwb-core/dpl/dpl_mutex.c
Normal file
@ -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_uwb_core
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Decawave Porting Layer mutex RIOT wrapper
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
||||
60
pkg/uwb-core/dpl/dpl_sem.c
Normal file
60
pkg/uwb-core/dpl/dpl_sem.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
68
pkg/uwb-core/dpl/dpl_task.c
Normal file
68
pkg/uwb-core/dpl/dpl_task.c
Normal file
@ -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_uwb_core
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Decawave Porting Layer tasks RIOT wrapper
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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
|
||||
40
pkg/uwb-core/include/dpl/dpl.h
Normal file
40
pkg/uwb-core/include/dpl/dpl.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_H
|
||||
#define DPL_DPL_H
|
||||
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "dpl/dpl_types.h"
|
||||
#include "dpl/dpl_error.h"
|
||||
#include "dpl/dpl_eventq.h"
|
||||
#include "dpl/dpl_callout.h"
|
||||
#include "dpl/dpl_cputime.h"
|
||||
#include "dpl/dpl_mutex.h"
|
||||
#include "dpl/dpl_os.h"
|
||||
#include "dpl/dpl_sem.h"
|
||||
#include "dpl/dpl_tasks.h"
|
||||
#include "dpl/dpl_time.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_H */
|
||||
83
pkg/uwb-core/include/dpl/dpl_callout.h
Normal file
83
pkg/uwb-core/include/dpl/dpl_callout.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 abstraction
|
||||
*
|
||||
* Callout sets a timer that on expiration will post an event to an
|
||||
* event queue. This mimics the same as MyNewt callout api.
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief callout structure
|
||||
*/
|
||||
struct dpl_callout {
|
||||
xtimer_t timer; /**< timer */
|
||||
struct dpl_event c_e; /**< callout event */
|
||||
struct dpl_eventq *c_q; /**< callout event queue */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize a callout.
|
||||
*
|
||||
* Callouts are used to schedule events in the future onto an event
|
||||
* queue. Callout timers are scheduled using the dpl_callout_reset()
|
||||
* function. When the timer expires, an event is posted to the event
|
||||
* queue specified in dpl_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
|
||||
*/
|
||||
void dpl_callout_init(struct dpl_callout *c, struct dpl_eventq *q,
|
||||
dpl_event_fn *e_cb, void *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
|
||||
*/
|
||||
dpl_error_t dpl_callout_reset(struct dpl_callout *c, dpl_time_t ticks);
|
||||
|
||||
/**
|
||||
* @brief Stops the callout from firing.
|
||||
*
|
||||
* @param[in] c the callout to stop
|
||||
*/
|
||||
void dpl_callout_stop(struct dpl_callout *c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_CALLOUT_H */
|
||||
162
pkg/uwb-core/include/dpl/dpl_cputime.h
Normal file
162
pkg/uwb-core/include/dpl/dpl_cputime.h
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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) cputime abstraction
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_CPUTIME_H
|
||||
#define DPL_DPL_CPUTIME_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "hal/hal_timer.h"
|
||||
|
||||
/**
|
||||
* Returns the low 32 bits of cputime.
|
||||
*
|
||||
* @return uint32_t The lower 32 bits of cputime
|
||||
*/
|
||||
static inline uint32_t dpl_cputime_get32(void)
|
||||
{
|
||||
return xtimer_now().ticks32;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given number of microseconds into cputime ticks.
|
||||
*
|
||||
* @param usecs The number of microseconds to convert to ticks
|
||||
*
|
||||
* @return uint32_t The number of ticks corresponding to 'usecs'
|
||||
*/
|
||||
static inline uint32_t dpl_cputime_usecs_to_ticks(uint32_t usecs)
|
||||
{
|
||||
return xtimer_ticks_from_usec(usecs).ticks32;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given number of ticks into microseconds.
|
||||
*
|
||||
* @param ticks The number of ticks to convert to microseconds.
|
||||
*
|
||||
* @return uint32_t The number of microseconds corresponding to 'ticks'
|
||||
*/
|
||||
static inline uint32_t dpl_cputime_ticks_to_usecs(uint32_t ticks)
|
||||
{
|
||||
xtimer_ticks32_t val = {.ticks32 = ticks};
|
||||
return xtimer_usec_from_ticks(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the number of ticks has elapsed. This is a blocking delay.
|
||||
*
|
||||
* @param ticks The number of ticks to wait.
|
||||
*/
|
||||
static inline void dpl_cputime_delay_ticks(uint32_t ticks)
|
||||
{
|
||||
xtimer_ticks32_t val = {.ticks32 = ticks};
|
||||
xtimer_tsleep32((xtimer_ticks32_t) val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until 'usecs' microseconds has elapsed. This is a blocking delay.
|
||||
*
|
||||
* @param usecs The number of usecs to wait.
|
||||
*/
|
||||
static inline void dpl_cputime_delay_usecs(uint32_t usecs)
|
||||
{
|
||||
xtimer_usleep(usecs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a CPU timer, using the given HAL timer.
|
||||
*
|
||||
* @param timer The timer to initialize. Cannot be NULL.
|
||||
* @param fp The timer callback function. Cannot be NULL.
|
||||
* @param arg Pointer to data object to pass to timer.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a cputimer that will expire at 'cputime'. If cputime has already
|
||||
* passed, the timer callback will still be called (at interrupt context).
|
||||
*
|
||||
* NOTE: This must be called when the timer is stopped.
|
||||
*
|
||||
* @param timer Pointer to timer to start. Cannot be NULL.
|
||||
* @param cputime The cputime at which the timer should expire.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a cpu timer that will expire 'usecs' microseconds from the current
|
||||
* cputime.
|
||||
*
|
||||
* NOTE: This must be called when the timer is stopped.
|
||||
*
|
||||
* @param timer Pointer to timer. Cannot be NULL.
|
||||
* @param usecs The number of usecs from now at which the timer will expire.
|
||||
*
|
||||
* @return int 0 on success; EINVAL if timer already started or timer struct
|
||||
* invalid
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stops a cputimer from running.
|
||||
*
|
||||
* The timer is removed from the timer queue and interrupts are disabled
|
||||
* if no timers are left on the queue. Can be called even if timer is
|
||||
* not running.
|
||||
*
|
||||
* @param timer Pointer to cputimer to stop. Cannot be NULL.
|
||||
*/
|
||||
static inline void dpl_cputime_timer_stop(struct hal_timer *timer)
|
||||
{
|
||||
xtimer_remove(&timer->timer);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_CPUTIME_H */
|
||||
55
pkg/uwb-core/include/dpl/dpl_error.h
Normal file
55
pkg/uwb-core/include/dpl/dpl_error.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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) error types
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_ERROR_H
|
||||
#define DPL_DPL_ERROR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief dep error type
|
||||
*/
|
||||
typedef enum dpl_error dpl_error_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_ERROR_H */
|
||||
241
pkg/uwb-core/include/dpl/dpl_eventq.h
Normal file
241
pkg/uwb-core/include/dpl/dpl_eventq.h
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* 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) event queue wrappers
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_EVENTQ_H
|
||||
#define DPL_DPL_EVENTQ_H
|
||||
|
||||
#include <dpl/dpl_types.h>
|
||||
|
||||
#include "uwb_core.h"
|
||||
#include "event/callback.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief dpl event wrapper
|
||||
*/
|
||||
struct dpl_event
|
||||
{
|
||||
event_callback_t e; /**< the event callback */
|
||||
void *arg; /**< the event argument */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief dpl event queue wrapper
|
||||
*/
|
||||
struct dpl_eventq
|
||||
{
|
||||
event_queue_t q; /**< the event queue */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief dpl event callback function
|
||||
*/
|
||||
typedef void dpl_event_fn(struct dpl_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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if event is in queue
|
||||
*
|
||||
* @param[in] ev event to check
|
||||
*
|
||||
* @return true if event is queues, false otherwise
|
||||
*/
|
||||
static inline bool dpl_event_is_queued(struct dpl_event *ev)
|
||||
{
|
||||
return (ev->e.super.list_node.next != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Runs an event
|
||||
*
|
||||
* @param[in] ev event to run
|
||||
*/
|
||||
static inline void *dpl_event_get_arg(struct dpl_event *ev)
|
||||
{
|
||||
return ev->arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the vent arg
|
||||
*
|
||||
* @param[in] ev event
|
||||
* @param[in] arg arg to set event
|
||||
*/
|
||||
static inline void dpl_event_set_arg(struct dpl_event *ev, void *arg)
|
||||
{
|
||||
ev->arg = arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Runs an event
|
||||
*
|
||||
* @param[in] ev event to run
|
||||
*/
|
||||
static inline void dpl_event_run(struct dpl_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 dpl_eventq_init(struct dpl_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 dpl_eventq_inited(struct dpl_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 dpl_eventq_deinit(struct dpl_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
|
||||
*
|
||||
* @return the event from the queue
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get next event from event queue, non-blocking
|
||||
*
|
||||
* @return event from the queue, or NULL if none available.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put an event on the event queue.
|
||||
*
|
||||
* @param[in] evq event queue
|
||||
* @param[in] ev event to put in queue
|
||||
*/
|
||||
static inline void dpl_eventq_put(struct dpl_eventq *evq, struct dpl_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 dpl_eventq_remove(struct dpl_eventq *evq, struct dpl_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 dpl_eventq_run(struct dpl_eventq *evq)
|
||||
{
|
||||
struct dpl_event *ev = dpl_eventq_get(evq);
|
||||
dpl_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 dpl_eventq_is_empty(struct dpl_eventq *evq)
|
||||
{
|
||||
return clist_count(&(evq->q.event_list)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves the default event queue.
|
||||
*
|
||||
* As there is no default event queue in RIOT, uwb-core will start and
|
||||
* handle a default event queue.
|
||||
*
|
||||
* @return the default event queue.
|
||||
*/
|
||||
static inline struct dpl_eventq * dpl_eventq_dflt_get(void)
|
||||
{
|
||||
return (struct dpl_eventq*) uwb_core_get_eventq();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_EVENTQ_H */
|
||||
74
pkg/uwb-core/include/dpl/dpl_mutex.h
Normal file
74
pkg/uwb-core/include/dpl/dpl_mutex.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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) mutex wrappers
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_MUTEX_H
|
||||
#define DPL_DPL_MUTEX_H
|
||||
|
||||
#include "dpl_types.h"
|
||||
#include "dpl_error.h"
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief dpl mutex wrapper
|
||||
*/
|
||||
struct dpl_mutex {
|
||||
mutex_t mutex; /**< the mutex */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initializes a mutex object.
|
||||
*
|
||||
* @param[out] mu pre-allocated mutex structure, must not be NULL.
|
||||
*/
|
||||
dpl_error_t dpl_mutex_init(struct dpl_mutex *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 dpl_error_t
|
||||
* 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);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Release a mutex.
|
||||
*
|
||||
* @return dpl_error_t
|
||||
* DPL_INVALID_PARM mutex was NULL
|
||||
* DPL_OK no error
|
||||
*/
|
||||
dpl_error_t dpl_mutex_release(struct dpl_mutex *mu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_MUTEX_H */
|
||||
97
pkg/uwb-core/include/dpl/dpl_os.h
Normal file
97
pkg/uwb-core/include/dpl/dpl_os.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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) error types
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_OS_H
|
||||
#define DPL_DPL_OS_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#include "irq.h"
|
||||
#include "dpl/dpl_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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())
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief variable to check if ISR are disabled
|
||||
*/
|
||||
extern atomic_uint dpl_in_critical;
|
||||
|
||||
/**
|
||||
* @brief CPU status register
|
||||
*/
|
||||
typedef uint32_t dpl_sr_t;
|
||||
|
||||
/**
|
||||
* @brief Disable ISRs
|
||||
*
|
||||
* @return current isr context
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restores ISR context
|
||||
*
|
||||
* @param[in] ctx ISR context to restore.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if is in critical section
|
||||
*
|
||||
* @return true, if in critical section, false otherwise
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_OS_H */
|
||||
89
pkg/uwb-core/include/dpl/dpl_sem.h
Normal file
89
pkg/uwb-core/include/dpl/dpl_sem.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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) semapahore wrappers
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_SEM_H
|
||||
#define DPL_DPL_SEM_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dpl_types.h"
|
||||
#include "dpl_error.h"
|
||||
|
||||
#include "sema.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief dpl semaphore wrapper
|
||||
*/
|
||||
struct dpl_sem {
|
||||
sema_t sema; /**< the semaphore */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize a semaphore
|
||||
*
|
||||
* @param[in] sem pointer to semaphore
|
||||
* @param[in] tokens # of tokens the semaphore should contain initially.
|
||||
*
|
||||
* @return dpl_error_t
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* @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 DPL_TIMEOUT_NEVER means wait forever.
|
||||
*
|
||||
*
|
||||
* @return dpl_error_t
|
||||
* DPL_INVALID_PARM semaphore passed in was NULL.
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* @brief Release a semaphore.
|
||||
*
|
||||
* @param[in] sem pointer to the semaphore to be released
|
||||
*
|
||||
* @return dpl_error_t
|
||||
* DPL_INVALID_PARM semaphore passed in was NULL.
|
||||
* DPL_OK no error
|
||||
*/
|
||||
dpl_error_t dpl_sem_release(struct dpl_sem *sem);
|
||||
|
||||
/**
|
||||
* @brief Get current semaphore's count
|
||||
*/
|
||||
uint16_t dpl_sem_get_count(struct dpl_sem *sem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_SEM_H */
|
||||
90
pkg/uwb-core/include/dpl/dpl_tasks.h
Normal file
90
pkg/uwb-core/include/dpl/dpl_tasks.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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) thread/task wrappers
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_TASKS_H
|
||||
#define DPL_DPL_TASKS_H
|
||||
|
||||
#include "dpl_types.h"
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief dpl task wrapper
|
||||
*/
|
||||
struct dpl_task {
|
||||
kernel_pid_t pid; /**< the process id */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief dpl task function
|
||||
*/
|
||||
typedef thread_task_func_t dpl_task_func_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize a task.
|
||||
*
|
||||
* This function initializes the task structure pointed to by t,
|
||||
* clearing and setting it's stack pointer, provides sane defaults
|
||||
* and sets the task as ready to run, and inserts it into the operating
|
||||
* system scheduler.
|
||||
*
|
||||
* @param[in] t the task to initialize
|
||||
* @param[in] name task name
|
||||
* @param[in] func task function to call
|
||||
* @param[in] arg argument to pass in task init function
|
||||
* @param[in] prio task priority
|
||||
* @param[in] sanity_itvl UNUSED
|
||||
* @param[in] stack_bottom pointer to bottom of the stack
|
||||
* @param[in] stack_size task stack size
|
||||
*
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief removes specified task
|
||||
*
|
||||
* NOTE: This interface is currently experimental and not ready for common use
|
||||
*/
|
||||
int dpl_task_remove(struct dpl_task *t);
|
||||
|
||||
/**
|
||||
* @brief Return the number of tasks initialized.
|
||||
*
|
||||
* @return number of tasks initialized
|
||||
*/
|
||||
uint8_t dpl_task_count(void);
|
||||
|
||||
/**
|
||||
* @brief Lets current thread yield.
|
||||
*/
|
||||
void dpl_task_yield(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_TASKS_H */
|
||||
113
pkg/uwb-core/include/dpl/dpl_time.h
Normal file
113
pkg/uwb-core/include/dpl/dpl_time.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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) time abstraction
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_TIME_H
|
||||
#define DPL_DPL_TIME_H
|
||||
|
||||
#include "xtimer.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.
|
||||
*
|
||||
* @return uint32_t The lower 32 bits of cputime
|
||||
*/
|
||||
static inline dpl_time_t dpl_time_get(void)
|
||||
{
|
||||
return xtimer_now().ticks32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 dpl_error_t DPL_OK - no error
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 dpl_error_t DPL_OK - no error
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 dpl_time_t dpl_time_ms_to_ticks32(uint32_t ms)
|
||||
{
|
||||
return xtimer_ticks_from_usec(ms * US_PER_MS).ticks32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wait until the number of ticks has elapsed, BLOICKING.
|
||||
*
|
||||
* @param[in] ticks The number of ticks to wait.
|
||||
*/
|
||||
static inline void dpl_time_delay(dpl_time_t ticks)
|
||||
{
|
||||
xtimer_ticks32_t val = {.ticks32 = ticks};
|
||||
xtimer_tsleep32((xtimer_ticks32_t) val);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_TIME_H */
|
||||
118
pkg/uwb-core/include/dpl/dpl_types.h
Normal file
118
pkg/uwb-core/include/dpl/dpl_types.h
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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) types
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef DPL_DPL_TYPES_H
|
||||
#define DPL_DPL_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PI approximated value macro definition
|
||||
*/
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Macro to wait forever on events and mutexes
|
||||
* @{
|
||||
*/
|
||||
#define DPL_TIMEOUT_NEVER (UINT32_MAX)
|
||||
#define DPL_WAIT_FOREVER (DPL_TIMEOUT_NEVER)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Decawave porting layer (DPL) stack alignment requirement
|
||||
* @{
|
||||
*/
|
||||
#define DPL_STACK_ALIGNMENT (4)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief dpl time type
|
||||
*/
|
||||
typedef uint32_t dpl_time_t;
|
||||
|
||||
/**
|
||||
* @brief dpl stack buffer type
|
||||
*/
|
||||
typedef char dpl_stack_t;
|
||||
|
||||
/**
|
||||
* @brief dpl float 32 type
|
||||
*/
|
||||
typedef float dpl_float32_t;
|
||||
/**
|
||||
* @brief dpl float 64 type
|
||||
*/
|
||||
typedef double dpl_float64_t;
|
||||
|
||||
/**
|
||||
* @name Decawave porting layer (DPL) float type macros
|
||||
* @{
|
||||
*/
|
||||
#define DPL_FLOAT32_INIT(__X) ((float)__X)
|
||||
#define DPL_FLOAT64_INIT(__X) ((double)__X)
|
||||
#define DPL_FLOAT64TO32(__X) (float)(__X)
|
||||
#define DPL_FLOAT32_I32_TO_F32(__X) (float)(__X)
|
||||
#define DPL_FLOAT64_I32_TO_F64(__X) ((double)(__X))
|
||||
#define DPL_FLOAT64_I64_TO_F64(__X) ((double)(__X))
|
||||
#define DPL_FLOAT64_U64_TO_F64(__X) ((double)(__X))
|
||||
#define DPL_FLOAT64_F64_TO_U64(__X) ((uint64_t)(__X))
|
||||
#define DPL_FLOAT32_INT(__X) ((int32_t)__X)
|
||||
#define DPL_FLOAT64_INT(__X) ((int64_t)__X)
|
||||
#define DPL_FLOAT64_FROM_F32(__X) (double)(__X)
|
||||
#define DPL_FLOAT32_FROM_F64(__X) (float)(__X)
|
||||
#define DPL_FLOAT32_CEIL(__X) (ceilf(__X))
|
||||
#define DPL_FLOAT64_CEIL(__X) (ceil(__X))
|
||||
#define DPL_FLOAT32_FABS(__X) fabsf(__X)
|
||||
#define DPL_FLOAT32_FMOD(__X, __Y) fmodf(__X, __Y)
|
||||
#define DPL_FLOAT64_FMOD(__X, __Y) fmod(__X, __Y)
|
||||
#define DPL_FLOAT32_NAN() nanf("")
|
||||
#define DPL_FLOAT64_NAN() nan("")
|
||||
#define DPL_FLOAT32_ISNAN(__X) isnan(__X)
|
||||
#define DPL_FLOAT64_ISNAN(__X) DPL_FLOAT32_ISNAN(__X)
|
||||
#define DPL_FLOAT32_LOG10(__X) (log10f(__X))
|
||||
#define DPL_FLOAT64_LOG10(__X) (log10(__X))
|
||||
#define DPL_FLOAT64_ASIN(__X) asin(__X)
|
||||
#define DPL_FLOAT64_ATAN(__X) atan(__X)
|
||||
#define DPL_FLOAT32_SUB(__X, __Y) ((__X)-(__Y))
|
||||
#define DPL_FLOAT64_SUB(__X, __Y) ((__X)-(__Y))
|
||||
#define DPL_FLOAT32_ADD(__X, __Y) ((__X)+(__Y))
|
||||
#define DPL_FLOAT64_ADD(__X, __Y) ((__X)+(__Y))
|
||||
#define DPL_FLOAT32_MUL(__X, __Y) ((__X)*(__Y))
|
||||
#define DPL_FLOAT64_MUL(__X, __Y) ((__X)*(__Y))
|
||||
#define DPL_FLOAT32_DIV(__X, __Y) ((__X)/(__Y))
|
||||
#define DPL_FLOAT64_DIV(__X, __Y) ((__X)/(__Y))
|
||||
#define DPL_FLOAT32_PRINTF_PRIM "%s%d.%03d"
|
||||
#define DPL_FLOAT32_PRINTF_VALS(__X) (__X)<0?"-":"", (int)(fabsf(__X)), (int)(fabsf((__X)-(int)(__X))*1000)
|
||||
#define DPL_FLOAT64_PRINTF_PRIM "%s%d.%06d"
|
||||
#define DPL_FLOAT64_PRINTF_VALS(__X) (__X)<0?"-":"", (int)(fabs(__X)), (int)(fabs((__X)-(int)(__X))*1000000)
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DPL_DPL_TYPES_H */
|
||||
48
pkg/uwb-core/include/log/dpl_log.h
Normal file
48
pkg/uwb-core/include/log/dpl_log.h
Normal file
@ -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_uwb_core
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief System logging header for uwb-core
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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 */
|
||||
33
pkg/uwb-core/include/mcu/mcu.h
Normal file
33
pkg/uwb-core/include/mcu/mcu.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef MCU_MCU_H
|
||||
#define MCU_MCU_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* empty header */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MCU_MCU_H */
|
||||
30
pkg/uwb-core/include/os/os.h
Normal file
30
pkg/uwb-core/include/os/os.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
#ifndef OS_OS_H
|
||||
#define OS_OS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OS_OS_H */
|
||||
52
pkg/uwb-core/include/os/os_dev.h
Normal file
52
pkg/uwb-core/include/os/os_dev.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
#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 */
|
||||
33
pkg/uwb-core/include/stats/stats.h
Normal file
33
pkg/uwb-core/include/stats/stats.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef STATS_STATS_H
|
||||
#define STATS_STATS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* empty header */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STATS_STATS_H */
|
||||
75
pkg/uwb-core/include/syscfg/syscfg.h
Normal file
75
pkg/uwb-core/include/syscfg/syscfg.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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 */
|
||||
53
pkg/uwb-core/include/syscfg/syscfg_twr_ds.h
Normal file
53
pkg/uwb-core/include/syscfg/syscfg_twr_ds.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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-dw100 double side two-way ranging module configurations
|
||||
* taken from decawave-uwb-core/lib/twr_ds/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_TWR_DS_H
|
||||
#define SYSCFG_SYSCFG_TWR_DS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable toplevel ranging services
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_DS_ENABLED
|
||||
#define MYNEWT_VAL_TWR_DS_ENABLED (IS_ACTIVE(MODULE_UWB_CORE_TWR_DS))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TOA timeout delay for DS TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_DS_RX_TIMEOUT
|
||||
#define MYNEWT_VAL_TWR_DS_RX_TIMEOUT (((uint16_t)0x30))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief tx holdoff delay for DS TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_DS_TX_HOLDOFF
|
||||
#define MYNEWT_VAL_TWR_DS_TX_HOLDOFF (((uint32_t)0x0300))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_TWR_DS_H */
|
||||
53
pkg/uwb-core/include/syscfg/syscfg_twr_ds_ext.h
Normal file
53
pkg/uwb-core/include/syscfg/syscfg_twr_ds_ext.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 double side extended two-way ranging module configurations
|
||||
* taken from decawave-uwb-core/lib/twr_ds_ext/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_TWR_DS_EXT_H
|
||||
#define SYSCFG_SYSCFG_TWR_DS_EXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable double sided extended two way ranging
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_DS_EXT_ENABLED
|
||||
#define MYNEWT_VAL_TWR_DS_EXT_ENABLED IS_ACTIVE(MODULE_UWB_CORE_TWR_DS_EXT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable double sided extended two way ranging
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_DS_EXT_RX_TIMEOUT
|
||||
#define MYNEWT_VAL_TWR_DS_EXT_RX_TIMEOUT (((uint16_t)0x40))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief tx holdoff delay for DS TWR extended frame (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_DS_EXT_TX_HOLDOFF
|
||||
#define MYNEWT_VAL_TWR_DS_EXT_TX_HOLDOFF (((uint32_t)0x0400))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_TWR_DS_EXT_H */
|
||||
53
pkg/uwb-core/include/syscfg/syscfg_twr_ss.h
Normal file
53
pkg/uwb-core/include/syscfg/syscfg_twr_ss.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 single-sided two-way ranging module configurations
|
||||
* taken from decawave-uwb-core/lib/twr_ss/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_TWR_SS_H
|
||||
#define SYSCFG_SYSCFG_TWR_SS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable ranging services
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_ENABLED
|
||||
#define MYNEWT_VAL_TWR_SS_ENABLED (IS_ACTIVE(MODULE_UWB_CORE_TWR_SS))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TOA timeout delay for SS TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_RX_TIMEOUT
|
||||
#define MYNEWT_VAL_TWR_SS_RX_TIMEOUT (((uint16_t)0x30))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief tx holdoff delay for SS TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_TX_HOLDOFF
|
||||
#define MYNEWT_VAL_TWR_SS_TX_HOLDOFF (((uint32_t)0x0300))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_TWR_SS_H */
|
||||
53
pkg/uwb-core/include/syscfg/syscfg_twr_ss_ack.h
Normal file
53
pkg/uwb-core/include/syscfg/syscfg_twr_ss_ack.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 Single sided ranging using a hw generated ack module configurations
|
||||
* taken from decawave-uwb-core/lib/twr_ss_ack/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_TWR_SS_ACK_H
|
||||
#define SYSCFG_SYSCFG_TWR_SS_ACK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable toplevel ranging services
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_ACK_ENABLED
|
||||
#define MYNEWT_VAL_TWR_SS_ACK_ENABLED (IS_ACTIVE(MODULE_UWB_CORE_TWR_SS_ACK))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief tx holdoff delay used to know how long to wait for SS TWR ACK message (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_ACK_RX_TIMEOUT
|
||||
#define MYNEWT_VAL_TWR_SS_ACK_RX_TIMEOUT (((uint16_t)0x100))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TOA timeout delay for SS TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_ACK_TX_HOLDOFF
|
||||
#define MYNEWT_VAL_TWR_SS_ACK_TX_HOLDOFF (((uint32_t)0x800))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_TWR_SS_ACK_H */
|
||||
53
pkg/uwb-core/include/syscfg/syscfg_twr_ss_ext.h
Normal file
53
pkg/uwb-core/include/syscfg/syscfg_twr_ss_ext.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 single-sided two-way ranging module configurations
|
||||
* taken from decawave-uwb-core/lib/twr_ss_ext/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_TWR_SS_EXT_H
|
||||
#define SYSCFG_SYSCFG_TWR_SS_EXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable Single Sided extended ranging services
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_EXT_ENABLED
|
||||
#define MYNEWT_VAL_TWR_SS_EXT_ENABLED (IS_ACTIVE(MODULE_UWB_CORE_TWR_SS_EXT))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TOA timeout delay for SS EXT TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_EXT_RX_TIMEOUT
|
||||
#define MYNEWT_VAL_TWR_SS_EXT_RX_TIMEOUT (((uint16_t)0x40))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief tx holdoff delay for SS EXT TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_TWR_SS_EXT_TX_HOLDOFF
|
||||
#define MYNEWT_VAL_TWR_SS_EXT_TX_HOLDOFF (((uint32_t)0x0400))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_TWR_SS_EXT_H */
|
||||
144
pkg/uwb-core/include/syscfg/syscfg_uwb.h
Normal file
144
pkg/uwb-core/include/syscfg/syscfg_uwb.h
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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 uwb module configurations
|
||||
* taken from decawave-uwb-core/hw/drivers/uwb/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_UWB_H
|
||||
#define SYSCFG_SYSCFG_UWB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Interrupt task priority for instance 0
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_DEV_TASK_PRIO
|
||||
#define MYNEWT_VAL_UWB_DEV_TASK_PRIO (THREAD_PRIORITY_MAIN - 5)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Size of interrupt task stack
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_DEV_TASK_STACK_SZ
|
||||
#define MYNEWT_VAL_UWB_DEV_TASK_STACK_SZ (1024)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Size of the rx buffer in the uwb_dev
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_RX_BUFFER_SIZE
|
||||
#define MYNEWT_VAL_UWB_RX_BUFFER_SIZE (1024)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @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)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum size of rxdiag structure
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_DEV_RXDIAG_MAXLEN
|
||||
#define MYNEWT_VAL_UWB_DEV_RXDIAG_MAXLEN (20)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief UWB_0 Device Enable. BSP uses this to enable the specific uwb device
|
||||
*
|
||||
* @note in uwb-core you need to tell exactly how many uwb-device there
|
||||
* are, ideally thus would be done different
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_DEVICE_0
|
||||
#define MYNEWT_VAL_UWB_DEVICE_0 (1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Max number of UWB_DEVICES allowed in system
|
||||
*
|
||||
* @note uwb-core uses arrays to keep track of devices, currently se use
|
||||
* linked list, this is temporary...
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_DEVICE_MAX
|
||||
#define MYNEWT_VAL_UWB_DEVICE_MAX (3)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief If ipatov and sts timestamps differ by more than this value
|
||||
* they are considered invalid
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_STS_TS_MATCH_THRESHOLD
|
||||
#define MYNEWT_VAL_UWB_STS_TS_MATCH_THRESHOLD (30)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default Anchor X Coordinate
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_LOCAL_COORDINATE_X
|
||||
#define MYNEWT_VAL_LOCAL_COORDINATE_X (((float)0.0f))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default Anchor Y Coordinate
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_LOCAL_COORDINATE_Y
|
||||
#define MYNEWT_VAL_LOCAL_COORDINATE_Y (((float)0.0f))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default Anchor Z Coordinate
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_LOCAL_COORDINATE_Z
|
||||
#define MYNEWT_VAL_LOCAL_COORDINATE_Z (((float)0.0f))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Range Measurement Variance
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_RANGE_VARIANCE
|
||||
#define MYNEWT_VAL_RANGE_VARIANCE (((float)5.4444e-04))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Azimuth Measurement Variance
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_AZIMUTH_VARIANCE
|
||||
#define MYNEWT_VAL_AZIMUTH_VARIANCE (((float)2.91e-2))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OS Latency Guardband (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_OS_LATENCY
|
||||
#define MYNEWT_VAL_OS_LATENCY (((uint32_t)800))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default Pan ID
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_PANID
|
||||
#define MYNEWT_VAL_PANID (((const uint16_t)0xdeca))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_UWB_H */
|
||||
67
pkg/uwb-core/include/syscfg/syscfg_uwb_rng.h
Normal file
67
pkg/uwb-core/include/syscfg/syscfg_uwb_rng.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 uwb_rng module configurations
|
||||
* taken from decawave-uwb-core/lib/uwb_rng/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_UWB_RNG_H
|
||||
#define SYSCFG_SYSCFG_UWB_RNG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief uwb-core uwb_rng module is enabled
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_RNG_ENABLED
|
||||
#define MYNEWT_VAL_UWB_RNG_ENABLED ((IS_ACTIVE(MODULE_UWB_CORE_RNG)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TOA timeout delay for TWR (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_RNG_RX_TIMEOUT
|
||||
#define MYNEWT_VAL_RNG_RX_TIMEOUT (((uint16_t)0x20))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief worstcase tx holdoff delay for all TWR modes (usec)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_RNG_TX_HOLDOFF
|
||||
#define MYNEWT_VAL_RNG_TX_HOLDOFF (((uint32_t)0x0320))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Show debug output from postprocess
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_RNG_VERBOSE
|
||||
#define MYNEWT_VAL_RNG_VERBOSE (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief JSON buffer size
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWB_RNG_JSON_BUFSIZE
|
||||
#define MYNEWT_VAL_UWB_RNG_JSON_BUFSIZE (256)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_UWB_RNG_H */
|
||||
241
pkg/uwb-core/include/syscfg/syscfg_uwbcfg.h
Normal file
241
pkg/uwb-core/include/syscfg/syscfg_uwbcfg.h
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* 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 uwbcfg module configurations
|
||||
* taken from decawave-uwb-core/sys/uwbcfg/syscfg.yml
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef SYSCFG_SYSCFG_UWBCFG_H
|
||||
#define SYSCFG_SYSCFG_UWBCFG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable uwbcfg module
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_ENABLED
|
||||
#define MYNEWT_VAL_UWBCFG_ENABLED (IS_ACTIVE(MODULE_UWB_CORE_UWBCFG))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Apply configuration on uwbcfg module setup
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_APPLY_AT_INIT
|
||||
#define MYNEWT_VAL_UWBCFG_APPLY_AT_INIT (1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default channel
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_CH
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_CH ("5")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB PRF (MHz)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_PRF
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_PRF ("64")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB Datarate (110k, 850k, 6m8)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_DATARATE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_DATARATE ("6m8")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB PAC Length (8, 16, 32, 64)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_PACLEN
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_PACLEN ("8")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB External clock delay
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_EXT_CLKDLY
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_EXT_CLKDLY ("0")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default MAC FrameFilter (0x0000 = no filter)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_FRAME_FILTER
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_FRAME_FILTER ("0x0000")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB Role
|
||||
*
|
||||
* - Tag "0x00"
|
||||
* - Node "0x01"
|
||||
* - Pan master "0x02"
|
||||
* - Anchor "0x04"
|
||||
* - Panmaster "0x07"
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_ROLE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_ROLE ("0x0")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB RX Antenna delay
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_ANTDLY
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_ANTDLY ("0x4050")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB RX Antenna separation distance in m
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_ANTSEP
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_ANTSEP ("0.0205")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief UWBCFG_DEF_RX_DIAG_EN
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_DIAG_EN
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_DIAG_EN ("0x1")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB PDOA Mode (0, 1, 2, 3)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_PDOA_MODE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_PDOA_MODE ("0")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB PHR Mode (s, e)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_PHR_MODE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_PHR_MODE ("e")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB PHR Rate (0 = std, 1 = data)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_PHR_RATE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_PHR_RATE ("0")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB RX Preamble Code Index
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_PREAM_CIDX
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_PREAM_CIDX ("9")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB SFD Timeout (-1=auto, timeout in symbols)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_SFD_TO
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_SFD_TO ("-1")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB SFD Type (0, 1)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_SFD_TYPE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_SFD_TYPE ("1")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB Sts Length (32-2040 in steps of 8)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_STS_LEN
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_STS_LEN ("64")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB Sts Mode (0, 1, 2, sdc, 4z)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_RX_STS_MODE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_RX_STS_MODE ("0")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB Coarse TX Power (0,3,6,..,18)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_TXRF_POWER_COARSE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_TXRF_POWER_COARSE ("15")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB FINE TX Power (0,1,2,..,31)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_TXRF_POWER_FINE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_TXRF_POWER_FINE ("22")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB FINE TX Power (0,1,2,..,31)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_TXRF_VCM_LO
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_TXRF_VCM_LO ("15")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB TX Antenna delay
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_TX_ANTDLY
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_TX_ANTDLY ("0x4050")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB RX Antenna separation distance in m
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_TX_PREAM_CIDX
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_TX_PREAM_CIDX ("9")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default UWB Preamble Length
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_TX_PREAM_LEN
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_TX_PREAM_LEN ("128")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default XTAL Trim value (0xff = no trim, or use OTP value)
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_XTAL_TRIM
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_XTAL_TRIM ("0xff")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Offset relative leading edge to start extracting CIR from
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_CIR_OFFSET
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_CIR_OFFSET ("0")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of bins to extract from CIR
|
||||
*/
|
||||
#ifndef MYNEWT_VAL_UWBCFG_DEF_CIR_SIZE
|
||||
#define MYNEWT_VAL_UWBCFG_DEF_CIR_SIZE ("0")
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSCFG_SYSCFG_UWBCFG_H */
|
||||
38
pkg/uwb-core/include/sysinit/sysinit.h
Normal file
38
pkg/uwb-core/include/sysinit/sysinit.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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 */
|
||||
63
pkg/uwb-core/include/uwb_core.h
Normal file
63
pkg/uwb-core/include/uwb_core.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef UWB_CORE_H
|
||||
#define UWB_CORE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "event.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Priority used for
|
||||
*/
|
||||
#ifndef UWB_CORE__PRIO
|
||||
#define UWB_CORE__PRIO (THREAD_PRIORITY_MAIN - 2)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Stacksize used for
|
||||
*/
|
||||
#ifndef UWB_CORE__STACKSIZE
|
||||
#define UWB_CORE__STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Setup and run uwb-core thread
|
||||
*/
|
||||
void uwb_core_riot_init(void);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the default event queue.
|
||||
*
|
||||
* As there is no default event queue in RIOT, uwb-core will start and
|
||||
* handle a default event queue.
|
||||
*
|
||||
* @return the default event queue.
|
||||
*/
|
||||
event_queue_t *uwb_core_get_eventq(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UWB_CORE_H */
|
||||
/** @} */
|
||||
@ -0,0 +1,33 @@
|
||||
From 0a9b2ebbe97dbe10a7bc9afdf3914b099c0264da Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Fri, 14 Aug 2020 14:14:23 +0200
|
||||
Subject: [PATCH 1/7] uwb/uwb.c: use RIOT specific uwb_dev_idx_lookup()
|
||||
|
||||
---
|
||||
hw/drivers/uwb/src/uwb.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/hw/drivers/uwb/src/uwb.c b/hw/drivers/uwb/src/uwb.c
|
||||
index 70c1b71..69e6714 100644
|
||||
--- a/hw/drivers/uwb/src/uwb.c
|
||||
+++ b/hw/drivers/uwb/src/uwb.c
|
||||
@@ -31,6 +31,8 @@
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
+
|
||||
+#if !defined(RIOT)
|
||||
struct uwb_dev*
|
||||
uwb_dev_idx_lookup(int idx)
|
||||
{
|
||||
@@ -48,6 +50,7 @@ uwb_dev_idx_lookup(int idx)
|
||||
return (struct uwb_dev*)odev;
|
||||
}
|
||||
EXPORT_SYMBOL(uwb_dev_idx_lookup);
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* API to register extension callbacks for different services.
|
||||
--
|
||||
2.28.0
|
||||
|
||||
758
pkg/uwb-core/patches/0002-lib-twr_-enable-stats-optionally.patch
Normal file
758
pkg/uwb-core/patches/0002-lib-twr_-enable-stats-optionally.patch
Normal file
@ -0,0 +1,758 @@
|
||||
From cac1c7aeb1db0732519fa6ae27f3f34234c83615 Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Fri, 14 Aug 2020 14:22:29 +0200
|
||||
Subject: [PATCH 2/7] lib/twr_*: enable stats optionally
|
||||
|
||||
---
|
||||
lib/twr_ds/src/twr_ds.c | 41 +++++++++++++----------
|
||||
lib/twr_ds/syscfg.yml | 3 ++
|
||||
lib/twr_ds_ext/src/twr_ds_ext.c | 17 +++++++---
|
||||
lib/twr_ds_ext/syscfg.yml | 3 ++
|
||||
lib/twr_ds_ext_nrng/src/twr_ds_ext_nrng.c | 16 ++++++---
|
||||
lib/twr_ds_ext_nrng/syscfg.yml | 3 ++
|
||||
lib/twr_ds_nrng/src/twr_ds_nrng.c | 16 ++++++---
|
||||
lib/twr_ds_nrng/syscfg.yml | 3 ++
|
||||
lib/twr_ss/src/twr_ss.c | 6 ++++
|
||||
lib/twr_ss/syscfg.yml | 3 ++
|
||||
lib/twr_ss_ack/src/twr_ss_ack.c | 8 +++--
|
||||
lib/twr_ss_ack/syscfg.yml | 3 ++
|
||||
lib/twr_ss_ext/src/twr_ss_ext.c | 15 ++++++---
|
||||
lib/twr_ss_ext/syscfg.yml | 3 ++
|
||||
lib/twr_ss_ext_nrng/src/twr_ss_ext_nrng.c | 9 ++++-
|
||||
lib/twr_ss_ext_nrng/syscfg.yml | 3 ++
|
||||
lib/twr_ss_nrng/src/twr_ss_nrng.c | 39 ++++++++++++++++++---
|
||||
lib/twr_ss_nrng/syscfg.yml | 3 ++
|
||||
18 files changed, 151 insertions(+), 43 deletions(-)
|
||||
|
||||
diff --git a/lib/twr_ds/src/twr_ds.c b/lib/twr_ds/src/twr_ds.c
|
||||
index c73c412..cb5de6a 100644
|
||||
--- a/lib/twr_ds/src/twr_ds.c
|
||||
+++ b/lib/twr_ds/src/twr_ds.c
|
||||
@@ -51,6 +51,23 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_STATS)
|
||||
+STATS_SECT_START(twr_ds_stat_section)
|
||||
+ STATS_SECT_ENTRY(complete)
|
||||
+ STATS_SECT_ENTRY(start_tx_error)
|
||||
+STATS_SECT_END
|
||||
+
|
||||
+STATS_NAME_START(twr_ds_stat_section)
|
||||
+ STATS_NAME(twr_ds_stat_section, complete)
|
||||
+ STATS_NAME(twr_ds_stat_section, start_tx_error)
|
||||
+STATS_NAME_END(twr_ds_stat_section)
|
||||
+
|
||||
+STATS_SECT_DECL(twr_ds_stat_section) g_twr_ds_stat;
|
||||
+#define DS_STATS_INC(__X) STATS_INC(g_twr_ds_stat, __X)
|
||||
+#else
|
||||
+#define DS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
+
|
||||
static bool rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs);
|
||||
|
||||
static struct uwb_mac_interface g_cbs[] = {
|
||||
@@ -72,18 +89,6 @@ static struct uwb_mac_interface g_cbs[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
-STATS_SECT_START(twr_ds_stat_section)
|
||||
- STATS_SECT_ENTRY(complete)
|
||||
- STATS_SECT_ENTRY(start_tx_error)
|
||||
-STATS_SECT_END
|
||||
-
|
||||
-STATS_NAME_START(twr_ds_stat_section)
|
||||
- STATS_NAME(twr_ds_stat_section, complete)
|
||||
- STATS_NAME(twr_ds_stat_section, start_tx_error)
|
||||
-STATS_NAME_END(twr_ds_stat_section)
|
||||
-
|
||||
-STATS_SECT_DECL(twr_ds_stat_section) g_twr_ds_stat;
|
||||
-
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_DS_TX_HOLDOFF), // Send Time delay in usec.
|
||||
.rx_timeout_delay = MYNEWT_VAL(TWR_DS_RX_TIMEOUT) // Receive response timeout in usec
|
||||
@@ -137,6 +142,7 @@ void twr_ds_pkg_init(void)
|
||||
uwb_rng_append_config(g_cbs[i].inst_ptr, &g_rng_cfgs[i]);
|
||||
}
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_STATS)
|
||||
rc = stats_init(
|
||||
STATS_HDR(g_twr_ds_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_twr_ds_stat, STATS_SIZE_32),
|
||||
@@ -145,6 +151,7 @@ void twr_ds_pkg_init(void)
|
||||
|
||||
rc = stats_register("twr_ds", STATS_HDR(g_twr_ds_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -231,7 +238,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
|
||||
/* Start tx now, the remaining settings can be done whilst sending anyway */
|
||||
if (uwb_start_tx(inst).start_tx_error){
|
||||
- STATS_INC(g_twr_ds_stat, start_tx_error);
|
||||
+ DS_STATS_INC(start_tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
}
|
||||
|
||||
@@ -291,7 +298,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_set_rxauto_disable(inst, true);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error){
|
||||
- STATS_INC(g_twr_ds_stat, start_tx_error);
|
||||
+ DS_STATS_INC(start_tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
}
|
||||
/* Setup when to listen for response, relative the end of our transmitted frame */
|
||||
@@ -337,11 +344,11 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_set_delay_start(inst, txd.response_tx_delay);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error) {
|
||||
- STATS_INC(g_twr_ds_stat, start_tx_error);
|
||||
+ DS_STATS_INC(start_tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
rng_issue_complete(inst);
|
||||
} else {
|
||||
- STATS_INC(g_twr_ds_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
rng->control.complete_after_tx = 1;
|
||||
}
|
||||
|
||||
@@ -352,7 +359,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
// This code executes on the device that initialed the original request, and has now receive the final response timestamp.
|
||||
// This marks the completion of the double-single-two-way request.
|
||||
|
||||
- STATS_INC(g_twr_ds_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
dpl_sem_release(&rng->sem);
|
||||
rng_issue_complete(inst);
|
||||
break;
|
||||
diff --git a/lib/twr_ds/syscfg.yml b/lib/twr_ds/syscfg.yml
|
||||
index cb12594..288b8fd 100644
|
||||
--- a/lib/twr_ds/syscfg.yml
|
||||
+++ b/lib/twr_ds/syscfg.yml
|
||||
@@ -10,3 +10,6 @@ syscfg.defs:
|
||||
TWR_DS_RX_TIMEOUT:
|
||||
description: 'TOA timeout delay for DS TWR (usec)'
|
||||
value: ((uint16_t)0x30)
|
||||
+ TWR_DS_STATS:
|
||||
+ description: 'Enable statistics for the twr_ds module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ds_ext/src/twr_ds_ext.c b/lib/twr_ds_ext/src/twr_ds_ext.c
|
||||
index 95f38fe..07cc28c 100644
|
||||
--- a/lib/twr_ds_ext/src/twr_ds_ext.c
|
||||
+++ b/lib/twr_ds_ext/src/twr_ds_ext.c
|
||||
@@ -67,6 +67,7 @@ static struct uwb_mac_interface g_cbs[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_EXT_STATS)
|
||||
STATS_SECT_START(twr_ds_ext_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(tx_error)
|
||||
@@ -78,6 +79,10 @@ STATS_NAME_START(twr_ds_ext_stat_section)
|
||||
STATS_NAME_END(twr_ds_ext_stat_section)
|
||||
|
||||
static STATS_SECT_DECL(twr_ds_ext_stat_section) g_twr_ds_ext_stat;
|
||||
+#define DS_STATS_INC(__X) STATS_INC(g_twr_ds_ext_stat, __X)
|
||||
+#else
|
||||
+#define DS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_DS_EXT_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -132,6 +137,7 @@ void twr_ds_ext_pkg_init(void)
|
||||
uwb_rng_append_config(g_cbs[i].inst_ptr, &g_rng_cfgs[i]);
|
||||
}
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_EXT_STATS)
|
||||
rc = stats_init(
|
||||
STATS_HDR(g_twr_ds_ext_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_twr_ds_ext_stat, STATS_SIZE_32),
|
||||
@@ -140,6 +146,7 @@ void twr_ds_ext_pkg_init(void)
|
||||
|
||||
rc = stats_register("twr_ds_ext", STATS_HDR(g_twr_ds_ext_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +231,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_set_rxauto_disable(inst, true);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error){
|
||||
- STATS_INC(g_twr_ds_ext_stat, tx_error);
|
||||
+ DS_STATS_INC(tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
}
|
||||
|
||||
@@ -293,7 +300,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_set_rxauto_disable(inst, true);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error){
|
||||
- STATS_INC(g_twr_ds_ext_stat, tx_error);
|
||||
+ DS_STATS_INC(tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
}
|
||||
/* Setup when to listen for response, relative the end of our transmitted frame */
|
||||
@@ -348,11 +355,11 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_rng_clear_twr_data(&frame->remote);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error) {
|
||||
- STATS_INC(g_twr_ds_ext_stat, tx_error);
|
||||
+ DS_STATS_INC(tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
rng_issue_complete(inst);
|
||||
}else{
|
||||
- STATS_INC(g_twr_ds_ext_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
rng->control.complete_after_tx = 1;
|
||||
}
|
||||
break;
|
||||
@@ -362,7 +369,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
// This code executes on the device that initialed the original request, and has now receive the final response timestamp.
|
||||
// This marks the completion of the double-single-two-way request.
|
||||
|
||||
- STATS_INC(g_twr_ds_ext_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
dpl_sem_release(&rng->sem);
|
||||
rng_issue_complete(inst);
|
||||
break;
|
||||
diff --git a/lib/twr_ds_ext/syscfg.yml b/lib/twr_ds_ext/syscfg.yml
|
||||
index 199a671..fe80282 100644
|
||||
--- a/lib/twr_ds_ext/syscfg.yml
|
||||
+++ b/lib/twr_ds_ext/syscfg.yml
|
||||
@@ -10,3 +10,6 @@ syscfg.defs:
|
||||
TWR_DS_EXT_RX_TIMEOUT:
|
||||
description: 'TOA timeout delay for DS TWR extended frame (usec)'
|
||||
value: ((uint16_t)0x40)
|
||||
+ TWR_DS_EXT_STATS:
|
||||
+ description: 'Enable statistics for the twr_ds_ext module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ds_ext_nrng/src/twr_ds_ext_nrng.c b/lib/twr_ds_ext_nrng/src/twr_ds_ext_nrng.c
|
||||
index b2a821e..2b15ae1 100644
|
||||
--- a/lib/twr_ds_ext_nrng/src/twr_ds_ext_nrng.c
|
||||
+++ b/lib/twr_ds_ext_nrng/src/twr_ds_ext_nrng.c
|
||||
@@ -65,6 +65,7 @@ static struct uwb_mac_interface g_cbs = {
|
||||
.final_cb = tx_final_cb,
|
||||
};
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_EXT_NRNG_STATS)
|
||||
STATS_SECT_START(twr_ds_ext_nrng_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(rx_error)
|
||||
@@ -78,6 +79,11 @@ STATS_NAME_START(twr_ds_ext_nrng_stat_section)
|
||||
STATS_NAME_END(twr_ds_ext_nrng_stat_section)
|
||||
|
||||
static STATS_SECT_DECL(twr_ds_ext_nrng_stat_section) g_stat;
|
||||
+#define DS_STATS_INC(__X) STATS_INC(g_stat, __X)
|
||||
+#else
|
||||
+#define DS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
+
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_DS_EXT_NRNG_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -96,6 +102,7 @@ void twr_ds_ext_nrng_pkg_init(void){
|
||||
printf("{\"utime\": %lu,\"msg\": \"twr_ds_ext_nrng_pkg_init\"}\n",os_cputime_ticks_to_usecs(os_cputime_get32()));
|
||||
uwb_mac_append_interface(hal_dw1000_inst(0), &g_cbs);
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_EXT_NRNG_STATS)
|
||||
int rc = stats_init(
|
||||
STATS_HDR(g_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_stat, STATS_SIZE_32),
|
||||
@@ -104,6 +111,7 @@ void twr_ds_ext_nrng_pkg_init(void){
|
||||
|
||||
rc = stats_register("twr_ds_ext_nrng", STATS_HDR(g_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +153,7 @@ rx_timeout_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs){
|
||||
if(inst->fctrl != FCNTL_IEEE_N_RANGES_16){
|
||||
return false;
|
||||
}
|
||||
- STATS_INC(g_stat, rx_timeout);
|
||||
+ DS_STATS_INC(rx_timeout);
|
||||
assert(inst->nrng);
|
||||
switch(inst->nrng->code){
|
||||
case UWB_DATA_CODE_DS_TWR_NRNG_EXT ... UWB_DATA_CODE_DS_TWR_NRNG_EXT_FINAL:
|
||||
@@ -191,7 +199,7 @@ rx_error_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs){
|
||||
if(inst->fctrl != FCNTL_IEEE_N_RANGES_16){
|
||||
return false;
|
||||
}
|
||||
- STATS_INC(g_stat, rx_error);
|
||||
+ DS_STATS_INC(rx_error);
|
||||
assert(inst->nrng);
|
||||
struct nrng_instance * nrng = inst->nrng;
|
||||
os_error_t err = os_sem_release(&nrng->sem);
|
||||
@@ -371,7 +379,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
if (cbs!=NULL && cbs->start_tx_error_cb)
|
||||
cbs->start_tx_error_cb(inst, cbs);
|
||||
}else{
|
||||
- STATS_INC(g_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
os_sem_release(&nrng->sem);
|
||||
struct uwb_mac_interface * cbs = NULL;
|
||||
if(!(SLIST_EMPTY(&inst->interface_cbs))){
|
||||
@@ -416,7 +424,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
if(idx == nnodes -1){
|
||||
os_sem_release(&nrng->sem);
|
||||
nrng->resp_count = 0;
|
||||
- STATS_INC(g_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
struct uwb_mac_interface * cbs = NULL;
|
||||
if(!(SLIST_EMPTY(&inst->interface_cbs))){
|
||||
SLIST_FOREACH(cbs, &inst->interface_cbs, next){
|
||||
diff --git a/lib/twr_ds_ext_nrng/syscfg.yml b/lib/twr_ds_ext_nrng/syscfg.yml
|
||||
index 5fd3404..92a952b 100644
|
||||
--- a/lib/twr_ds_ext_nrng/syscfg.yml
|
||||
+++ b/lib/twr_ds_ext_nrng/syscfg.yml
|
||||
@@ -12,3 +12,6 @@ syscfg.defs:
|
||||
value: ((uint16_t)0x10)
|
||||
TWR_DS_EXT_NRNG_TX_GUARD_DELAY:
|
||||
value: ((uint16_t)0x150)
|
||||
+ TWR_DS_EXT_NRNG_STATS:
|
||||
+ description: 'Enable statistics for the twr_ds_ext_nrng module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ds_nrng/src/twr_ds_nrng.c b/lib/twr_ds_nrng/src/twr_ds_nrng.c
|
||||
index b32b2f8..3aea94a 100644
|
||||
--- a/lib/twr_ds_nrng/src/twr_ds_nrng.c
|
||||
+++ b/lib/twr_ds_nrng/src/twr_ds_nrng.c
|
||||
@@ -61,6 +61,7 @@ static struct uwb_mac_interface g_cbs = {
|
||||
.rx_error_cb = rx_error_cb,
|
||||
};
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_NRNG_STATS)
|
||||
STATS_SECT_START(twr_ds_nrng_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(rx_timeout)
|
||||
@@ -74,6 +75,10 @@ STATS_NAME_START(twr_ds_nrng_stat_section)
|
||||
STATS_NAME_END(twr_ds_nrng_stat_section)
|
||||
|
||||
static STATS_SECT_DECL(twr_ds_nrng_stat_section) g_stat;
|
||||
+#define DS_STATS_INC(__X) STATS_INC(g_stat, __X)
|
||||
+#else
|
||||
+#define DS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_DS_NRNG_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -101,6 +106,7 @@ void twr_ds_nrng_pkg_init(void){
|
||||
uwb_mac_append_interface(uwb_dev_idx_lookup(0), &g_cbs);
|
||||
nrng_append_config(nrng, &g_rng_cfgs);
|
||||
|
||||
+#if MYNEWT_VAL(TWR_DS_NRNG_STATS)
|
||||
int rc = stats_init(
|
||||
STATS_HDR(g_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_stat, STATS_SIZE_32),
|
||||
@@ -109,7 +115,7 @@ void twr_ds_nrng_pkg_init(void){
|
||||
|
||||
rc = stats_register("twr_ds_nrng", STATS_HDR(g_stat));
|
||||
assert(rc == 0);
|
||||
-
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +145,7 @@ rx_timeout_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs){
|
||||
if(inst->fctrl != FCNTL_IEEE_N_RANGES_16){
|
||||
return false;
|
||||
}
|
||||
- STATS_INC(g_stat, rx_timeout);
|
||||
+ DS_STATS_INC(rx_timeout);
|
||||
switch(inst->nrng->code){
|
||||
case UWB_DATA_CODE_DS_TWR_NRNG ... UWB_DATA_CODE_DS_TWR_NRNG_FINAL:
|
||||
{
|
||||
@@ -183,7 +189,7 @@ rx_error_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs){
|
||||
if(inst->fctrl != FCNTL_IEEE_N_RANGES_16){
|
||||
return false;
|
||||
}
|
||||
- STATS_INC(g_stat, rx_error);
|
||||
+ DS_STATS_INC(rx_error);
|
||||
assert(inst->nrng);
|
||||
struct nrng_instance * nrng = inst->nrng;
|
||||
if(os_sem_get_count(&nrng->sem) == 0){
|
||||
@@ -381,7 +387,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
if (cbs!=NULL && cbs->start_tx_error_cb)
|
||||
cbs->start_tx_error_cb(inst, cbs);
|
||||
}else{
|
||||
- STATS_INC(g_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
os_sem_release(&nrng->sem);
|
||||
struct uwb_mac_interface * cbs = NULL;
|
||||
if(!(SLIST_EMPTY(&inst->interface_cbs))){
|
||||
@@ -430,7 +436,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
frame->transmission_timestamp = dw1000_read_txtime_lo(inst);
|
||||
if(idx == nnodes -1)
|
||||
{
|
||||
- STATS_INC(g_stat, complete);
|
||||
+ DS_STATS_INC(complete);
|
||||
os_sem_release(&nrng->sem);
|
||||
struct uwb_mac_interface * cbs = NULL;
|
||||
if(!(SLIST_EMPTY(&inst->interface_cbs))){
|
||||
diff --git a/lib/twr_ds_nrng/syscfg.yml b/lib/twr_ds_nrng/syscfg.yml
|
||||
index 804234a..28777c1 100644
|
||||
--- a/lib/twr_ds_nrng/syscfg.yml
|
||||
+++ b/lib/twr_ds_nrng/syscfg.yml
|
||||
@@ -12,3 +12,6 @@ syscfg.defs:
|
||||
value: ((uint16_t)0x10)
|
||||
TWR_DS_NRNG_TX_GUARD_DELAY:
|
||||
value: ((uint16_t)0x100)
|
||||
+ TWR_DS_NRNG_STATS:
|
||||
+ description: 'Enable statistics for the twr_ds_nrng module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ss/src/twr_ss.c b/lib/twr_ss/src/twr_ss.c
|
||||
index 84c5084..7394ef4 100644
|
||||
--- a/lib/twr_ss/src/twr_ss.c
|
||||
+++ b/lib/twr_ss/src/twr_ss.c
|
||||
@@ -76,6 +76,7 @@ static struct uwb_mac_interface g_cbs[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_STATS)
|
||||
STATS_SECT_START(twr_ss_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(tx_error)
|
||||
@@ -88,6 +89,9 @@ STATS_NAME_END(twr_ss_stat_section)
|
||||
|
||||
STATS_SECT_DECL(twr_ss_stat_section) g_twr_ss_stat;
|
||||
#define SS_STATS_INC(__X) STATS_INC(g_twr_ss_stat, __X)
|
||||
+#else
|
||||
+#define SS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_SS_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -143,6 +147,7 @@ twr_ss_pkg_init(void)
|
||||
uwb_rng_append_config(g_cbs[i].inst_ptr, &g_rng_cfgs[i]);
|
||||
}
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_STATS)
|
||||
rc = stats_init(
|
||||
STATS_HDR(g_twr_ss_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_twr_ss_stat, STATS_SIZE_32),
|
||||
@@ -151,6 +156,7 @@ twr_ss_pkg_init(void)
|
||||
|
||||
rc |= stats_register("twr_ss", STATS_HDR(g_twr_ss_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
diff --git a/lib/twr_ss/syscfg.yml b/lib/twr_ss/syscfg.yml
|
||||
index e2ab7a5..05dc497 100644
|
||||
--- a/lib/twr_ss/syscfg.yml
|
||||
+++ b/lib/twr_ss/syscfg.yml
|
||||
@@ -10,3 +10,6 @@ syscfg.defs:
|
||||
TWR_SS_RX_TIMEOUT:
|
||||
description: 'TOA timeout delay for SS TWR (usec)'
|
||||
value: ((uint16_t)0x30)
|
||||
+ TWR_SS_STATS:
|
||||
+ description: 'Enable statistics for the twr_ss module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ss_ack/src/twr_ss_ack.c b/lib/twr_ss_ack/src/twr_ss_ack.c
|
||||
index f0e0884..a64ce37 100644
|
||||
--- a/lib/twr_ss_ack/src/twr_ss_ack.c
|
||||
+++ b/lib/twr_ss_ack/src/twr_ss_ack.c
|
||||
@@ -78,7 +78,7 @@ static struct uwb_mac_interface g_cbs[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
-
|
||||
+#if MYNEWT_VAL(TWR_SS_ACK_STATS)
|
||||
STATS_SECT_START(twr_ss_ack_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(tx_error)
|
||||
@@ -97,7 +97,9 @@ STATS_NAME_END(twr_ss_ack_stat_section)
|
||||
|
||||
STATS_SECT_DECL(twr_ss_ack_stat_section) g_twr_ss_ack_stat;
|
||||
#define SS_STATS_INC(__X) STATS_INC(g_twr_ss_ack_stat, __X)
|
||||
-
|
||||
+#else
|
||||
+#define SS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_SS_ACK_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -154,6 +156,7 @@ twr_ss_ack_pkg_init(void)
|
||||
uwb_rng_append_config(g_cbs[i].inst_ptr, &g_rng_cfgs[i]);
|
||||
}
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_ACK_STATS)
|
||||
rc = stats_init(
|
||||
STATS_HDR(g_twr_ss_ack_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_twr_ss_ack_stat, STATS_SIZE_32),
|
||||
@@ -162,6 +165,7 @@ twr_ss_ack_pkg_init(void)
|
||||
|
||||
rc |= stats_register("twr_ss_ack", STATS_HDR(g_twr_ss_ack_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
diff --git a/lib/twr_ss_ack/syscfg.yml b/lib/twr_ss_ack/syscfg.yml
|
||||
index 4a27a9c..52177a2 100644
|
||||
--- a/lib/twr_ss_ack/syscfg.yml
|
||||
+++ b/lib/twr_ss_ack/syscfg.yml
|
||||
@@ -10,3 +10,6 @@ syscfg.defs:
|
||||
TWR_SS_ACK_RX_TIMEOUT:
|
||||
description: 'TOA timeout delay for SS TWR (usec)'
|
||||
value: ((uint16_t)0x100)
|
||||
+ TWR_SS_ACK_STATS:
|
||||
+ description: 'Enable statistics for the twr_ss_ack module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ss_ext/src/twr_ss_ext.c b/lib/twr_ss_ext/src/twr_ss_ext.c
|
||||
index 6e55a13..2ea3384 100644
|
||||
--- a/lib/twr_ss_ext/src/twr_ss_ext.c
|
||||
+++ b/lib/twr_ss_ext/src/twr_ss_ext.c
|
||||
@@ -74,6 +74,7 @@ static struct uwb_mac_interface g_cbs[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_EXT_STATS)
|
||||
STATS_SECT_START(twr_ss_ext_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(tx_error)
|
||||
@@ -85,6 +86,10 @@ STATS_NAME_START(twr_ss_ext_stat_section)
|
||||
STATS_NAME_END(twr_ss_ext_stat_section)
|
||||
|
||||
static STATS_SECT_DECL(twr_ss_ext_stat_section) g_twr_ss_ext_stat;
|
||||
+#define SS_STATS_INC(__X) STATS_INC(g_twr_ss_ext_stat __X)
|
||||
+#else
|
||||
+#define SS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_SS_EXT_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -140,12 +145,14 @@ twr_ss_ext_pkg_init(void)
|
||||
uwb_rng_append_config(g_cbs[i].inst_ptr, &g_rng_cfgs[i]);
|
||||
}
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_EXT_STATS)
|
||||
rc = stats_init(
|
||||
STATS_HDR(g_twr_ss_ext_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_twr_ss_ext_stat, STATS_SIZE_32),
|
||||
STATS_NAME_INIT_PARMS(twr_ss_ext_stat_section));
|
||||
rc |= stats_register("twr_ss_ext", STATS_HDR(g_twr_ss_ext_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +248,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_set_delay_start(inst, txd.response_tx_delay);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error){
|
||||
- STATS_INC(g_twr_ss_ext_stat, tx_error);
|
||||
+ SS_STATS_INC(tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
}
|
||||
/* Setup when to listen for response, relative the end of our transmitted frame */
|
||||
@@ -284,12 +291,12 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
uwb_set_delay_start(inst, txd.response_tx_delay);
|
||||
|
||||
if (uwb_start_tx(inst).start_tx_error){
|
||||
- STATS_INC(g_twr_ss_ext_stat, tx_error);
|
||||
+ SS_STATS_INC(tx_error);
|
||||
dpl_sem_release(&rng->sem);
|
||||
rng_issue_complete(inst);
|
||||
}
|
||||
else{
|
||||
- STATS_INC(g_twr_ss_ext_stat, complete);
|
||||
+ SS_STATS_INC(complete);
|
||||
rng->control.complete_after_tx = 1;
|
||||
}
|
||||
break;
|
||||
@@ -301,7 +308,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
if (inst->frame_len != sizeof(twr_frame_final_t))
|
||||
break;
|
||||
|
||||
- STATS_INC(g_twr_ss_ext_stat, complete);
|
||||
+ SS_STATS_INC(complete);
|
||||
dpl_sem_release(&rng->sem);
|
||||
rng_issue_complete(inst);
|
||||
break;
|
||||
diff --git a/lib/twr_ss_ext/syscfg.yml b/lib/twr_ss_ext/syscfg.yml
|
||||
index fcca45a..a71963f 100644
|
||||
--- a/lib/twr_ss_ext/syscfg.yml
|
||||
+++ b/lib/twr_ss_ext/syscfg.yml
|
||||
@@ -10,3 +10,6 @@ syscfg.defs:
|
||||
TWR_SS_EXT_RX_TIMEOUT:
|
||||
description: 'TOA timeout delay for SS EXT TWR (usec)'
|
||||
value: ((uint16_t)0x40)
|
||||
+ TWR_SS_EXT_STATS:
|
||||
+ description: 'Enable statistics for the twr_ss_ext module'
|
||||
+ value: 1
|
||||
diff --git a/lib/twr_ss_ext_nrng/src/twr_ss_ext_nrng.c b/lib/twr_ss_ext_nrng/src/twr_ss_ext_nrng.c
|
||||
index 3808785..759f928 100644
|
||||
--- a/lib/twr_ss_ext_nrng/src/twr_ss_ext_nrng.c
|
||||
+++ b/lib/twr_ss_ext_nrng/src/twr_ss_ext_nrng.c
|
||||
@@ -67,6 +67,7 @@ static struct uwb_mac_interface g_cbs = {
|
||||
.final_cb = tx_final_cb,
|
||||
};
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_EXT_NRNG_STATS)
|
||||
STATS_SECT_START(twr_ss_ext_nrng_stat_section)
|
||||
STATS_SECT_ENTRY(complete)
|
||||
STATS_SECT_ENTRY(rx_error)
|
||||
@@ -80,6 +81,10 @@ STATS_NAME_START(twr_ss_ext_nrng_stat_section)
|
||||
STATS_NAME_END(twr_ss_ext_nrng_stat_section)
|
||||
|
||||
static STATS_SECT_DECL(twr_ss_ext_nrng_stat_section) g_stat;
|
||||
+#define SS_STATS_INC(__X) STATS_INC(g_stat, __X)
|
||||
+#else
|
||||
+#define SS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
|
||||
static struct uwb_rng_config g_config = {
|
||||
.tx_holdoff_delay = MYNEWT_VAL(TWR_SS_EXT_NRNG_TX_HOLDOFF), // Send Time delay in usec.
|
||||
@@ -107,12 +112,14 @@ void twr_ss_ext_nrng_pkg_init(void)
|
||||
uwb_mac_append_interface(uwb_dev_idx_lookup(0), &g_cbs);
|
||||
nrng_append_config(nrng, &g_rng_cfgs);
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_EXT_NRNG_STATS)
|
||||
int rc = stats_init(
|
||||
STATS_HDR(g_stat),
|
||||
STATS_SIZE_INIT_PARMS(g_stat, STATS_SIZE_32),
|
||||
STATS_NAME_INIT_PARMS(twr_ss_ext_nrng_stat_section));
|
||||
rc |= stats_register("ss_ext_nrng", STATS_HDR(g_stat));
|
||||
assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +151,7 @@ rx_error_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs){
|
||||
}
|
||||
struct uwb_rng_instance * rng = inst->rng;
|
||||
if(os_sem_get_count(&rng->sem) == 0){
|
||||
- STATS_INC(g_stat, rx_error);
|
||||
+ SS_STATS_INC(rx_error);
|
||||
os_error_t err = os_sem_release(&rng->sem);
|
||||
assert(err == OS_OK);
|
||||
return true;
|
||||
diff --git a/lib/twr_ss_ext_nrng/syscfg.yml b/lib/twr_ss_ext_nrng/syscfg.yml
|
||||
index 997def3..ff8c789 100644
|
||||
--- a/lib/twr_ss_ext_nrng/syscfg.yml
|
||||
+++ b/lib/twr_ss_ext_nrng/syscfg.yml
|
||||
@@ -12,6 +12,9 @@ syscfg.defs:
|
||||
value: ((uint16_t)0x10)
|
||||
TWR_SS_EXT_NRNG_TX_GUARD_DELAY:
|
||||
value: ((uint32_t)0x90)
|
||||
+ TWR_SS_EXT_NRNG_STATS:
|
||||
+ description: 'Enable statistics for the twr_ss_ext_nrng module'
|
||||
+ value: 1
|
||||
CELL_ENABLED:
|
||||
description: 'Cell network model on slot decoding'
|
||||
value: 0
|
||||
diff --git a/lib/twr_ss_nrng/src/twr_ss_nrng.c b/lib/twr_ss_nrng/src/twr_ss_nrng.c
|
||||
index b6550f6..f5a60fc 100644
|
||||
--- a/lib/twr_ss_nrng/src/twr_ss_nrng.c
|
||||
+++ b/lib/twr_ss_nrng/src/twr_ss_nrng.c
|
||||
@@ -52,6 +52,24 @@
|
||||
#define DIAGMSG(s,u)
|
||||
#endif
|
||||
|
||||
+#if MYNEWT_VAL(TWR_SS_NRNG_STATS)
|
||||
+STATS_SECT_START(twr_ss_nrng_stat_section)
|
||||
+ STATS_SECT_ENTRY(complete)
|
||||
+ STATS_SECT_ENTRY(start_tx_error)
|
||||
+STATS_SECT_END
|
||||
+
|
||||
+STATS_NAME_START(twr_ss_nrng_stat_section)
|
||||
+ STATS_NAME(twr_ss_nrng_stat_section, complete)
|
||||
+ STATS_NAME(twr_ss_nrng_stat_section, start_tx_error)
|
||||
+STATS_NAME_END(twr_ss_nrng_stat_section)
|
||||
+
|
||||
+STATS_SECT_DECL(twr_ss_nrng_stat_section) g_twr_ss_nrng_stat;
|
||||
+#define SS_STATS_INC(__X) STATS_INC(g_twr_ss_nrng_stat, __X)
|
||||
+#else
|
||||
+#define SS_STATS_INC(__X) {}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
static bool rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs);
|
||||
static bool rx_timeout_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs);
|
||||
static bool rx_error_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs);
|
||||
@@ -93,6 +111,17 @@ void twr_ss_nrng_pkg_init(void)
|
||||
g_cbs.inst_ptr = nrng;
|
||||
uwb_mac_append_interface(udev, &g_cbs);
|
||||
nrng_append_config(nrng, &g_rng_cfgs);
|
||||
+
|
||||
+#if MYNEWT_VAL(TWR_SS_NRNG_STATS)
|
||||
+ int rc = stats_init(
|
||||
+ STATS_HDR(g_twr_ss_nrng_stat),
|
||||
+ STATS_SIZE_INIT_PARMS(g_twr_ss_nrng_stat, STATS_SIZE_32),
|
||||
+ STATS_NAME_INIT_PARMS(twr_ss_nrng_stat_section));
|
||||
+ assert(rc == 0);
|
||||
+
|
||||
+ rc = stats_register("twr_ss_nrng", STATS_HDR(g_twr_ss_nrng_stat));
|
||||
+ assert(rc == 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +155,7 @@ rx_error_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
return false;
|
||||
|
||||
if(dpl_sem_get_count(&nrng->sem) == 0){
|
||||
- NRNG_STATS_INC(rx_error);
|
||||
+ SS_STATS_INC(rx_error);
|
||||
dpl_error_t err = dpl_sem_release(&nrng->sem);
|
||||
assert(err == DPL_OK);
|
||||
return true;
|
||||
@@ -150,7 +179,7 @@ rx_timeout_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
return false;
|
||||
|
||||
if(dpl_sem_get_count(&nrng->sem) == 0){
|
||||
- NRNG_STATS_INC(rx_timeout);
|
||||
+ SS_STATS_INC(rx_timeout);
|
||||
// In the case of a NRNG timeout is used to mark the end of the request
|
||||
// and is used to call the completion callback
|
||||
if(!(SLIST_EMPTY(&inst->interface_cbs))){
|
||||
@@ -179,7 +208,7 @@ reset_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
if(dpl_sem_get_count(&nrng->sem) == 0){
|
||||
dpl_error_t err = dpl_sem_release(&nrng->sem);
|
||||
assert(err == DPL_OK);
|
||||
- NRNG_STATS_INC(reset);
|
||||
+ SS_STATS_INC(reset);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -203,7 +232,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
|
||||
if(dpl_sem_get_count(&nrng->sem) == 1){
|
||||
// unsolicited inbound
|
||||
- NRNG_STATS_INC(rx_unsolicited);
|
||||
+ SS_STATS_INC(rx_unsolicited);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -213,7 +242,7 @@ rx_complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
if (_frame->dst_address != inst->my_short_address && _frame->dst_address != UWB_BROADCAST_ADDRESS)
|
||||
return true;
|
||||
|
||||
- NRNG_STATS_INC(rx_complete);
|
||||
+ SS_STATS_INC(rx_complete);
|
||||
|
||||
switch(_frame->code){
|
||||
case UWB_DATA_CODE_SS_TWR_NRNG:
|
||||
diff --git a/lib/twr_ss_nrng/syscfg.yml b/lib/twr_ss_nrng/syscfg.yml
|
||||
index 7ef5969..a296efd 100644
|
||||
--- a/lib/twr_ss_nrng/syscfg.yml
|
||||
+++ b/lib/twr_ss_nrng/syscfg.yml
|
||||
@@ -12,6 +12,9 @@ syscfg.defs:
|
||||
value: ((uint16_t)0x10)
|
||||
TWR_SS_NRNG_TX_GUARD_DELAY:
|
||||
value: ((uint32_t)0x120)
|
||||
+ TWR_SS_NRNG_STATS:
|
||||
+ description: 'Enable statistics for the twr_ss_nrng module'
|
||||
+ value: 1
|
||||
CELL_ENABLED:
|
||||
description: 'Cell network model on slot decoding'
|
||||
value: 1
|
||||
--
|
||||
2.28.0
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
From 478d952b17c33ed5644172c9b4aebf4cdf7bec62 Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Fri, 14 Aug 2020 15:04:20 +0200
|
||||
Subject: [PATCH 3/7] lib/tofdb/: use DPL_ENOENT instead of OS_ENOENT
|
||||
|
||||
---
|
||||
lib/tofdb/src/tofdb.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/tofdb/src/tofdb.c b/lib/tofdb/src/tofdb.c
|
||||
index e6c8015..7d75942 100644
|
||||
--- a/lib/tofdb/src/tofdb.c
|
||||
+++ b/lib/tofdb/src/tofdb.c
|
||||
@@ -28,7 +28,7 @@ int tofdb_get_tof(uint16_t addr, uint32_t *tof)
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
- return OS_ENOENT;
|
||||
+ return DPL_ENOENT;
|
||||
ret:
|
||||
return OS_OK;
|
||||
}
|
||||
--
|
||||
2.28.0
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
From 2304bef6c63b15411fae3050554edc0538ae93d9 Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Fri, 14 Aug 2020 15:08:22 +0200
|
||||
Subject: [PATCH 4/7] sys/uwbcfg: use DPL_ENOENT instead of OS_ENOENT
|
||||
|
||||
---
|
||||
sys/uwbcfg/src/uwbcfg.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/sys/uwbcfg/src/uwbcfg.c b/sys/uwbcfg/src/uwbcfg.c
|
||||
index 595c19b..4c4678e 100644
|
||||
--- a/sys/uwbcfg/src/uwbcfg.c
|
||||
+++ b/sys/uwbcfg/src/uwbcfg.c
|
||||
@@ -149,7 +149,7 @@ uwbcfg_set(int argc, char **argv, char *val)
|
||||
return CONF_VALUE_SET(val, CONF_STRING, g_uwb_config[i]);
|
||||
}
|
||||
}
|
||||
- return OS_ENOENT;
|
||||
+ return DPL_ENOENT;
|
||||
}
|
||||
|
||||
char*
|
||||
--
|
||||
2.28.0
|
||||
|
||||
@ -0,0 +1,78 @@
|
||||
From 86db74c73938d86a3bcf581af2174991cef632fe Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Fri, 14 Aug 2020 15:11:06 +0200
|
||||
Subject: [PATCH 5/7] treewide: use dpl_log.h instaed of log.h to avoid
|
||||
conflict
|
||||
|
||||
---
|
||||
lib/panmaster/src/panmaster.c | 10 +++++-----
|
||||
sys/uwbcfg/src/uwbcfg.c | 2 +-
|
||||
sys/uwbcfg/src/uwbcfg_priv.h | 10 +++++-----
|
||||
3 files changed, 11 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/lib/panmaster/src/panmaster.c b/lib/panmaster/src/panmaster.c
|
||||
index a1234b6..f2d9fef 100644
|
||||
--- a/lib/panmaster/src/panmaster.c
|
||||
+++ b/lib/panmaster/src/panmaster.c
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <dpl/dpl.h>
|
||||
#include <syscfg/syscfg.h>
|
||||
#include <sysinit/sysinit.h>
|
||||
-#include <log/log.h>
|
||||
+#include <log/dpl_log.h>
|
||||
#include <config/config.h>
|
||||
|
||||
#include "panmaster/panmaster.h"
|
||||
@@ -23,10 +23,10 @@ static uint16_t pan_id = 0x0000;
|
||||
static volatile int nodes_loaded = 0;
|
||||
|
||||
#define LOG_MODULE_PAN_MASTER (91)
|
||||
-#define PM_INFO(...) LOG_INFO(&_log, LOG_MODULE_PAN_MASTER, __VA_ARGS__)
|
||||
-#define PM_DEBUG(...) LOG_DEBUG(&_log, LOG_MODULE_PAN_MASTER, __VA_ARGS__)
|
||||
-#define PM_WARN(...) LOG_WARN(&_log, LOG_MODULE_PAN_MASTER, __VA_ARGS__)
|
||||
-#define PM_ERR(...) LOG_ERROR(&_log, LOG_MODULE_PAN_MASTER, __VA_ARGS__)
|
||||
+#define PM_INFO(...) LOG_INFO(__VA_ARGS__)
|
||||
+#define PM_DEBUG(...) LOG_DEBUG(__VA_ARGS__)
|
||||
+#define PM_WARN(...) LOG_WARN(__VA_ARGS__)
|
||||
+#define PM_ERR(...) LOG_ERROR(__VA_ARGS__)
|
||||
static struct log _log;
|
||||
|
||||
/*
|
||||
diff --git a/sys/uwbcfg/src/uwbcfg.c b/sys/uwbcfg/src/uwbcfg.c
|
||||
index 4c4678e..c7c97ea 100644
|
||||
--- a/sys/uwbcfg/src/uwbcfg.c
|
||||
+++ b/sys/uwbcfg/src/uwbcfg.c
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <dpl/dpl.h>
|
||||
-#include <log/log.h>
|
||||
+#include <log/dpl_log.h>
|
||||
#include <syscfg/syscfg.h>
|
||||
#include <sysinit/sysinit.h>
|
||||
#include <config/config.h>
|
||||
diff --git a/sys/uwbcfg/src/uwbcfg_priv.h b/sys/uwbcfg/src/uwbcfg_priv.h
|
||||
index 8f7f05b..4158b34 100644
|
||||
--- a/sys/uwbcfg/src/uwbcfg_priv.h
|
||||
+++ b/sys/uwbcfg/src/uwbcfg_priv.h
|
||||
@@ -20,12 +20,12 @@
|
||||
#ifndef __UWBCFG_PRIV_H_
|
||||
#define __UWBCFG_PRIV_H_
|
||||
|
||||
-#include <log/log.h>
|
||||
+#include <log/dpl_log.h>
|
||||
#define LOG_MODULE_UWBCFG (92)
|
||||
-#define UC_INFO(...) LOG_INFO(&_uwbcfg_log, LOG_MODULE_UWBCFG, __VA_ARGS__)
|
||||
-#define UC_DEBUG(...) LOG_DEBUG(&_uwbcfg_log, LOG_MODULE_UWBCFG, __VA_ARGS__)
|
||||
-#define UC_WARN(...) LOG_WARN(&_uwbcfg_log, LOG_MODULE_UWBCFG, __VA_ARGS__)
|
||||
-#define UC_ERR(...) LOG_ERROR(&_uwbcfg_log, LOG_MODULE_UWBCFG, __VA_ARGS__)
|
||||
+#define UC_INFO(...) LOG_INFO(__VA_ARGS__)
|
||||
+#define UC_DEBUG(...) LOG_DEBUG(__VA_ARGS__)
|
||||
+#define UC_WARN(...) LOG_WARN(__VA_ARGS__)
|
||||
+#define UC_ERR(...) LOG_ERROR(__VA_ARGS__)
|
||||
|
||||
enum {
|
||||
CFGSTR_CH=0,
|
||||
--
|
||||
2.28.0
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
From b7dd28c1fa7610baa00950e8798392102dfd69f9 Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Thu, 17 Sep 2020 17:00:09 +0200
|
||||
Subject: [PATCH 6/7] lib/json/src: use fmt to avoid newlib issue
|
||||
|
||||
---
|
||||
lib/json/src/json_encode.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lib/json/src/json_encode.c b/lib/json/src/json_encode.c
|
||||
index 4de928e..377fd18 100644
|
||||
--- a/lib/json/src/json_encode.c
|
||||
+++ b/lib/json/src/json_encode.c
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
+#include "fmt.h"
|
||||
+
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/kernel.h>
|
||||
#else
|
||||
@@ -70,13 +72,11 @@ json_encode_value(struct json_encoder *encoder, struct json_value *jv)
|
||||
encoder->je_write(encoder->je_arg, encoder->je_encode_buf, len);
|
||||
break;
|
||||
case JSON_VALUE_TYPE_UINT64:
|
||||
- len = sprintf(encoder->je_encode_buf, "%" PRIu64,
|
||||
- jv->jv_val.u);
|
||||
+ len = fmt_u64_dec(encoder->je_encode_buf, jv->jv_val.u);
|
||||
encoder->je_write(encoder->je_arg, encoder->je_encode_buf, len);
|
||||
break;
|
||||
case JSON_VALUE_TYPE_INT64:
|
||||
- len = sprintf(encoder->je_encode_buf, "%" PRIi64,
|
||||
- jv->jv_val.u);
|
||||
+ len = fmt_s64_dec(encoder->je_encode_buf, jv->jv_val.u);
|
||||
encoder->je_write(encoder->je_arg, encoder->je_encode_buf, len);
|
||||
break;
|
||||
case JSON_VALUE_TYPE_FLOAT64:
|
||||
--
|
||||
2.28.0
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
From f51123d3cfcd811090367a65d5bf029897aceb98 Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Mon, 21 Sep 2020 13:42:56 +0200
|
||||
Subject: [PATCH 7/7] lib/uwb_rng: always set rssi to vrssi[0]
|
||||
|
||||
---
|
||||
lib/uwb_rng/src/uwb_rng.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/lib/uwb_rng/src/uwb_rng.c b/lib/uwb_rng/src/uwb_rng.c
|
||||
index ccc91c5..3218f61 100644
|
||||
--- a/lib/uwb_rng/src/uwb_rng.c
|
||||
+++ b/lib/uwb_rng/src/uwb_rng.c
|
||||
@@ -981,12 +981,17 @@ complete_cb(struct uwb_dev * inst, struct uwb_mac_interface * cbs)
|
||||
frame->local.rssi = uwb_calc_rssi(inst, inst->rxdiag);
|
||||
frame->local.fppl = uwb_calc_fppl(inst, inst->rxdiag);
|
||||
|
||||
+
|
||||
if (inst->capabilities.sts) {
|
||||
frame->local.flags.has_sts = inst->config.rx.stsMode != DWT_STS_MODE_OFF;
|
||||
frame->local.flags.has_valid_sts = !(inst->status.sts_ts_error || inst->status.sts_pream_error);
|
||||
frame->local.vrssi[0] = frame->local.rssi;
|
||||
frame->local.vrssi[1] = uwb_calc_seq_rssi(inst, inst->rxdiag, UWB_RXDIAG_STS);
|
||||
frame->local.vrssi[2] = uwb_calc_seq_rssi(inst, inst->rxdiag, UWB_RXDIAG_STS2);
|
||||
+ } else {
|
||||
+ frame->local.vrssi[0] = frame->local.rssi;
|
||||
+ frame->local.vrssi[1] = DPL_FLOAT32_NAN();
|
||||
+ frame->local.vrssi[2] = DPL_FLOAT32_NAN();
|
||||
}
|
||||
|
||||
/* Postprocess in thread context */
|
||||
--
|
||||
2.28.0
|
||||
|
||||
1012
pkg/uwb-core/patches/0008-porting-dpl-add-riot-files.patch
Normal file
1012
pkg/uwb-core/patches/0008-porting-dpl-add-riot-files.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -113,6 +113,11 @@ void auto_init(void)
|
||||
extern void openwsn_bootstrap(void);
|
||||
openwsn_bootstrap();
|
||||
}
|
||||
if (IS_USED(MODULE_AUTO_INIT_UWB_CORE)) {
|
||||
LOG_DEBUG("Bootstrapping uwb core.\n");
|
||||
extern void uwb_core_init(void);
|
||||
uwb_core_init();
|
||||
}
|
||||
if (IS_USED(MODULE_GCOAP) &&
|
||||
!IS_ACTIVE(CONFIG_GCOAP_NO_AUTO_INIT)) {
|
||||
LOG_DEBUG("Auto init gcoap.\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user