source: rtems/testsuites/sptests/sp50/init.c @ b1274bd9

4.104.115
Last change on this file since b1274bd9 was b1274bd9, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 03:33:25

Whitespace removal.

  • Property mode set to 100644
File size: 2.0 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>
13
14volatile int   Fired;
15volatile bool  timerRan;
16
17rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored )
18{
19  rtems_status_code sc;
20
21  Fired++;
22  timerRan = true;
23
24  sc = rtems_timer_server_fire_after(
25    id,
26    rtems_clock_get_ticks_per_second(),
27    Timer_Routine,
28    NULL
29  );
30}
31
32rtems_task Init(
33  rtems_task_argument argument
34)
35{
36  rtems_status_code sc;
37  rtems_id          timer1;
38  struct timespec   uptime;
39
40  puts( "\n\n*** TEST 50 ***" );
41
42  sc = rtems_timer_initiate_server(
43    1,
44    RTEMS_MINIMUM_STACK_SIZE,
45    RTEMS_DEFAULT_ATTRIBUTES
46  );
47  directive_failed( sc, "rtems_timer_initiate_server" );
48
49  sc = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &timer1);
50  directive_failed( sc, "rtems_timer_create" );
51
52  Fired = 0;
53  timerRan = false;
54
55  Timer_Routine(timer1, NULL);
56
57  while (1) {
58    sc = rtems_task_wake_after( 10 );
59    directive_failed( sc, "rtems_task_wake_after" );
60
61    if ( timerRan == true ) {
62      timerRan = false;
63
64      sc = rtems_clock_get_uptime( &uptime );
65      directive_failed( sc, "rtems_clock_get_uptime" );
66
67      printf( "Timer fired at %" PRItime_t "\n", uptime.tv_sec );
68    }
69
70    if ( Fired >= 10 ) {
71      puts( "*** END OF TEST 50 ***" );
72      rtems_test_exit( 0 );
73    }
74    /* technically the following is a critical section */
75  }
76}
77
78
79/**************** START OF CONFIGURATION INFORMATION ****************/
80
81#define CONFIGURE_INIT
82#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
83#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
84
85#define CONFIGURE_MAXIMUM_TASKS         2
86#define CONFIGURE_MAXIMUM_TIMERS        1
87
88#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
89
90#include <rtems/confdefs.h>
91
92/****************  END OF CONFIGURATION INFORMATION  ****************/
Note: See TracBrowser for help on using the repository browser.