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

4.115
Last change on this file since f57f5ce2 was f57f5ce2, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/30/11 at 02:50:48

2011-09-30 Ralf Corsépius <ralf.corsepius@…>

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