source: rtems/cpukit/score/src/coretodtickle.c @ fa6b0f5

4.104.114.84.95
Last change on this file since fa6b0f5 was a8eed23, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/27/05 at 05:57:05

Include config.h.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  Time of Day (TOD) Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/object.h>
21#include <rtems/score/thread.h>
22#include <rtems/score/tod.h>
23#include <rtems/score/watchdog.h>
24
25/*PAGE
26 *
27 *  _TOD_Tickle
28 *
29 *  This routine updates the calendar time and tickles the
30 *  per second watchdog timer chain.
31 *
32 *  Input parameters:
33 *    ignored - this parameter is ignored
34 *
35 *  Output parameters: NONE
36 *
37 *  NOTE: This routine only works for leap-years through 2099.
38 */
39
40void _TOD_Tickle(
41  Objects_Id  id,
42  void       *ignored
43)
44{
45  uint32_t   leap;
46
47  _TOD_Current.ticks = 0;
48  ++_TOD_Seconds_since_epoch;
49  if ( ++_TOD_Current.second >= TOD_SECONDS_PER_MINUTE ) {
50    _TOD_Current.second = 0;
51    if ( ++_TOD_Current.minute >= TOD_MINUTES_PER_HOUR ) {
52      _TOD_Current.minute = 0;
53      if ( ++_TOD_Current.hour >= TOD_HOURS_PER_DAY ) {
54        _TOD_Current.hour = 0;
55        if ( _TOD_Current.year & 0x3 ) leap = 0;
56        else                           leap = 1;
57        if ( ++_TOD_Current.day >
58               _TOD_Days_per_month[ leap ][ _TOD_Current.month ]) {
59          _TOD_Current.day = 1;
60          if ( ++_TOD_Current.month > TOD_MONTHS_PER_YEAR ) {
61            _TOD_Current.month = 1;
62            _TOD_Current.year++;
63          }
64        }
65      }
66    }
67  }
68
69  _Watchdog_Tickle_seconds();
70  _Watchdog_Insert_ticks( &_TOD_Seconds_watchdog, _TOD_Ticks_per_second );
71}
Note: See TracBrowser for help on using the repository browser.