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