source: rtems/cpukit/rtems/include/rtems/rtems/timer.h @ 6d8720c4

4.104.115
Last change on this file since 6d8720c4 was 6d8720c4, checked in by Joel Sherrill <joel.sherrill@…>, on 05/10/09 at 14:55:43

2009-05-10 Joel Sherrill <joel.sherrill@…>

  • libmisc/shell/login_prompt.c, libmisc/shell/shell_script.c, rtems/include/rtems/rtems/timer.h: Fix warnings.
  • Property mode set to 100644
File size: 9.9 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-2009.
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/**
39 *  This constant is defined to extern most of the time when using
40 *  this header file.  However by defining it to nothing, the data
41 *  declared in this header file can be instantiated.  This is done
42 *  in a single per manager file.
43 */
44#ifndef RTEMS_TIMER_EXTERN
45#define RTEMS_TIMER_EXTERN extern
46#endif
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#include <rtems/score/object.h>
53#include <rtems/score/watchdog.h>
54#include <rtems/score/thread.h>
55#include <rtems/rtems/clock.h>
56#include <rtems/rtems/attr.h>
57
58/**
59 *  @defgroup ClassicTimer Classic API Timer
60 *
61 *  This encapsulates functionality related to the Classic API Timer
62 *  Manager.  This manager provides functionality which allows the
63 *  application to schedule the execution of methods at a specified
64 *  time in the future.  These methods may be scheduled based upon
65 *  interval or wall time and may be executed in either the clock tick
66 *  ISR or in a special dedicated timer server task.
67 */
68/**@{*/
69
70/**
71 *  The following enumerated type details the classes to which a timer
72 *  may belong.
73 */
74typedef enum {
75  /**
76   * This value indicates the timer is currently in use as an interval
77   * timer which will fire in the clock tick ISR.
78   */
79  TIMER_INTERVAL,
80
81  /**
82   * This value indicates the timer is currently in use as an interval
83   * timer which will fire in the timer server task.
84   */
85  TIMER_INTERVAL_ON_TASK,
86
87  /**
88   * This value indicates the timer is currently in use as an time of day
89   * timer which will fire in the clock tick ISR.
90   */
91  TIMER_TIME_OF_DAY,
92
93  /**
94   * This value indicates the timer is currently in use as an time of day
95   * timer which will fire in the timer server task.
96   */
97  TIMER_TIME_OF_DAY_ON_TASK,
98
99  /**
100   * This value indicates the timer is currently not in use.
101   */
102  TIMER_DORMANT
103} Timer_Classes;
104
105/**
106 *  The following types define a pointer to a timer service routine.
107 */
108typedef void rtems_timer_service_routine;
109
110/**
111 *  This type defines the type used to manage and indirectly invoke
112 *  Timer Service Routines (TSRs).  This defines the prototype and interface
113 *  for a function which is to be used as a TSR.
114 */
115typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )(
116                 rtems_id,
117                 void *
118             );
119
120/**
121 *  The following defines the information control block used to manage
122 *  this class of objects.
123 */
124RTEMS_TIMER_EXTERN Objects_Information  _Timer_Information;
125
126/**
127 *  Pointer to TCB of the Timer Server.  This is NULL before the
128 *  server is executing and task-based timers are not allowed to be
129 *  initiated until the server is started.
130 */
131RTEMS_TIMER_EXTERN Thread_Control *_Timer_Server;
132
133/**
134 *  The following records define the control block used to manage
135 *  each timer.
136 */
137typedef struct {
138  /** This field is the object management portion of a Timer instance. */
139  Objects_Control  Object;
140  /** This field is the Watchdog instance which will be the scheduled. */
141  Watchdog_Control Ticker;
142  /** This field indicates what type of timer this currently is. */
143  Timer_Classes    the_class;
144}   Timer_Control;
145
146/**
147 *  @brief _Timer_Manager_initialization
148 *
149 *  This routine performs the initialization necessary for this manager.
150 */
151void _Timer_Manager_initialization(void);
152
153/**
154 *  @brief rtems_timer_create
155 *
156 *  This routine implements the rtems_timer_create directive.  The
157 *  timer will have the name name.  It returns the id of the
158 *  created timer in ID.
159 */
160rtems_status_code rtems_timer_create(
161  rtems_name    name,
162  Objects_Id   *id
163);
164
165/**
166 *  @brief rtems_timer_ident
167 *
168 *  This routine implements the rtems_timer_ident directive.
169 *  This directive returns the timer ID associated with name.
170 *  If more than one timer is named name, then the timer
171 *  to which the ID belongs is arbitrary.
172 */
173rtems_status_code rtems_timer_ident(
174  rtems_name    name,
175  Objects_Id   *id
176);
177
178/**
179 *  @brief rtems_timer_cancel
180 *
181 *  This routine implements the rtems_timer_cancel directive.  It is used
182 *  to stop the timer associated with ID from firing.
183 */
184rtems_status_code rtems_timer_cancel(
185  Objects_Id id
186);
187
188/**
189 *  @brief rtems_timer_delete
190 *
191 *  This routine implements the rtems_timer_delete directive.  The
192 *  timer indicated by ID is deleted.
193 */
194rtems_status_code rtems_timer_delete(
195  Objects_Id id
196);
197
198/**
199 *  @brief rtems_timer_fire_after
200 *
201 *  This routine implements the rtems_timer_fire_after directive.  It
202 *  initiates the timer associated with ID to fire in ticks clock ticks.
203 *  When the timer fires, the routine will be invoked in the context
204 *  of the rtems_clock_tick directive which is normally invoked as
205 *  part of servicing a periodic interupt.
206 */
207rtems_status_code rtems_timer_fire_after(
208  Objects_Id                         id,
209  rtems_interval                     ticks,
210  rtems_timer_service_routine_entry  routine,
211  void                              *user_data
212);
213
214/**
215 *  @brief rtems_timer_server_fire_after
216 *
217 *  This routine implements the rtems_timer_server_fire_after directive.  It
218 *  initiates the timer associated with ID to fire in ticks clock
219 *  ticks.  When the timer fires, the routine will be invoked by the
220 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
221 *  clock tick interrupt.
222 */
223rtems_status_code rtems_timer_server_fire_after(
224  Objects_Id                         id,
225  rtems_interval                     ticks,
226  rtems_timer_service_routine_entry  routine,
227  void                              *user_data
228);
229
230/**
231 *  @brief rtems_timer_fire_when
232 *
233 *  This routine implements the rtems_timer_fire_when directive.  It
234 *  initiates the timer associated with ID to fire at wall_time
235 *  When the timer fires, the routine will be invoked in the context
236 *  of the rtems_clock_tick directive which is normally invoked as
237 *  part of servicing a periodic interupt.
238 */
239rtems_status_code rtems_timer_fire_when(
240  Objects_Id                          id,
241  rtems_time_of_day                  *wall_time,
242  rtems_timer_service_routine_entry   routine,
243  void                               *user_data
244);
245
246/**
247 *  @brief rtems_timer_server_fire_when
248 *
249 *  This routine implements the rtems_timer_server_fire_when directive.  It
250 *  initiates the timer associated with ID to fire at wall_time
251 *  When the timer fires, the routine will be invoked by the
252 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
253 *  clock tick interrupt.
254 */
255rtems_status_code rtems_timer_server_fire_when(
256  Objects_Id                          id,
257  rtems_time_of_day                  *wall_time,
258  rtems_timer_service_routine_entry   routine,
259  void                               *user_data
260);
261
262/**
263 *  @brief rtems_timer_reset
264 *
265 *  This routine implements the rtems_timer_reset directive.  It is used
266 *  to reinitialize the interval timer associated with ID just as if
267 *  rtems_timer_fire_after were re-invoked with the same arguments that
268 *  were used to initiate this timer.
269 */
270rtems_status_code rtems_timer_reset(
271  Objects_Id id
272);
273
274/**
275 *  @brief rtems_timer_initiate_server
276 *
277 *  This routine implements the rtems_timer_initiate_server directive.
278 *  It creates and starts the server that executes task-based timers.
279 *  It must be invoked before any task-based timers can be initiated.
280 */
281rtems_status_code rtems_timer_initiate_server(
282  uint32_t             priority,
283  uint32_t             stack_size,
284  rtems_attribute      attribute_set
285);
286
287/**
288 *  This is the default value for the priority of the Timer Server.
289 *  When given this priority, a special high priority not accessible
290 *  via the Classic API is used.
291 */
292#define RTEMS_TIMER_SERVER_DEFAULT_PRIORITY (uint32_t) -1
293
294/**
295 *  This is the structure filled in by the timer get information
296 *  service.
297 */
298typedef struct {
299  /** This indicates the current type of the timer. */
300  Timer_Classes      the_class;
301  /** This indicates the initial requested interval. */
302  Watchdog_Interval  initial;
303  /** This indicates the time the timer was initially scheduled. */
304  Watchdog_Interval  start_time;
305  /** This indicates the time the timer is scheduled to fire. */
306  Watchdog_Interval  stop_time;
307} rtems_timer_information;
308
309/**
310 *  @brief rtems_timer_get_information
311 *
312 *  This routine implements the rtems_timer_get_information directive.
313 *  This directive returns information about the timer.
314 */
315rtems_status_code rtems_timer_get_information(
316  Objects_Id               id,
317  rtems_timer_information *the_info
318);
319
320/**
321 *  This type defines the method used to schedule the insertion of task
322 *  based timers.
323 */
324typedef void (*Timer_Server_schedule_operation_t)(
325  Timer_Control     *the_timer
326);
327
328/**
329 *  This variable will point to the schedule operation method once the
330 *  timer server is initialized.
331 */
332RTEMS_TIMER_EXTERN Timer_Server_schedule_operation_t
333  _Timer_Server_schedule_operation;
334
335#ifndef __RTEMS_APPLICATION__
336#include <rtems/rtems/timer.inl>
337#endif
338
339#ifdef __cplusplus
340}
341#endif
342
343/**@}*/
344
345#endif
346/* end of include file */
Note: See TracBrowser for help on using the repository browser.