mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
examples/timer_periodic_wakeup: switch to ztimer
This commit is contained in:
parent
df0c04ecc8
commit
a27f382f7e
@ -1,8 +1,9 @@
|
|||||||
APPLICATION = timer_periodic_wakeup
|
APPLICATION = timer_periodic_wakeup
|
||||||
RIOTBASE ?= $(CURDIR)/../..
|
RIOTBASE ?= $(CURDIR)/../..
|
||||||
|
|
||||||
BOARD ?= native
|
BOARD ?= native
|
||||||
USEMODULE += xtimer
|
|
||||||
QUIET ?= 1
|
USEMODULE += ztimer_msec
|
||||||
|
|
||||||
# Comment this out to disable code in RIOT that does safety checking
|
# Comment this out to disable code in RIOT that does safety checking
|
||||||
# which is not needed in a production environment but helps in the
|
# which is not needed in a production environment but helps in the
|
||||||
|
|||||||
@ -19,19 +19,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "xtimer.h"
|
#include "ztimer.h"
|
||||||
#include "timex.h"
|
#include "timex.h"
|
||||||
|
|
||||||
/* set interval to 1 second */
|
/* set interval to 1 second */
|
||||||
#define INTERVAL (1U * US_PER_SEC)
|
#define INTERVAL_MS (1U * MS_PER_SEC)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
xtimer_ticks32_t last_wakeup = xtimer_now();
|
uint32_t last_wakeup = ztimer_now(ZTIMER_MSEC);
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
xtimer_periodic_wakeup(&last_wakeup, INTERVAL);
|
ztimer_periodic_wakeup(ZTIMER_MSEC, &last_wakeup, INTERVAL_MS);
|
||||||
printf("slept until %" PRIu32 "\n", xtimer_usec_from_ticks(xtimer_now()));
|
printf("slept until %" PRIu32 "\n", ztimer_now(ZTIMER_MSEC));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user