source: rtems/cpukit/score/include/rtems/score/tod.h @ 6a07436

4.104.114.84.95
Last change on this file since 6a07436 was 6a07436, checked in by Joel Sherrill <joel.sherrill@…>, on 01/16/06 at 15:13:58

2006-01-16 Joel Sherrill <joel@…>

Large patch to improve Doxygen output. As a side-effect, grammar and
spelling errors were corrected, spacing errors were address, and some
variable names were improved.

  • libmisc/monitor/mon-object.c, libmisc/monitor/monitor.h: Account for changing OBJECTS_NO_CLASS to OBJECTS_CLASSIC_NO_CLASS.
  • score/Doxyfile: Set output directory. Predefine some macro values. Turn on graphical output.
  • score/include/rtems/debug.h, score/include/rtems/seterr.h, score/include/rtems/system.h, score/include/rtems/score/address.h, score/include/rtems/score/apiext.h, score/include/rtems/score/apimutex.h, score/include/rtems/score/bitfield.h, score/include/rtems/score/chain.h, score/include/rtems/score/context.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h, score/include/rtems/score/heap.h, score/include/rtems/score/interr.h, score/include/rtems/score/isr.h, score/include/rtems/score/mpci.h, score/include/rtems/score/mppkt.h, score/include/rtems/score/object.h, score/include/rtems/score/objectmp.h, score/include/rtems/score/priority.h, score/include/rtems/score/stack.h, score/include/rtems/score/states.h, score/include/rtems/score/sysstate.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadmp.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tod.h, score/include/rtems/score/tqdata.h, score/include/rtems/score/userext.h, score/include/rtems/score/watchdog.h, score/include/rtems/score/wkspace.h, score/inline/rtems/score/address.inl, score/inline/rtems/score/chain.inl, score/inline/rtems/score/coremutex.inl, score/inline/rtems/score/coresem.inl, score/inline/rtems/score/heap.inl, score/inline/rtems/score/object.inl, score/inline/rtems/score/stack.inl, score/inline/rtems/score/thread.inl, score/inline/rtems/score/tqdata.inl, score/macros/README, score/src/heap.c, score/src/threadmp.c, score/src/threadready.c, score/src/threadstartmultitasking.c: Improve generated Doxygen output. Fix spelling and grammar errors in comments. Correct names of some variables and propagate changes.
  • Property mode set to 100644
