source: rtems/cpukit/rtems/include/rtems/rtems/timer.h @ 067a96a

4.104.114.95
Last change on this file since 067a96a was 067a96a, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/08 at 15:02:20

2008-04-18 Joel Sherrill <joel.sherrill@…>

  • rtems/include/rtems.h, rtems/include/rtems/rtems/asr.h, rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/barriermp.h, rtems/include/rtems/rtems/cache.h, rtems/include/rtems/rtems/clock.h, rtems/include/rtems/rtems/config.h, rtems/include/rtems/rtems/dpmem.h, rtems/include/rtems/rtems/event.h, rtems/include/rtems/rtems/eventmp.h, rtems/include/rtems/rtems/eventset.h, rtems/include/rtems/rtems/intr.h, rtems/include/rtems/rtems/message.h, rtems/include/rtems/rtems/modes.h, rtems/include/rtems/rtems/mp.h, rtems/include/rtems/rtems/msgmp.h, rtems/include/rtems/rtems/object.h, rtems/include/rtems/rtems/options.h, rtems/include/rtems/rtems/part.h, rtems/include/rtems/rtems/partmp.h, rtems/include/rtems/rtems/ratemon.h, rtems/include/rtems/rtems/region.h, rtems/include/rtems/rtems/regionmp.h, rtems/include/rtems/rtems/rtemsapi.h, rtems/include/rtems/rtems/sem.h, rtems/include/rtems/rtems/semmp.h, rtems/include/rtems/rtems/signal.h, rtems/include/rtems/rtems/signalmp.h, rtems/include/rtems/rtems/status.h, rtems/include/rtems/rtems/support.h, rtems/include/rtems/rtems/taskmp.h, rtems/include/rtems/rtems/tasks.h, rtems/include/rtems/rtems/timer.h, rtems/include/rtems/rtems/types.h, rtems/inline/rtems/rtems/asr.inl, rtems/inline/rtems/rtems/attr.inl, rtems/inline/rtems/rtems/barrier.inl, rtems/inline/rtems/rtems/dpmem.inl, rtems/inline/rtems/rtems/event.inl, rtems/inline/rtems/rtems/eventset.inl, rtems/inline/rtems/rtems/message.inl, rtems/inline/rtems/rtems/modes.inl, rtems/inline/rtems/rtems/options.inl, rtems/inline/rtems/rtems/part.inl, rtems/inline/rtems/rtems/ratemon.inl, rtems/inline/rtems/rtems/region.inl, rtems/inline/rtems/rtems/sem.inl, rtems/inline/rtems/rtems/status.inl, rtems/inline/rtems/rtems/support.inl, rtems/inline/rtems/rtems/tasks.inl, rtems/inline/rtems/rtems/timer.inl: Initial conversion of Classic API header files to Doxygen.
  • rtems/Doxyfile: New file.
  • Property mode set to 100644
