forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: timers: add timer_periodic_wakeup example
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
APPLICATION = timer_periodic_wakeup | ||
RIOTBASE ?= $(CURDIR)/../.. | ||
BOARD ?= native | ||
USEMODULE += xtimer | ||
QUIET ?= 1 | ||
|
||
FEATURES_REQUIRED += periph_timer | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2015 Kaspar Schleiser <[email protected]> | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @ingroup xtimer_examples | ||
* @{ | ||
* | ||
* @file | ||
* @brief example application for setting a periodic wakeup | ||
* | ||
* @author Kaspar Schleiser <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include "xtimer.h" | ||
|
||
/* set interval to 1 second */ | ||
#define INTERVAL (1000000U) | ||
|
||
int main(void) | ||
{ | ||
uint32_t last_wakeup = xtimer_now(); | ||
|
||
while(1) { | ||
xtimer_usleep_until(&last_wakeup, INTERVAL); | ||
printf("slept until %"PRIu32"\n", xtimer_now()); | ||
} | ||
|
||
return 0; | ||
} |