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

4.104.114.84.95
Last change on this file since a85d8ec was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 1.5 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.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/object.h>
17#include <rtems/score/thread.h>
18#include <rtems/score/tod.h>
19#include <rtems/score/watchdog.h>
20
21/*PAGE
22 *
23 *  _TOD_Set
24 *
25 *  This rountine sets the current date and time with the specified
26 *  new date and time structure.
27 *
28 *  Input parameters:
29 *    the_tod             - pointer to the time and date structure
30 *    seconds_since_epoch - seconds since system epoch
31 *
32 *  Output parameters: NONE
33 */
34
35void _TOD_Set(
36  TOD_Control *the_tod,
37  Watchdog_Interval  seconds_since_epoch
38)
39{
40  Watchdog_Interval ticks_until_next_second;
41
42  _Thread_Disable_dispatch();
43  _TOD_Deactivate();
44
45  if ( seconds_since_epoch < _TOD_Seconds_since_epoch )
46    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD,
47       _TOD_Seconds_since_epoch - seconds_since_epoch );
48  else
49    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD,
50       seconds_since_epoch - _TOD_Seconds_since_epoch );
51
52  ticks_until_next_second = _TOD_Ticks_per_second;
53  if ( ticks_until_next_second > _TOD_Current.ticks )
54    ticks_until_next_second -= _TOD_Current.ticks;
55
56  _TOD_Current             = *the_tod;
57  _TOD_Seconds_since_epoch = seconds_since_epoch;
58  _TOD_Is_set              = TRUE;
59  _TOD_Activate( ticks_until_next_second );
60
61  _Thread_Enable_dispatch();
62}
63
Note: See TracBrowser for help on using the repository browser.