source: rtems/testsuites/sptests/sp32/init.c @ 614821e

4.104.115
Last change on this file since 614821e was 614821e, checked in by Joel Sherrill <joel.sherrill@…>, on 10/14/09 at 21:35:05

2009-10-14 Joel Sherrill <joel.sherrill@…>

  • sp32/init.c: Lengthen the clock tick and move configuration to the bottom of the file.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 * $Id$
10 */
11
12#include <tmacros.h>  /* includes bsp.h, stdio, etc... */
13
14rtems_task Init(
15    rtems_task_argument ignored
16) {
17  rtems_status_code  status;
18  rtems_interval     timestamps[6],
19                     wantintervals[5] = { 1, 50, 200, 25, 3 };
20  rtems_name         period_name = rtems_build_name('P','E','R','a');
21  rtems_id           period_id;
22  int                loopy;
23
24  printf("\n\n*** TEST 32 ***\n");
25
26  /* create period */
27  status = rtems_rate_monotonic_create(
28      period_name,
29      &period_id
30  );
31  directive_failed(status, "rate_monotonic_create");
32
33  /* start period with initial value */
34  status = rtems_rate_monotonic_period( period_id, wantintervals[0] );
35  directive_failed(status, "rate_monotonic_period #1");
36
37  /* get our first timestamp */
38  status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &timestamps[0] );
39  directive_failed(status, "clock_get");
40
41  /* loop through and gather more timestamps */
42  for (loopy = 1; loopy < 5; loopy++) {
43
44    status = rtems_rate_monotonic_period( period_id, wantintervals[loopy] );
45    directive_failed(status, "rate_monotonic_period #2");
46
47    status = rtems_clock_get(
48        RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
49        &timestamps[loopy]
50    );
51    directive_failed(status, "clock_get");
52  }
53
54  /* block one last time */
55  status = rtems_rate_monotonic_period( period_id, 1 );
56  directive_failed(status, "rate_monotonic_period #3");
57
58  /* get one last timestamp */
59  status = rtems_clock_get(
60      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
61      &timestamps[loopy]
62  );
63  directive_failed(status, "clock_get");
64
65  /* cancel the period */
66  status = rtems_rate_monotonic_cancel(period_id);
67  directive_failed(status, "rate_monotonic_cancel");
68
69  /* delete it */
70  status = rtems_rate_monotonic_delete(period_id);
71  directive_failed(status, "rate_monotonic_delete");
72
73  /* tabulate and print results */
74  for (loopy = 0; loopy < 5; loopy++) {
75    printf(
76        "period %d: measured %d tick(s), wanted %d\n",
77        loopy, timestamps[loopy+1] - timestamps[loopy],
78        wantintervals[loopy]
79    );
80  }
81
82  /* the end */
83  puts("*** END OF TEST 32 ***");
84  rtems_test_exit(0);
85}
86
87#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
88
89#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
90#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
91#define CONFIGURE_MAXIMUM_TASKS        1
92#define CONFIGURE_MAXIMUM_PERIODS      1
93
94#define CONFIGURE_MICROSECONDS_PER_TICK 100000
95
96#define CONFIGURE_INIT
97
98#include <rtems/confdefs.h>
99
Note: See TracBrowser for help on using the repository browser.