Blame view

RIOT/tests/irq/main.c 1.16 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  /*
   * Copyright (C) 2013 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.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 tests
   * @{
   *
   * @file
   * @brief IRQ test application
   *
   * @author      Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
   *
   * @}
   */
  
  #include <stdio.h>
  
  #include "xtimer.h"
  #include "thread.h"
  
  static char busy_stack[THREAD_STACKSIZE_MAIN];
  static volatile int busy, i, k;
  
  void *busy_thread(void *arg)
  {
      (void) arg;
  
      int j = 0;
      puts("busy_thread starting");
  
      i = 0;
  
      while (busy) {
          k = j = ++i;
      }
  
      printf("i: %i\n", i);
      printf("j: %i\n", j);
      printf("k: %i\n", k);
  
      puts("success");
  
      return NULL;
  }
  
  
  int main(void)
  {
      busy = 1;
      k = 23;
      thread_create(busy_stack, sizeof(busy_stack),
                    THREAD_PRIORITY_MAIN + 1, THREAD_CREATE_WOUT_YIELD,
                    busy_thread, NULL, "busy_thread");
      puts("busy_thread created");
  
      puts("xtimer_wait()");
      xtimer_usleep(100000);
      busy = 0;
  
      puts("main: return");
  
      return 0;
  }