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

4.115
Last change on this file since c0d7e23 was c0d7e23, checked in by Joel Sherrill <joel.sherrill@…>, on 05/05/11 at 16:45:57

2011-05-05 Joel Sherrill <joel.sherrill@…>

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