File size: 8.3 KB
Line 
1/**
2 *  @file  rtems/score/tod.h
3 *
4 *  This include file contains all the constants and structures associated
5 *  with the Time of Day Handler.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2006.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_SCORE_TOD_H
20#define _RTEMS_SCORE_TOD_H
21
22/**
23 *  @defgroup ScoreTOD Time Of Day (TOD) Handler
24 *
25 *  This handler encapsulates functionality used to manage time of day.
26 */
27/**@{*/
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <rtems/score/object.h>
34#include <rtems/score/watchdog.h>
35
36/** @defgroup ScoreTODConstants TOD Constants
37 *  The following constants are related to the time of day.
38 */
39/**@{*/
40
41/**
42 *  This constant represents the number of seconds in a minute.
43 */
44#define TOD_SECONDS_PER_MINUTE (uint32_t)60
45
46/**
47 *  This constant represents the number of minutes per hour.
48 */
49#define TOD_MINUTES_PER_HOUR   (uint32_t)60
50
51/**
52 *  This constant represents the number of months in a year.
53 */
54#define TOD_MONTHS_PER_YEAR    (uint32_t)12
55
56/**
57 *  This constant represents the number of days in a non-leap year.
58 */
59#define TOD_DAYS_PER_YEAR      (uint32_t)365
60
61/**
62 *  This constant represents the number of hours per day.
63 */
64#define TOD_HOURS_PER_DAY      (uint32_t)24
65
66/**
67 *  This constant represents the number of seconds in a day which does
68 *  not include a leap second.
69 */
70#define TOD_SECONDS_PER_DAY    (uint32_t) (TOD_SECONDS_PER_MINUTE * \
71                                TOD_MINUTES_PER_HOUR   * \
72                                TOD_HOURS_PER_DAY)
73
74/**
75 *  This constant represents the number of seconds in a non-leap year.
76 */
77#define TOD_SECONDS_PER_NON_LEAP_YEAR (365 * TOD_SECONDS_PER_DAY)
78
79/**
80 *  This constant represents the number of seconds in a millisecond.
81 */
82#define TOD_MILLISECONDS_PER_SECOND     (uint32_t)1000
83
84/**
85 *  This constant represents the number of microseconds in a second.
86 */
87#define TOD_MICROSECONDS_PER_SECOND     (uint32_t)1000000
88
89/**
90 *  This constant represents the number of nanoseconds in a second.
91 */
92#define TOD_NANOSECONDS_PER_SECOND      (uint32_t)1000000000
93
94/**
95 *  This constant represents the number of nanoseconds in a second.
96 */
97#define TOD_NANOSECONDS_PER_MICROSECOND (uint32_t)1000
98
99/**@}*/
100
101/** @brief RTEMS Epoch Year
102 *
103 *  The following constant define the earliest year to which an
104 *  time of day can be initialized.  This is considered the
105 *  epoch.
106 */
107#define TOD_BASE_YEAR 1988
108
109/**
110 *  The following record defines the time of control block.  This
111 *  control block is used to maintain the current time of day.
112 *
113 *  @note This is an RTEID style time/date.
114 */
115typedef struct {
116  /** This field is the year, A.D. */
117  uint32_t   year;
118  /** This field is the month, 1 -> 12 */
119  uint32_t   month;
120  /** This field is the day, 1 -> 31 */
121  uint32_t   day;
122  /** This field is the hour, 0 -> 23 */
123  uint32_t   hour;
124  /** This field is the minute, 0 -> 59 */
125  uint32_t   minute;
126  /** This field is the second, 0 -> 59 */
127  uint32_t   second;
128  /** This field is the elapsed ticks between secs */
129  uint32_t   ticks;
130}   TOD_Control;
131
132/** @brief Is the Time Of Day Set
133 *
134 *  This is TRUE if the application has set the current
135 *  time of day, and FALSE otherwise.
136 */
137SCORE_EXTERN boolean _TOD_Is_set;
138
139/** @brief Current Time of Day
140 *  The following contains the current time of day.
141 */
142SCORE_EXTERN TOD_Control _TOD_Current;
143
144/** @brief Seconds Since RTEMS Epoch
145 *  The following contains the number of seconds from 00:00:00
146 *  January 1, TOD_BASE_YEAR until the current time of day.
147 */
148SCORE_EXTERN Watchdog_Interval _TOD_Seconds_since_epoch;
149
150/** @brief Microseconds per Clock Tick
151 *
152 *  The following contains the number of microseconds per tick.
153 */
154SCORE_EXTERN uint32_t   _TOD_Microseconds_per_tick;
155
156/** @brief Clock Ticks per Second
157 *
158 *  The following contains the number of clock ticks per second.
159 *
160 *  @note If one second is NOT evenly divisible by the number of microseconds
161 *  per clock tick, this value will contain only the integer portion
162 *  of the division.  This means that the interval between clock ticks
163 *  can be a source of error in the current time of day.
164 */
165SCORE_EXTERN uint32_t   _TOD_Ticks_per_second;
166
167/** @brief Watchdog Set Managed by Seconds
168 *
169 *  This is the control structure for the watchdog timer which
170 *  fires to service the seconds chain.
171 */
172SCORE_EXTERN Watchdog_Control _TOD_Seconds_watchdog;
173
174#ifdef SCORE_INIT
175
176/*
177 *  The following array contains the number of days in all months.
178 *  The first dimension should be 1 for leap years, and 0 otherwise.
179 *  The second dimension should range from 1 to 12 for January to
180 *  February, respectively.
181 */
182const uint32_t   _TOD_Days_per_month[ 2 ][ 13 ] = {
183  { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
184  { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
185};
186
187/*
188 *  The following array contains the number of days in all months
189 *  up to the month indicated by the index of the second dimension.
190 *  The first dimension should be 1 for leap years, and 0 otherwise.
191 */
192const uint16_t   _TOD_Days_to_date[2][13] = {
193  { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
194  { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
195};
196
197/*
198 *  The following array contains the number of days in the years
199 *  since the last leap year.  The index should be 0 for leap
200 *  years, and the number of years since the beginning of a leap
201 *  year otherwise.
202 */
203const uint16_t   _TOD_Days_since_last_leap_year[4] = { 0, 366, 731, 1096 };
204
205#else
206
207/** @brief Convert Month to Julian Days
208 *
209 *  This is a prototype for a table which assists in converting the
210 *  current day into the Julian days since the first of the year.
211 */
212extern const uint16_t   _TOD_Days_to_date[2][13]; /* Julian days */
213
214/** @brief Days since Beginning of Last Leap Year
215 *
216 *  This is a prototype for a table which assists in calculating the
217 *  number of days since the beginning of the last leap year.
218 */
219extern const uint16_t   _TOD_Days_since_last_leap_year[4];
220
221/** @brief Days Per Month Table
222 *
223 *  This is a prototype for a table which holds the number of days
224 *  per month for a leap year and non-leap year.
225 */
226extern const uint32_t   _TOD_Days_per_month[2][13];
227
228#endif
229
230/** @brief _TOD_Handler_initialization
231 *
232 *  This routine performs the initialization necessary for this handler.
233 */
234void _TOD_Handler_initialization(
235  uint32_t   microseconds_per_tick
236);
237
238/** @brief _TOD_Set
239 *
240 *  This routine sets the current time of day to THE_TOD and
241 *  the equivalent SECONDS_SINCE_EPOCH.
242 */
243void _TOD_Set(
244  TOD_Control       *the_tod,
245  Watchdog_Interval  seconds_since_epoch
246);
247
248/** @brief _TOD_Validate
249 *
250 *  This function returns TRUE if THE_TOD contains
251 *  a valid time of day, and FALSE otherwise.
252 */
253boolean _TOD_Validate(
254  TOD_Control *the_tod
255);
256
257/** @brief _TOD_To_seconds
258 *
259 *  This function returns the number seconds between the epoch and THE_TOD.
260 */
261Watchdog_Interval _TOD_To_seconds(
262  TOD_Control *the_tod
263);
264
265/** @brief _TOD_Tickle
266 *
267 *  This routine is scheduled as a watchdog function and is invoked at
268 *  each second boundary.  It updates the current time of day to indicate
269 *  that a second has passed and processes the seconds watchdog chain.
270 */
271void _TOD_Tickle(
272  Objects_Id  id,
273  void       *ignored
274);
275
276/** @brief TOD_MILLISECONDS_TO_MICROSECONDS
277 *
278 *  This routine converts an interval expressed in milliseconds to microseconds.
279 *
280 *  @note This must be a macro so it can be used in "static" tables.
281 */
282#define TOD_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000)
283
284/** @brief TOD_MICROSECONDS_TO_TICKS
285 *
286 *  This routine converts an interval expressed in microseconds to ticks.
287 *
288 *  @note This must be a macro so it can be used in "static" tables.
289 */
290#define TOD_MICROSECONDS_TO_TICKS(_us) \
291    ((_us) / _TOD_Microseconds_per_tick)
292
293/** @brief TOD_MILLISECONDS_TO_TICKS
294 *
295 *  This routine converts an interval expressed in milliseconds to ticks.
296 *
297 *  @note This must be a macro so it can be used in "static" tables.
298 */
299
300#define TOD_MILLISECONDS_TO_TICKS(_ms) \
301    (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick)
302
303#ifndef __RTEMS_APPLICATION__
304#include <rtems/score/tod.inl>
305#endif
306
307#ifdef __cplusplus
308}
309#endif
310
311/**@}*/
312
313#endif
314/* end of include file */
Note: See TracBrowser for help on using the repository browser.