source:
rtems/cpukit/score/src/coretodget.c
@
25f5730f
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47 | |
---|---|
|
|
File size: 1.0 KB |
Rev | Line | |
---|---|---|
[355ee7d] | 1 | /** |
2 | * @file | |
[812da54] | 3 | * |
[355ee7d] | 4 | * @brief Returns a Current TOD with Nanosecond Granularity |
5 | * @ingroup ScoreTODConstants | |
6 | */ | |
7 | ||
8 | /* | |
[6a614160] | 9 | * COPYRIGHT (c) 1989-2008. |
[812da54] | 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. |
[812da54] | 15 | */ |
16 | ||
17 | #if HAVE_CONFIG_H | |
[62181b21] | 18 | #include "config.h" |
[812da54] | 19 | #endif |
20 | ||
[f031df0e] | 21 | #include <rtems/score/todimpl.h> |
[88c74ab] | 22 | #include <rtems/score/isrlevel.h> |
[812da54] | 23 | |
[62181b21] | 24 | Timestamp_Control *_TOD_Get_with_nanoseconds( |
25 | Timestamp_Control *snapshot, | |
26 | const Timestamp_Control *clock | |
[812da54] | 27 | ) |
28 | { | |
[965a442] | 29 | TOD_Control *tod = &_TOD; |
[d50acdbb] | 30 | ISR_lock_Context lock_context; |
[c16bcc0] | 31 | Timestamp_Control offset; |
32 | Timestamp_Control now; | |
[62181b21] | 33 | uint32_t nanoseconds; |
[812da54] | 34 | |
[d50acdbb] | 35 | _TOD_Acquire( tod, &lock_context ); |
[965a442] | 36 | nanoseconds = ( *tod->nanoseconds_since_last_tick )(); |
[62181b21] | 37 | now = *clock; |
[d50acdbb] | 38 | _TOD_Release( tod, &lock_context ); |
[812da54] | 39 | |
[c16bcc0] | 40 | _Timestamp_Set( &offset, 0, nanoseconds ); |
41 | _Timestamp_Add_to( &now, &offset ); | |
[8d7aea0d] | 42 | |
[62181b21] | 43 | *snapshot = now; |
44 | ||
45 | return snapshot; | |
[812da54] | 46 | } |
Note: See TracBrowser
for help on using the repository browser.