Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/timer_periodic_wakeup: switch to ztimer #19001

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/timer_periodic_wakeup/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
APPLICATION = timer_periodic_wakeup
RIOTBASE ?= $(CURDIR)/../..

BOARD ?= native
USEMODULE += xtimer
QUIET ?= 1

USEMODULE += ztimer_msec

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
Expand Down
12 changes: 6 additions & 6 deletions examples/timer_periodic_wakeup/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
*/

#include <stdio.h>
#include "xtimer.h"
#include "ztimer.h"
#include "timex.h"

/* set interval to 1 second */
#define INTERVAL (1U * US_PER_SEC)
#define INTERVAL_MS (1U * MS_PER_SEC)

int main(void)
{
xtimer_ticks32_t last_wakeup = xtimer_now();
uint32_t last_wakeup = ztimer_now(ZTIMER_MSEC);

while(1) {
xtimer_periodic_wakeup(&last_wakeup, INTERVAL);
printf("slept until %" PRIu32 "\n", xtimer_usec_from_ticks(xtimer_now()));
while (1) {
ztimer_periodic_wakeup(ZTIMER_MSEC, &last_wakeup, INTERVAL_MS);
printf("slept until %" PRIu32 "\n", ztimer_now(ZTIMER_MSEC));
}

return 0;
Expand Down