OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [coretodset.c] - Blame information for rev 227

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: coretodset.c,v 1.2 2001-09-27 11:59:34 chris Exp $
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
 
35
void _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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.