diff --git a/examples/posix_sockets/Makefile b/examples/posix_sockets/Makefile index b5cfaa243b..9188a0f96a 100644 --- a/examples/posix_sockets/Makefile +++ b/examples/posix_sockets/Makefile @@ -15,7 +15,7 @@ USEMODULE += auto_init_gnrc_netif USEMODULE += gnrc_ipv6_default USEMODULE += sock_udp USEMODULE += posix_sockets -USEMODULE += posix_time +USEMODULE += posix_sleep USEMODULE += posix_inet # Add also the shell, some shell commands USEMODULE += shell diff --git a/pkg/umorse/Makefile.dep b/pkg/umorse/Makefile.dep index 350dc2afa4..7b58f2b903 100644 --- a/pkg/umorse/Makefile.dep +++ b/pkg/umorse/Makefile.dep @@ -1 +1 @@ -USEMODULE += posix_time +USEMODULE += posix_sleep diff --git a/sys/Makefile b/sys/Makefile index 9abc50975f..e2216b74a1 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -140,8 +140,8 @@ endif ifneq (,$(filter posix_sockets,$(USEMODULE))) DIRS += posix/sockets endif -ifneq (,$(filter posix_time,$(USEMODULE))) - DIRS += posix/time +ifneq (,$(filter posix_sleep,$(USEMODULE))) + DIRS += posix/sleep endif ifneq (,$(filter pthread,$(USEMODULE))) DIRS += posix/pthread diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 0c02884a14..99f2b0a329 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -561,8 +561,12 @@ ifneq (,$(filter posix_semaphore,$(USEMODULE))) USEMODULE += posix_headers endif -ifneq (,$(filter posix_time,$(USEMODULE))) - USEMODULE += xtimer +ifneq (,$(filter posix_sleep,$(USEMODULE))) + USEMODULE += ztimer_msec + ifneq (,$(filter periph_rtt,$(USEMODULE))) + USEMODULE += ztimer_periph_rtt + endif + USEMODULE += ztimer_usec USEMODULE += posix_headers endif diff --git a/sys/posix/time/Makefile b/sys/posix/sleep/Makefile similarity index 62% rename from sys/posix/time/Makefile rename to sys/posix/sleep/Makefile index 58c4276185..8cfde5a886 100644 --- a/sys/posix/time/Makefile +++ b/sys/posix/sleep/Makefile @@ -1,3 +1,3 @@ -MODULE = posix_time +MODULE = posix_sleep include $(RIOTBASE)/Makefile.base diff --git a/sys/posix/time/posix_time.c b/sys/posix/sleep/posix_sleep.c similarity index 64% rename from sys/posix/time/posix_time.c rename to sys/posix/sleep/posix_sleep.c index ae78095968..11581069c8 100644 --- a/sys/posix/time/posix_time.c +++ b/sys/posix/sleep/posix_sleep.c @@ -7,27 +7,29 @@ */ /** - * @ingroup sys_xtimer + * @ingroup posix * * @{ * @file - * @brief xtimer posix wrapper + * @brief posix sleep/usleep implementation wrapped around @ref ztimer * @author Kaspar Schleiser * @} */ #include -#include "xtimer.h" +#include "kernel_defines.h" +#include "timex.h" +#include "ztimer.h" unsigned int sleep(unsigned int seconds) { - xtimer_usleep64(seconds * US_PER_SEC); + ztimer_sleep(ZTIMER_MSEC, seconds * MS_PER_SEC); return 0; } int usleep(useconds_t usec) { - xtimer_usleep64(usec); + ztimer_sleep(ZTIMER_USEC, usec); return 0; } diff --git a/tests/posix_sleep/Makefile b/tests/posix_sleep/Makefile new file mode 100644 index 0000000000..ff3a969bad --- /dev/null +++ b/tests/posix_sleep/Makefile @@ -0,0 +1,9 @@ +include ../Makefile.tests_common + +USEMODULE += posix_sleep + +# Pull-in periph-rtt on board that provides this feature to switch to the RTT +# backend of ztimer +FEATURES_OPTIONAL += periph_rtt + +include $(RIOTBASE)/Makefile.include diff --git a/tests/posix_sleep/Makefile.ci b/tests/posix_sleep/Makefile.ci new file mode 100644 index 0000000000..b9ff275375 --- /dev/null +++ b/tests/posix_sleep/Makefile.ci @@ -0,0 +1,3 @@ +BOARD_INSUFFICIENT_MEMORY := \ + nucleo-l011k4 \ + # diff --git a/tests/posix_time/README.md b/tests/posix_sleep/README.md similarity index 88% rename from tests/posix_time/README.md rename to tests/posix_sleep/README.md index e8d161db4a..b9b6f89853 100644 --- a/tests/posix_time/README.md +++ b/tests/posix_sleep/README.md @@ -1,4 +1,4 @@ -# posix_time test application +# posix_sleep test application This test tests POSIX' `sleep()` and `usleep()`. The test script also checks the sanity of the timings by comparing the overall diff --git a/tests/posix_time/main.c b/tests/posix_sleep/main.c similarity index 100% rename from tests/posix_time/main.c rename to tests/posix_sleep/main.c diff --git a/tests/posix_time/tests/01-run.py b/tests/posix_sleep/tests/01-run.py similarity index 100% rename from tests/posix_time/tests/01-run.py rename to tests/posix_sleep/tests/01-run.py diff --git a/tests/posix_time/Makefile b/tests/posix_time/Makefile deleted file mode 100644 index 65e58f6d25..0000000000 --- a/tests/posix_time/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../Makefile.tests_common - -USEMODULE += posix_time - -include $(RIOTBASE)/Makefile.include