source: rtems/cpukit/score/src/coretodset.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 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.6 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_Set
28 *
29 *  This rountine sets the current date and time with the specified
30 *  new date and time structure.
31 *
32 *  Input parameters:
33 *    the_tod             - pointer to the time and date structure
34 *    seconds_since_epoch - seconds since system epoch
35 *
36 *  Output parameters: NONE
37 */
38
39void _TOD_Set(
40  TOD_Control *the_tod,
41  Watchdog_Interval  seconds_since_epoch
42)
43{
44  Watchdog_Interval ticks_until_next_second;
45
46  _Thread_Disable_dispatch();
47  _TOD_Deactivate();
48
49  if ( seconds_since_epoch < _TOD_Seconds_since_epoch )
50    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD,
51       _TOD_Seconds_since_epoch - seconds_since_epoch );
52  else
53    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD,
54       seconds_since_epoch - _TOD_Seconds_since_epoch );
55
56  ticks_until_next_second = _TOD_Ticks_per_second;
57  if ( ticks_until_next_second > the_tod->ticks )
58    ticks_until_next_second -= the_tod->ticks;
59
60  _TOD_Current             = *the_tod;
61  _TOD_Seconds_since_epoch = seconds_since_epoch;
62  _TOD_Is_set              = TRUE;
63  _TOD_Activate( ticks_until_next_second );
64
65  _Thread_Enable_dispatch();
66}
Note: See TracBrowser for help on using the repository browser.