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

4.115
Last change on this file since a2e3f33 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Time of Day Given a Timestamp
5 *
6 * @ingroup ScoreTOD
7 */
8
9/*  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/threaddispatch.h>
24#include <rtems/score/timestamp.h>
25#include <rtems/score/tod.h>
26#include <rtems/score/watchdogimpl.h>
27
28void _TOD_Set_with_timestamp(
29  const Timestamp_Control *tod
30)
31{
32  uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod );
33  Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod );
34  Watchdog_Interval seconds_now;
35
36  _Thread_Disable_dispatch();
37  _TOD_Deactivate();
38
39  seconds_now = _TOD_Seconds_since_epoch();
40
41  if ( seconds_next < seconds_now )
42    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
43  else
44    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
45
46  _TOD.now = *tod;
47  _TOD.seconds_trigger = nanoseconds;
48  _TOD.is_set = true;
49
50  _TOD_Activate();
51  _Thread_Enable_dispatch();
52}
Note: See TracBrowser for help on using the repository browser.