source:
rtems/cpukit/rtems/src/clockset.c
@
c0623a99
Last change on this file since c0623a99 was 1ef8e4a8, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/16 at 20:07:56 | |
---|---|
|
|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[205dbb9d] | 1 | /** |
2 | * @file | |
[bd83f47] | 3 | * |
[205dbb9d] | 4 | * @brief Set the Current TOD |
5 | * @ingroup ClassicClock | |
6 | */ | |
7 | ||
8 | /* | |
[08311cc3] | 9 | * COPYRIGHT (c) 1989-1999. |
[bd83f47] | 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. |
[bd83f47] | 15 | */ |
16 | ||
[1095ec1] | 17 | #if HAVE_CONFIG_H |
18 | #include "config.h" | |
19 | #endif | |
20 | ||
[bd83f47] | 21 | #include <rtems/rtems/clock.h> |
[f031df0e] | 22 | #include <rtems/score/todimpl.h> |
[0c3edbf] | 23 | #include <rtems/config.h> |
[bd83f47] | 24 | |
25 | rtems_status_code rtems_clock_set( | |
[8d7aea0d] | 26 | const rtems_time_of_day *tod |
[bd83f47] | 27 | ) |
28 | { | |
[8d7aea0d] | 29 | if ( !tod ) |
[e980b219] | 30 | return RTEMS_INVALID_ADDRESS; |
31 | ||
[8d7aea0d] | 32 | if ( _TOD_Validate( tod ) ) { |
33 | Timestamp_Control tod_as_timestamp; | |
[1ef8e4a8] | 34 | uint32_t seconds; |
35 | uint32_t nanoseconds; | |
36 | ISR_lock_Context lock_context; | |
[8d7aea0d] | 37 | |
[1ef8e4a8] | 38 | seconds = _TOD_To_seconds( tod ); |
39 | nanoseconds = tod->ticks | |
40 | * rtems_configuration_get_nanoseconds_per_tick(); | |
[8d7aea0d] | 41 | _Timestamp_Set( &tod_as_timestamp, seconds, nanoseconds ); |
[812da54] | 42 | |
[1ef8e4a8] | 43 | _TOD_Lock(); |
44 | _TOD_Acquire( &lock_context ); | |
45 | _TOD_Set( &tod_as_timestamp, &lock_context ); | |
46 | _TOD_Unlock(); | |
[8d7aea0d] | 47 | |
[bd83f47] | 48 | return RTEMS_SUCCESSFUL; |
49 | } | |
[8d7aea0d] | 50 | |
[bd83f47] | 51 | return RTEMS_INVALID_CLOCK; |
52 | } |
Note: See TracBrowser
for help on using the repository browser.