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