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

4.115
Last change on this file since bcf536a was bcf536a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/10/15 at 13:51:50

score: Split _Watchdog_Adjust()

Split _Watchdog_Adjust() into _Watchdog_Adjust_backward() and
_Watchdog_Adjust_forward(). Remove Watchdog_Adjust_directions,
_Watchdog_Adjust_seconds() and _Watchdog_Adjust_ticks(). This avoids to
check the same condition again.

Update #2307.

  • Property mode set to 100644
File size: 1.3 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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/todimpl.h>
22#include <rtems/score/threaddispatch.h>
23#include <rtems/score/watchdogimpl.h>
24
25void _TOD_Set_with_timestamp(
26  const Timestamp_Control *tod_as_timestamp
27)
28{
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 );
32  Watchdog_Interval seconds_now;
33  ISR_lock_Context lock_context;
34  Chain_Control *header;
35
36  _Thread_Disable_dispatch();
37
38  seconds_now = _TOD_Seconds_since_epoch();
39  header = &_Watchdog_Seconds_chain;
40
41  if ( seconds_next < seconds_now )
42    _Watchdog_Adjust_backward( header, seconds_now - seconds_next );
43  else
44    _Watchdog_Adjust_forward( header, seconds_next - seconds_now );
45
46  _TOD_Acquire( tod, &lock_context );
47  tod->now = *tod_as_timestamp;
48  _TOD_Release( tod, &lock_context );
49
50  tod->seconds_trigger = nanoseconds;
51  tod->is_set = true;
52
53  _Thread_Enable_dispatch();
54}
Note: See TracBrowser for help on using the repository browser.