source: rtems/cpukit/score/src/coretodtickle.c @ 6af81435

4.104.114.84.95
Last change on this file since 6af81435 was 93b4e6ef, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 21:05:17

Split Heap and Time of Day Handlers.

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