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