Blame view

RIOT/examples/timer_periodic_wakeup/main.c 805 Bytes
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  /*
   * 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.
   */
  
  /**
   * @ingroup     xtimer_examples
   * @{
   *
   * @file
   * @brief       example application for setting a periodic wakeup
   *
   * @author      Kaspar Schleiser <kaspar@schleiser.de>
   *
   * @}
   */
  
  #include <stdio.h>
  #include "xtimer.h"
  #include "timex.h"
  
  /* set interval to 1 second */
  #define INTERVAL (1U * US_PER_SEC)
  
  int main(void)
  {
      xtimer_ticks32_t last_wakeup = xtimer_now();
  
      while(1) {
          xtimer_periodic_wakeup(&last_wakeup, INTERVAL);
          printf("slept until %" PRIu32 "\n", xtimer_usec_from_ticks(xtimer_now()));
      }
  
      return 0;
  }