sys/sema: allow to use ztimer and/or xtimer#15782
sys/sema: allow to use ztimer and/or xtimer#15782haukepetersen merged 2 commits intoRIOT-OS:masterfrom
Conversation
|
Forgot to mention: remodeling the |
a5a758d to
8c04066
Compare
|
Did another take on this, and I think with the API part I am quite happy now. The new take applies the exact same style than we use for the The only thing that needs more work is the implementation part. Here we need some smarter approach to prevent code duplication I guess... |
|
Cleaned up the API part slightly. The more I think about this, I come to the conclusion that having two, although in large parts identical, implementations of the |
Sure lets got with it as is, seems like there is actually no taste for |
fjmolinas
left a comment
There was a problem hiding this comment.
@haukepetersen there is a sema test in master now, lets keep it simple and simply use the ztimer version in one of the wait scenario:
diff --git a/tests/sema/Makefile b/tests/sema/Makefile
index ce88d28105..0d0af60982 100644
--- a/tests/sema/Makefile
+++ b/tests/sema/Makefile
@@ -1,5 +1,7 @@
include ../Makefile.tests_common
USEMODULE += sema
+USEMODULE += xtimer
+USEMODULE += ztimer_usec
include $(RIOTBASE)/Makefile.include
diff --git a/tests/sema/main.c b/tests/sema/main.c
index 295c434103..5f0fdd2fa4 100644
--- a/tests/sema/main.c
+++ b/tests/sema/main.c
@@ -26,6 +26,7 @@
#include "sema.h"
#include "thread.h"
#include "xtimer.h"
+#include "ztimer.h"
#define TEST_TIME_US 1000
#define TEST_ITERATIONS 4
@@ -48,7 +49,7 @@ static void *second_thread(void *arg)
printf("THREAD ERROR: sema_wait_timed()");
*thread_success = -1;
}
- if (sema_wait_timed(&test_sema2, TEST_TIME_US) != 0) {
+ if (sema_wait_timed_ztimer(&test_sema2, ZTIMER_USEC, TEST_TIME_US) != 0) {
printf("THREAD ERROR: sema_wait_timed()");
*thread_success = -1;
}
(please rebase to get the test in)
Actually, maybe its better to simply duplicate the test |
With #15782 (comment) in mind I think just the patch in #15782 (review) is enough. So if you remove this newline #15782 (comment) then I think this one is OK! |
0b81ecf to
c650335
Compare
|
done:
|
|
Murdock is green please squash @haukepetersen! |
c650335 to
4cd9e96
Compare
|
squashed |
|
All green -> go |
Contribution description
On the winding road to get NimBLE running without including
xtimerorperiph_timerin the build, thesemaandeventmodules are the last ones that pull in these dependencies currently. So I am desperately looking for way to free these modules ofxtimerdeps.The code in this PR, still very prototypic, illustrates one possible solution to decouple the
semamodule fromxtimerand at the same time addingztimersupport. However, this might not be the most elegant solution, so I am happy to hear any alternative ideas on this task!Regarding what IMO should be possible:
ztimerAPI in parallel to the existing API -> allows for mixing legacy code with new ztimer codextimersupport and use theztimersupport only -> allows to throw outxtimerTesting procedure
not in focus, yet.
Issues/PRs references
none