1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
* Based upon test code posted on the RTEMS User's Mailing List
* by Sergio Faustino <sergio.faustino@edisoft.pt>:
*
* http://www.rtems.org/pipermail/rtems-users/2009-June/005540.html
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tmacros.h>
#include <rtems/score/watchdogimpl.h>
const char rtems_test_name[] = "SP 67";
/* forward declarations to avoid warnings */
rtems_task Init(rtems_task_argument argument);
rtems_timer_service_routine TIMER_service_routine(
rtems_id ignored_id,
void *user_data
);
volatile bool _timer_passage_1 = FALSE;
volatile bool _timer_passage_2 = FALSE;
/*timer Routine*/
rtems_timer_service_routine TIMER_service_routine(
rtems_id ignored_id,
void *user_data
)
{
bool *passed = (bool *)user_data;
*passed = TRUE;
}
rtems_task Init(
rtems_task_argument argument
)
{
rtems_status_code status;
rtems_id timer1;
rtems_id timer2;
TEST_BEGIN();
/* build timer name*/
/* create Timer */
puts( "Init - create timer 1" );
status = rtems_timer_create( rtems_build_name('T', 'M', '1', ' '), &timer1 );
directive_failed( status, "rtems_timer_create #1" );
puts( "Init - create timer 2" );
status = rtems_timer_create( rtems_build_name('T', 'M', '2', ' '), &timer2 );
directive_failed( status, "rtems_timer_create #1" );
/* Manipulate the time */
_Watchdog_Ticks_since_boot = (Watchdog_Interval) -15;
/* initiate timer server */
puts( "Init - Initiate the timer server" );
status = rtems_timer_initiate_server(
RTEMS_MINIMUM_PRIORITY,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_ATTRIBUTES
);
directive_failed( status, "rtems_timer_initiate_server" );
/* Give the timer server some time to initialize */
status = rtems_task_wake_after( 10 );
directive_failed( status, "task wake_after" );
status = rtems_timer_server_fire_after(
timer1,
10,
TIMER_service_routine,
(void*) &_timer_passage_1
);
directive_failed( status, "rtems_timer_server_fire_after" );
status = rtems_timer_server_fire_after(
timer2,
20,
TIMER_service_routine,
(void*) &_timer_passage_2
);
directive_failed( status, "rtems_timer_server_fire_after" );
status = rtems_task_wake_after( 15 );
directive_failed( status, "task wake_after" );
if (!_timer_passage_1) {
puts( "Timer 1 FAILED to fire after wrapping time");
rtems_test_exit(0);
}
puts( "Server Timer 1 fired after wrapping ticks since boot-- OK");
if (_timer_passage_2) {
puts( "Timer 2 fired and should not have after wrapping time");
rtems_test_exit(0);
}
TEST_END();
rtems_test_exit(0);
}
/* configuration stuff */
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_MAXIMUM_TIMERS 2
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
|