mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge #19636
19636: sys: model ecc, evtimer, pipe and shell_lock in kconfig r=aabadie a=aabadie Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
This commit is contained in:
commit
7d16a1b289
@ -64,7 +64,6 @@ PSEUDOMODULES += event_%
|
||||
PSEUDOMODULES += event_timeout
|
||||
PSEUDOMODULES += event_timeout_ztimer
|
||||
PSEUDOMODULES += evtimer_mbox
|
||||
PSEUDOMODULES += evtimer_on_ztimer
|
||||
PSEUDOMODULES += fatfs_vfs_format
|
||||
PSEUDOMODULES += fmt_%
|
||||
PSEUDOMODULES += gcoap_forward_proxy
|
||||
|
@ -74,6 +74,8 @@ choice LOG
|
||||
endchoice
|
||||
|
||||
rsource "coding/Kconfig"
|
||||
rsource "ecc/Kconfig"
|
||||
rsource "evtimer/Kconfig"
|
||||
rsource "log_color/Kconfig"
|
||||
rsource "log_printfnoformat/Kconfig"
|
||||
rsource "luid/Kconfig"
|
||||
@ -85,6 +87,7 @@ rsource "net/Kconfig"
|
||||
rsource "od/Kconfig"
|
||||
rsource "oneway-malloc/Kconfig"
|
||||
rsource "phydat/Kconfig"
|
||||
rsource "pipe/Kconfig"
|
||||
rsource "pm_layered/Kconfig"
|
||||
rsource "posix/Kconfig"
|
||||
rsource "preprocessor/Kconfig"
|
||||
@ -100,6 +103,7 @@ rsource "sema_inv/Kconfig"
|
||||
rsource "senml/Kconfig"
|
||||
rsource "seq/Kconfig"
|
||||
rsource "shell/Kconfig"
|
||||
rsource "shell_lock/Kconfig"
|
||||
rsource "ssp/Kconfig"
|
||||
rsource "test_utils/Kconfig"
|
||||
rsource "timex/Kconfig"
|
||||
|
@ -998,14 +998,7 @@ ifneq (,$(filter ztimer64%,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter evtimer,$(USEMODULE)))
|
||||
ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE)))
|
||||
USEMODULE += ztimer_msec
|
||||
else
|
||||
USEMODULE += xtimer
|
||||
ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
|
||||
USEMODULE += evtimer_on_ztimer
|
||||
endif
|
||||
endif
|
||||
USEMODULE += ztimer_msec
|
||||
endif
|
||||
|
||||
# handle xtimer's deps. Needs to be done *after* ztimer
|
||||
|
35
sys/ecc/Kconfig
Normal file
35
sys/ecc/Kconfig
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2023 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.
|
||||
#
|
||||
|
||||
menuconfig MODULE_ECC
|
||||
bool "Error Correction Code (ECC) algorithms"
|
||||
depends on TEST_KCONFIG
|
||||
help
|
||||
Provides Golay1412, Hamming256 and Repetition algorithms.
|
||||
|
||||
if MODULE_ECC
|
||||
|
||||
menu "ECC algorithms"
|
||||
|
||||
config MODULE_ECC_GOLAY1412
|
||||
bool "Golay1412 Error Correction Code (ECC) algorithm"
|
||||
help
|
||||
Provides Golay1412 ECC algorithm.
|
||||
|
||||
config MODULE_ECC_HAMMING256
|
||||
bool "Hamming256 Error Correction Code (ECC) algorithm"
|
||||
help
|
||||
Provides Hamming256 ECC algorithm.
|
||||
|
||||
config MODULE_ECC_REPETITION
|
||||
bool "Repetition Error Correction Code (ECC) algorithm"
|
||||
help
|
||||
Provides Repetition ECC algorithm.
|
||||
|
||||
endmenu # ECC algorithms
|
||||
|
||||
endif
|
19
sys/evtimer/Kconfig
Normal file
19
sys/evtimer/Kconfig
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2023 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.
|
||||
#
|
||||
|
||||
config MODULE_EVTIMER
|
||||
bool "Event timer module"
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
config MODULE_EVTIMER_MBOX
|
||||
bool "Use message box"
|
||||
select MODULE_CORE_MBOX
|
||||
select MODULE_EVTIMER
|
||||
help
|
||||
Use message box to implement event timer.
|
@ -93,19 +93,9 @@ static void _del_event_from_list(evtimer_t *evtimer, evtimer_event_t *event)
|
||||
static void _set_timer(evtimer_t *evtimer)
|
||||
{
|
||||
evtimer_event_t *next_event = evtimer->events;
|
||||
|
||||
#if IS_USED(MODULE_EVTIMER_ON_ZTIMER)
|
||||
evtimer->base = ztimer_set(ZTIMER_MSEC, &evtimer->timer, next_event->offset);
|
||||
DEBUG("evtimer: now=%" PRIu32 " ms setting ztimer to %" PRIu32 " ms\n",
|
||||
evtimer->base, next_event->offset);
|
||||
#else
|
||||
uint64_t offset_us = (uint64_t)next_event->offset * US_PER_MS;
|
||||
|
||||
DEBUG("evtimer: now=%" PRIu32 " us setting xtimer to %" PRIu32 ":%" PRIu32 " us\n",
|
||||
xtimer_now_usec(), (uint32_t)(offset_us >> 32), (uint32_t)(offset_us));
|
||||
|
||||
xtimer_set64(&evtimer->timer, offset_us);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _update_timer(evtimer_t *evtimer)
|
||||
@ -114,15 +104,10 @@ static void _update_timer(evtimer_t *evtimer)
|
||||
_set_timer(evtimer);
|
||||
}
|
||||
else {
|
||||
#if IS_USED(MODULE_EVTIMER_ON_ZTIMER)
|
||||
ztimer_remove(ZTIMER_MSEC, &evtimer->timer);
|
||||
#else
|
||||
xtimer_remove(&evtimer->timer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if IS_USED(MODULE_EVTIMER_ON_ZTIMER)
|
||||
static void _update_head_offset(evtimer_t *evtimer)
|
||||
{
|
||||
if (evtimer->events) {
|
||||
@ -137,23 +122,6 @@ static void _update_head_offset(evtimer_t *evtimer)
|
||||
evtimer->base = now;
|
||||
}
|
||||
}
|
||||
#else /* IS_USED(MODULE_EVTIMER_ON_ZTIMER) */
|
||||
static uint32_t _get_offset(xtimer_t *timer)
|
||||
{
|
||||
uint64_t left = xtimer_left_usec(timer);
|
||||
/* add half of 125 so integer division rounds to nearest */
|
||||
return div_u64_by_125((left >> 3) + 62);
|
||||
}
|
||||
|
||||
static void _update_head_offset(evtimer_t *evtimer)
|
||||
{
|
||||
if (evtimer->events) {
|
||||
evtimer_event_t *event = evtimer->events;
|
||||
event->offset = _get_offset(&evtimer->timer);
|
||||
DEBUG("evtimer: _update_head_offset(): new head offset %" PRIu32 "\n", event->offset);
|
||||
}
|
||||
}
|
||||
#endif /* !IS_USED(MODULE_EVTIMER_ON_ZTIMER) */
|
||||
|
||||
void evtimer_add(evtimer_t *evtimer, evtimer_event_t *event)
|
||||
{
|
||||
|
@ -15,24 +15,20 @@
|
||||
*
|
||||
* @note Experimental and likely to replaced with unified timer API
|
||||
*
|
||||
* RIOT's main timer subsystem is @ref sys_xtimer "xtimer", but for many
|
||||
* applications @ref sys_xtimer "xtimer's" 64-bit absolute time values are
|
||||
* wasteful or clumsy to use.
|
||||
*
|
||||
* Compared to @ref sys_xtimer "xtimer", evtimer offers:
|
||||
* RIOT's main timer subsystem is @ref sys_ztimer "ztimer" but compared to
|
||||
* @ref sys_ztimer "ztimer", evtimer offers:
|
||||
*
|
||||
* - only relative 32-bit millisecond timer values
|
||||
* Events can be scheduled with a relative offset of up to ~49.7 days in the
|
||||
* future.
|
||||
* **For time-critical stuff, use @ref sys_xtimer "xtimer"!**
|
||||
* **For time-critical stuff, use @ref sys_ztimer "ztimer"!**
|
||||
* - more flexible, "intrusive" timer type @ref evtimer_event_t only contains
|
||||
* the necessary fields, which can be extended as needed, and handlers define
|
||||
* actions taken on timer triggers. Check out @ref evtimer_msg_event_t as
|
||||
* example.
|
||||
* - uses @ref sys_xtimer "xtimer" as backend by default. Alternatively, with
|
||||
* the pseudomodule "evtimer_on_ztimer" compiled in, evtimer is backend by
|
||||
* @ref sys_ztimer "ZTIMER_MSEC".
|
||||
*
|
||||
* - when a number of timeouts with the same callback function need to be
|
||||
* scheduled, evtimer is using less RAM (due to storing the callback function
|
||||
* only once), while each ztimer has a function pointer for the callback.
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -48,13 +44,7 @@
|
||||
#include <stdint.h>
|
||||
#include "modules.h"
|
||||
|
||||
#if IS_USED(MODULE_EVTIMER_ON_ZTIMER)
|
||||
#include "ztimer.h"
|
||||
#else
|
||||
#include "xtimer.h"
|
||||
#endif
|
||||
|
||||
#include "timex.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -77,12 +67,8 @@ typedef void(*evtimer_callback_t)(evtimer_event_t* event);
|
||||
* @brief Event timer
|
||||
*/
|
||||
typedef struct {
|
||||
#if IS_USED(MODULE_EVTIMER_ON_ZTIMER)
|
||||
ztimer_t timer; /**< Timer */
|
||||
uint32_t base; /**< Absolute time the first event is built on */
|
||||
#else
|
||||
xtimer_t timer; /**< Timer */
|
||||
#endif
|
||||
evtimer_callback_t callback; /**< Handler function for this evtimer's
|
||||
event type */
|
||||
evtimer_event_t *events; /**< Event queue */
|
||||
@ -128,11 +114,7 @@ void evtimer_print(const evtimer_t *evtimer);
|
||||
*/
|
||||
static inline uint32_t evtimer_now_msec(void)
|
||||
{
|
||||
#if IS_USED(MODULE_EVTIMER_ON_ZTIMER)
|
||||
return ztimer_now(ZTIMER_MSEC);
|
||||
#else
|
||||
return xtimer_now_usec64() / US_PER_MS;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -26,6 +26,7 @@
|
||||
/* prevent cascading include error to xtimer if it is not compiled in or not
|
||||
* supported by board */
|
||||
#if IS_USED(MODULE_EVTIMER)
|
||||
#include "timex.h"
|
||||
#include "evtimer.h"
|
||||
#endif
|
||||
#include "net/ipv6/addr.h"
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
||||
* Instead terminate RIOT, which is also the behavior a user would
|
||||
* expect from a CLI application.
|
||||
*/
|
||||
# if defined(CPU_NATIVE) && !IS_ACTIVE(KCONFIG_USEMODULE_SHELL)
|
||||
# if defined(CPU_NATIVE)
|
||||
# define CONFIG_SHELL_SHUTDOWN_ON_EXIT 1
|
||||
# else
|
||||
# define CONFIG_SHELL_SHUTDOWN_ON_EXIT 0
|
||||
|
12
sys/pipe/Kconfig
Normal file
12
sys/pipe/Kconfig
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (c) 2023 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.
|
||||
#
|
||||
|
||||
config MODULE_PIPE
|
||||
bool "Statically allocated pipes"
|
||||
depends on TEST_KCONFIG
|
||||
help
|
||||
Implementation for statically allocated pipes.
|
29
sys/shell_lock/Kconfig
Normal file
29
sys/shell_lock/Kconfig
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2023 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.
|
||||
#
|
||||
|
||||
menuconfig MODULE_SHELL_LOCK
|
||||
bool "Shell Locking module"
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
if MODULE_SHELL_LOCK
|
||||
|
||||
config SHELL_LOCK_PASSWORD
|
||||
string "Lock password"
|
||||
default "password"
|
||||
|
||||
config SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS
|
||||
int "Timeout in ms before automatic locking"
|
||||
default 7000
|
||||
|
||||
endif # MODULE_SHELL_LOCK
|
||||
|
||||
config MODULE_SHELL_LOCK_AUTO_LOCKING
|
||||
bool "Automatic locking of the shell"
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_SHELL_LOCK
|
@ -11,13 +11,6 @@ ifneq (,$(filter ztimer,$(USEMODULE)))
|
||||
DEFAULT_MODULE += ztimer_init
|
||||
endif
|
||||
|
||||
# unless ztimer_xtimer_compat is used, make xtimer use ztimer_usec as backend.
|
||||
ifneq (,$(filter ztimer,$(USEMODULE)))
|
||||
ifneq (,$(filter evtimer,$(USEMODULE)))
|
||||
USEMODULE += evtimer_on_ztimer
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ztimer_xtimer_compat,$(USEMODULE)))
|
||||
USEMODULE += ztimer_usec
|
||||
endif
|
||||
@ -27,11 +20,6 @@ ifneq (,$(filter ztimer64_xtimer_compat,$(USEMODULE)))
|
||||
USEMODULE += ztimer_xtimer_compat
|
||||
endif
|
||||
|
||||
# make evtimer use ztimer_msec as low level timer
|
||||
ifneq (,$(filter evtimer_on_ztimer,$(USEMODULE)))
|
||||
USEMODULE += ztimer_msec
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ztimer_%,$(USEMODULE)))
|
||||
USEMODULE += ztimer_core
|
||||
USEMODULE += ztimer_extend
|
||||
|
@ -1,5 +1,6 @@
|
||||
include ../Makefile.net_common
|
||||
|
||||
USEMODULE += ztimer_msec
|
||||
USEMODULE += gnrc_mac
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "net/gnrc/mac/timeout.h"
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#define TIMEOUT_COUNT 3
|
||||
#define TIMEOUT_1_DURATION 1000
|
||||
@ -34,7 +34,7 @@ static gnrc_mac_timeout_event_t test_timeouts[TIMEOUT_COUNT];
|
||||
static gnrc_mac_timeout_type_t timeout_1;
|
||||
static gnrc_mac_timeout_type_t timeout_2;
|
||||
static gnrc_mac_timeout_type_t timeout_3;
|
||||
static uint32_t start_time;
|
||||
static ztimer_now_t start_time;
|
||||
|
||||
static char worker_stack[THREAD_STACKSIZE_MAIN];
|
||||
|
||||
@ -47,10 +47,10 @@ void *worker_thread(void *arg)
|
||||
|
||||
while (1) {
|
||||
msg_t m;
|
||||
uint32_t now;
|
||||
ztimer_now_t now;
|
||||
|
||||
msg_receive(&m);
|
||||
now = xtimer_now_usec() / US_PER_MS;
|
||||
now = ztimer_now(ZTIMER_MSEC);
|
||||
|
||||
if (gnrc_mac_timeout_is_expired(&mac_timeout, timeout_1)) {
|
||||
printf("At %6" PRIu32 " ms received msg %i: timeout_1 (set at %" PRIu32 " ms) expired, "
|
||||
@ -102,7 +102,7 @@ int main(void)
|
||||
timeout_2 = -2;
|
||||
timeout_3 = -3;
|
||||
|
||||
start_time = xtimer_now_usec() / US_PER_MS;
|
||||
start_time = ztimer_now(ZTIMER_MSEC);
|
||||
gnrc_mac_init_timeouts(&mac_timeout, test_timeouts, TIMEOUT_COUNT);
|
||||
gnrc_mac_set_timeout(&mac_timeout, timeout_1, TIMEOUT_1_DURATION, pid);
|
||||
gnrc_mac_set_timeout(&mac_timeout, timeout_2, TIMEOUT_2_DURATION, pid);
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "net/netif.h"
|
||||
#include "test_utils/expect.h"
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#define ETHERNET_STACKSIZE (THREAD_STACKSIZE_MAIN)
|
||||
#define IEEE802154_STACKSIZE (THREAD_STACKSIZE_MAIN)
|
||||
|
1
tests/sys/evtimer_mbox/app.config.test
Normal file
1
tests/sys/evtimer_mbox/app.config.test
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_MODULE_EVTIMER_MBOX=y
|
@ -1,7 +1,7 @@
|
||||
include ../Makefile.sys_common
|
||||
|
||||
USEMODULE += evtimer
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
# This test randomly fails on `native` so disable it from CI
|
||||
TEST_ON_CI_BLACKLIST += native
|
||||
|
1
tests/sys/evtimer_msg/app.config.test
Normal file
1
tests/sys/evtimer_msg/app.config.test
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_MODULE_EVTIMER=y
|
@ -23,7 +23,7 @@
|
||||
#include "evtimer_msg.h"
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
static char worker_stack[THREAD_STACKSIZE_MAIN];
|
||||
static evtimer_t evtimer;
|
||||
@ -111,7 +111,7 @@ int main(void)
|
||||
NEVENTS);
|
||||
|
||||
/* The last offset is the largest, wait for it and a tiny bit more */
|
||||
xtimer_msleep((offsets[3] + 10));
|
||||
ztimer_sleep(ZTIMER_MSEC, (offsets[3] + 10));
|
||||
puts("By now all msgs should have been received");
|
||||
puts("If yes, the tests were successful");
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
include ../Makefile.sys_common
|
||||
|
||||
USEMODULE += evtimer
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
# microbit qemu lacks rtt
|
||||
TEST_ON_CI_BLACKLIST += microbit
|
||||
|
1
tests/sys/evtimer_underflow/app.config.test
Normal file
1
tests/sys/evtimer_underflow/app.config.test
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_MODULE_EVTIMER=y
|
@ -23,7 +23,7 @@
|
||||
#include "evtimer_msg.h"
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
#include "xtimer.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#define WORKER_MSG_QUEUE_SIZE (8)
|
||||
|
||||
@ -61,7 +61,7 @@ void *worker_thread(void *arg)
|
||||
|
||||
void sleep_msec(uint16_t t)
|
||||
{
|
||||
xtimer_msleep(t);
|
||||
ztimer_sleep(ZTIMER_MSEC, t);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
1
tests/sys/pipe/app.config.test
Normal file
1
tests/sys/pipe/app.config.test
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_MODULE_PIPE=y
|
@ -7,8 +7,10 @@ USEMODULE += shell_cmds_default
|
||||
USEMODULE += shell_lock
|
||||
USEMODULE += shell_lock_auto_locking
|
||||
|
||||
ifneq (1,$(TEST_KCONFIG))
|
||||
CFLAGS += -DCONFIG_SHELL_LOCK_PASSWORD=\"password\"
|
||||
CFLAGS += -DCONFIG_SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS=7000
|
||||
endif
|
||||
|
||||
# This config defaults to 1 on native, such that pm_off() would be called as soon as
|
||||
# shell_run_once is terminated in shell_run_forever. We do not want this behavior for this test.
|
||||
|
6
tests/sys/shell_lock/app.config.test
Normal file
6
tests/sys/shell_lock/app.config.test
Normal file
@ -0,0 +1,6 @@
|
||||
CONFIG_MODULE_SHELL=y
|
||||
CONFIG_MODULE_SHELL_CMDS_DEFAULT=y
|
||||
CONFIG_MODULE_SHELL_LOCK=y
|
||||
CONFIG_MODULE_SHELL_LOCK_AUTO_LOCKING=y
|
||||
CONFIG_MODULE_TEST_UTILS_INTERACTIVE_SYNC_SHELL=n
|
||||
CONFIG_SHELL_SHUTDOWN_ON_EXIT=n
|
Loading…
Reference in New Issue
Block a user