File size: 10.1 KB
Line 
1/**
2 * @file rtems/rtems/timer.h
3 *
4 *  This include file contains all the constants, structures, and
5 *  prototypes associated with the Timer Manager.  This manager provides
6 *  facilities to configure, initiate, cancel, and delete timers which will
7 *  fire at specified intervals of time.
8 *
9 *  Directives provided are:
10 *
11 *     - create a timer
12 *     - get an ID of a timer
13 *     - delete a timer
14 *     - set timer to fire in context of clock tick
15 *        - after a number of ticks have passed
16 *        - when a specified date and time has been reached
17 *     - initiate the timer server task
18 *     - set timer to fire in context of the timer server task
19 *        - after a number of ticks have passed
20 *        - when a specified date and time has been reached
21 *     - reset a timer
22 *     - cancel a time
23 */
24
25/*  COPYRIGHT (c) 1989-2007.
26 *  On-Line Applications Research Corporation (OAR).
27 *
28 *  The license and distribution terms for this file may be
29 *  found in the file LICENSE in this distribution or at
30 *  http://www.rtems.com/license/LICENSE.
31 *
32 *  $Id$
33 */
34
35#ifndef _RTEMS_RTEMS_TIMER_H
36#define _RTEMS_RTEMS_TIMER_H
37
38#ifndef RTEMS_TIMER_EXTERN
39#define RTEMS_TIMER_EXTERN extern
40#endif
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#include <rtems/score/object.h>
47#include <rtems/score/watchdog.h>
48#include <rtems/score/thread.h>
49#include <rtems/rtems/clock.h>
50#include <rtems/rtems/attr.h>
51
52/**
53 *  @defgroup ClassicTimer Classic API Timer
54 *
55 *  This encapsulates functionality which XXX
56 */
57/**@{*/
58
59/**
60 *  The following enumerated type details the classes to which a timer
61 *  may belong.
62 */
63typedef enum {
64  TIMER_INTERVAL,
65  TIMER_INTERVAL_ON_TASK,
66  TIMER_TIME_OF_DAY,
67  TIMER_TIME_OF_DAY_ON_TASK,
68  TIMER_DORMANT
69} Timer_Classes;
70
71/**
72 *  The following types define a pointer to a timer service routine.
73 */
74typedef void rtems_timer_service_routine;
75
76typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )(
77                 rtems_id,
78                 void *
79             );
80
81/**
82 *  The following defines the information control block used to manage
83 *  this class of objects.
84 */
85RTEMS_TIMER_EXTERN Objects_Information  _Timer_Information;
86
87/**
88 *  Pointer to TCB of the Timer Server.  This is NULL before the
89 *  server is executing and task-based timers are not allowed to be
90 *  initiated until the server is started.
91 */
92RTEMS_TIMER_EXTERN Thread_Control *_Timer_Server;
93
94/**
95 *  The following chains contain the list of interval timers that are
96 *  executed in the context of the Timer Server.
97 *
98 *  NOTE: These are extern'ed because they do not have to be in the
99 *        minimum footprint.  They are only really required when
100 *        task-based timers are used.  Since task-based timers can
101 *        not be started until the server is initiated, these structures
102 *        do not have to be initialized until then.  They are declared
103 *        in the same file as _Timer_Server_body.
104 */
105extern Chain_Control _Timer_Ticks_chain;
106extern Chain_Control _Timer_Seconds_chain;
107
108/**
109 *  The following records define the control block used to manage
110 *  each timer.
111 */
112typedef struct {
113  Objects_Control  Object;
114  Watchdog_Control Ticker;
115  Timer_Classes    the_class;
116}   Timer_Control;
117
118/**
119 *  @brief _Timer_Manager_initialization
120 *
121 *  This routine performs the initialization necessary for this manager.
122 */
123void _Timer_Manager_initialization(
124  uint32_t   maximum_timers
125);
126
127/**
128 *  @brief _Timer_Server_body
129 *
130 *  This is the server for task based timers.  This task executes whenever
131 *  a task-based timer should fire.  It services both "after" and "when"
132 *  timers.  It is not created automatically but must be created explicitly
133 *  by the application before task-based timers may be initiated.
134 */
135Thread _Timer_Server_body(
136  uint32_t   ignored
137);
138
139/**
140 *  @brief rtems_timer_create
141 *
142 *  This routine implements the rtems_timer_create directive.  The
143 *  timer will have the name name.  It returns the id of the
144 *  created timer in ID.
145 */
146rtems_status_code rtems_timer_create(
147  rtems_name    name,
148  Objects_Id   *id
149);
150
151/**
152 *  @brief rtems_timer_ident
153 *
154 *  This routine implements the rtems_timer_ident directive.
155 *  This directive returns the timer ID associated with name.
156 *  If more than one timer is named name, then the timer
157 *  to which the ID belongs is arbitrary.
158 */
159rtems_status_code rtems_timer_ident(
160  rtems_name    name,
161  Objects_Id   *id
162);
163
164/**
165 *  @brief rtems_timer_cancel
166 *
167 *  This routine implements the rtems_timer_cancel directive.  It is used
168 *  to stop the timer associated with ID from firing.
169 */
170rtems_status_code rtems_timer_cancel(
171  Objects_Id id
172);
173
174/**
175 *  @brief rtems_timer_delete
176 *
177 *  This routine implements the rtems_timer_delete directive.  The
178 *  timer indicated by ID is deleted.
179 */
180rtems_status_code rtems_timer_delete(
181  Objects_Id id
182);
183
184/**
185 *  @brief rtems_timer_fire_after
186 *
187 *  This routine implements the rtems_timer_fire_after directive.  It
188 *  initiates the timer associated with ID to fire in ticks clock ticks.
189 *  When the timer fires, the routine will be invoked in the context
190 *  of the rtems_clock_tick directive which is normally invoked as
191 *  part of servicing a periodic interupt.
192 */
193rtems_status_code rtems_timer_fire_after(
194  Objects_Id                         id,
195  rtems_interval                     ticks,
196  rtems_timer_service_routine_entry  routine,
197  void                              *user_data
198);
199
200/**
201 *  @brief rtems_timer_server_fire_after
202 *
203 *  This routine implements the rtems_timer_server_fire_after directive.  It
204 *  initiates the timer associated with ID to fire in ticks clock
205 *  ticks.  When the timer fires, the routine will be invoked by the
206 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
207 *  clock tick interrupt.
208 */
209rtems_status_code rtems_timer_server_fire_after(
210  Objects_Id                         id,
211  rtems_interval                     ticks,
212  rtems_timer_service_routine_entry  routine,
213  void                              *user_data
214);
215
216/**
217 *  @brief rtems_timer_fire_when
218 *
219 *  This routine implements the rtems_timer_fire_when directive.  It
220 *  initiates the timer associated with ID to fire at wall_time
221 *  When the timer fires, the routine will be invoked in the context
222 *  of the rtems_clock_tick directive which is normally invoked as
223 *  part of servicing a periodic interupt.
224 */
225rtems_status_code rtems_timer_fire_when(
226  Objects_Id                          id,
227  rtems_time_of_day                  *wall_time,
228  rtems_timer_service_routine_entry   routine,
229  void                               *user_data
230);
231
232/**
233 *  @brief rtems_timer_server_fire_when
234 *
235 *  This routine implements the rtems_timer_server_fire_when directive.  It
236 *  initiates the timer associated with ID to fire at wall_time
237 *  When the timer fires, the routine will be invoked by the
238 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
239 *  clock tick interrupt.
240 */
241rtems_status_code rtems_timer_server_fire_when(
242  Objects_Id                          id,
243  rtems_time_of_day                  *wall_time,
244  rtems_timer_service_routine_entry   routine,
245  void                               *user_data
246);
247
248/**
249 *  @brief rtems_timer_reset
250 *
251 *  This routine implements the rtems_timer_reset directive.  It is used
252 *  to reinitialize the interval timer associated with ID just as if
253 *  rtems_timer_fire_after were re-invoked with the same arguments that
254 *  were used to initiate this timer.
255 */
256rtems_status_code rtems_timer_reset(
257  Objects_Id id
258);
259
260/**
261 *  @brief rtems_timer_initiate_server
262 *
263 *  This routine implements the rtems_timer_initiate_server directive.
264 *  It creates and starts the server that executes task-based timers.
265 *  It must be invoked before any task-based timers can be initiated.
266 */
267rtems_status_code rtems_timer_initiate_server(
268  uint32_t             priority,
269  uint32_t             stack_size,
270  rtems_attribute      attribute_set
271);
272
273/**
274 *  This is the default value for the priority of the Timer Server.
275 *  When given this priority, a special high priority not accessible
276 *  via the Classic API is used.
277 */
278#define RTEMS_TIMER_SERVER_DEFAULT_PRIORITY -1
279
280/**
281 *  This is the structure filled in by the timer get information
282 *  service.
283 */
284typedef struct {
285  Timer_Classes      the_class;
286  Watchdog_Interval  initial;
287  Watchdog_Interval  start_time;
288  Watchdog_Interval  stop_time;
289} rtems_timer_information;
290
291/**
292 *  @brief rtems_timer_get_information
293 *
294 *  This routine implements the rtems_timer_get_information directive.
295 *  This directive returns information about the timer.
296 */
297rtems_status_code rtems_timer_get_information(
298  Objects_Id               id,
299  rtems_timer_information *the_info
300);
301
302/**
303 *  Macros and routines that expose the mechanisms required to service
304 *  the Timer Server timer.  These stop the timer, synchronize it with
305 *  the current time, and restart it.
306 */
307extern Watchdog_Control _Timer_Seconds_timer;
308
309#define _Timer_Server_stop_ticks_timer() \
310      _Watchdog_Remove( &_Timer_Server->Timer )
311
312#define _Timer_Server_stop_seconds_timer() \
313      _Watchdog_Remove( &_Timer_Seconds_timer );
314
315/**
316 *  This is a helper function which processes the ticks chain when
317 *  needed.  It advances time for the ticks chain which results in
318 *  timers firing.
319 */
320void _Timer_Server_process_ticks_chain(void);
321
322/**
323 *  This is a helper function which processes the seconds chain when
324 *  needed.  It advances time for the seconds chain which results in
325 *  timers firing.
326 */
327void _Timer_Server_process_seconds_chain(void);
328
329#define _Timer_Server_reset_ticks_timer() \
330   do { \
331      if ( !_Chain_Is_empty( &_Timer_Ticks_chain ) ) { \
332        _Watchdog_Insert_ticks( &_Timer_Server->Timer, \
333           ((Watchdog_Control *)_Timer_Ticks_chain.first)->delta_interval ); \
334      } \
335   } while (0)
336
337#define _Timer_Server_reset_seconds_timer() \
338   do { \
339      if ( !_Chain_Is_empty( &_Timer_Seconds_chain ) ) { \
340        _Watchdog_Insert_seconds( &_Timer_Seconds_timer, \
341          ((Watchdog_Control *)_Timer_Seconds_chain.first)->delta_interval ); \
342      } \
343   } while (0)
344
345#ifndef __RTEMS_APPLICATION__
346#include <rtems/rtems/timer.inl>
347#endif
348
349#ifdef __cplusplus
350}
351#endif
352
353/**@}*/
354
355#endif
356/* end of include file */
Note: See TracBrowser for help on using the repository browser.