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

pkg/uwb-core: allow using event-thread

This commit is contained in:
Francisco Molina 2021-09-06 11:00:54 +02:00
parent 45add49342
commit d0e8d3aa24
5 changed files with 36 additions and 26 deletions

View File

@ -74,6 +74,10 @@ config MODULE_UWB-CORE_UWBCFG
bool "uwb-core configuration module"
select MODULE_UWB-CORE_CONFIG
config MODULE_UWB-CORE_EVENT_THREAD
bool "Use event-thread loop as uwb-core's event loop"
select MODULE_UWB-CORE_CONFIG
config MODULE_UWB-CORE_CONFIG
bool

View File

@ -30,6 +30,10 @@ ifneq (,$(filter uwb-core_dpl,$(USEMODULE)))
endif
endif
ifneq (,$(filter uwb-core_event_thread,$(USEMODULE)))
USEMODULE += event_thread
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

View File

@ -19,43 +19,37 @@
#include "thread.h"
#include "event.h"
#include "event/callback.h"
#include "uwb_core.h"
#include "os/os_cputime.h"
#include "hal/hal_timer.h"
#ifndef UWB_CORE_STACKSIZE
#define UWB_CORE_STACKSIZE (THREAD_STACKSIZE_LARGE)
#endif
#ifndef UWB_CORE_PRIO
#define UWB_CORE_PRIO (THREAD_PRIORITY_MAIN - 5)
#endif
static char _stack_uwb_core[UWB_CORE_STACKSIZE];
#if !IS_USED(MODULE_UWB_CORE_EVENT_THREAD)
static event_queue_t _queue;
static char _stack_uwb_core[UWB_CORE_STACKSIZE];
static void *_uwb_core_thread(void *arg)
{
(void)arg;
event_queue_init(&_queue);
event_loop(&_queue);
/* never reached */
return NULL;
}
#endif
event_queue_t *uwb_core_get_eventq(void)
{
#if !IS_USED(MODULE_UWB_CORE_EVENT_THREAD)
return &_queue;
#else
return UWB_CORE_EVENT_THREAD_QUEUE;
#endif
}
void uwb_core_riot_init(void)
{
#if !IS_USED(MODULE_UWB_CORE_EVENT_THREAD)
thread_create(_stack_uwb_core, sizeof(_stack_uwb_core),
UWB_CORE_PRIO,
THREAD_CREATE_STACKTEST,
_uwb_core_thread, NULL,
"uwb_core");
"uwb_core_event");
#endif
}

View File

@ -53,13 +53,11 @@ void uwb_core_init(void)
extern void uwb_rng_pkg_init(void);
uwb_rng_pkg_init();
#endif
/* uwb configuration module */
#if IS_USED(MODULE_UWB_CORE_UWBCFG)
extern int uwbcfg_pkg_init(void);
uwbcfg_pkg_init();
#endif
/* ranging algorithms */
#if IS_USED(MODULE_UWB_CORE_TWR_SS)
twr_ss_pkg_init();

View File

@ -21,23 +21,33 @@
#include <stdint.h>
#include "event.h"
#if IS_USED(MODULE_UWB_CORE_EVENT_THREAD)
#include "event/thread"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Priority used for
* @brief The event queue if uwb_core_event_thread is used
*/
#ifndef UWB_CORE__PRIO
#define UWB_CORE__PRIO (THREAD_PRIORITY_MAIN - 2)
#ifndef UWB_CORE_EVENT_THREAD_QUEUE
#define UWB_CORE_EVENT_THREAD_QUEUE EVENT_PRIO_MEDIUM
#endif
/**
* @brief Stacksize used for
* @brief Priority used for uwb-core event queue
*/
#ifndef UWB_CORE__STACKSIZE
#define UWB_CORE__STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef UWB_CORE_PRIO
#define UWB_CORE_PRIO (THREAD_PRIORITY_MAIN - 2)
#endif
/**
* @brief Stacksize used for uwb-core event queue
*/
#ifndef UWB_CORE_STACKSIZE
#define UWB_CORE_STACKSIZE (THREAD_STACKSIZE_LARGE)
#endif
/**
@ -48,8 +58,8 @@ 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.
* if uwb_core_event_thread is used then the event_thread module queue will be
* used. Otherwise uwb-core will start and handle its own event queue.
*
* @return the default event queue.
*/