2015-08-14 16:02:32 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-01 15:04:34 +02:00
|
|
|
* @ingroup examples
|
2015-08-14 16:02:32 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief example application for setting a periodic wakeup
|
|
|
|
*
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2022-12-01 16:34:25 +01:00
|
|
|
#include "ztimer.h"
|
2016-07-07 16:15:33 +02:00
|
|
|
#include "timex.h"
|
2015-08-14 16:02:32 +02:00
|
|
|
|
|
|
|
/* set interval to 1 second */
|
2022-12-01 16:34:25 +01:00
|
|
|
#define INTERVAL_MS (1U * MS_PER_SEC)
|
2015-08-14 16:02:32 +02:00
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2022-12-01 16:34:25 +01:00
|
|
|
uint32_t last_wakeup = ztimer_now(ZTIMER_MSEC);
|
2015-08-14 16:02:32 +02:00
|
|
|
|
2022-12-01 16:34:25 +01:00
|
|
|
while (1) {
|
|
|
|
ztimer_periodic_wakeup(ZTIMER_MSEC, &last_wakeup, INTERVAL_MS);
|
|
|
|
printf("slept until %" PRIu32 "\n", ztimer_now(ZTIMER_MSEC));
|
2015-08-14 16:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|