source: rtems/cpukit/score/src/coretodset.c @ 25f5730f

4.115
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[1b475860]1/**
2 * @file
3 *
4 * @brief Set Time of Day Given a Timestamp
5 *
6 * @ingroup ScoreTOD
[412dbff6]7 */
8
9/*  COPYRIGHT (c) 1989-2007.
[93b4e6ef]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[93b4e6ef]15 */
16
[a8eed23]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[f031df0e]21#include <rtems/score/todimpl.h>
[88c74ab]22#include <rtems/score/threaddispatch.h>
[4b48ece0]23#include <rtems/score/watchdogimpl.h>
[93b4e6ef]24
[8d7aea0d]25void _TOD_Set_with_timestamp(
[9bf7467]26  const Timestamp_Control *tod_as_timestamp
[93b4e6ef]27)
28{
[9bf7467]29  TOD_Control *tod = &_TOD;
30  uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod_as_timestamp );
31  Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod_as_timestamp );
[8d7aea0d]32  Watchdog_Interval seconds_now;
[d50acdbb]33  ISR_lock_Context lock_context;
[c16bcc0]34
[93b4e6ef]35  _Thread_Disable_dispatch();
36
[8d7aea0d]37  seconds_now = _TOD_Seconds_since_epoch();
[c16bcc0]38
[8d7aea0d]39  if ( seconds_next < seconds_now )
40    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
[93b4e6ef]41  else
[8d7aea0d]42    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
[93b4e6ef]43
[d50acdbb]44  _TOD_Acquire( tod, &lock_context );
[9bf7467]45  tod->now = *tod_as_timestamp;
[d50acdbb]46  _TOD_Release( tod, &lock_context );
[9bf7467]47
48  tod->seconds_trigger = nanoseconds;
49  tod->is_set = true;
[812da54]50
[93b4e6ef]51  _Thread_Enable_dispatch();
52}
Note: See TracBrowser for help on using the repository browser.