5
Last change
on this file since 8054b1c 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.1 KB
|
Line | |
---|
1 | /* |
---|
2 | * Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <rtems@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.org/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <rtems/counter.h> |
---|
16 | |
---|
17 | RTEMS_STATIC_ASSERT(sizeof(rtems_counter_ticks) <= sizeof(uint32_t), type); |
---|
18 | |
---|
19 | static uint64_t to_ns_scaler = UINT64_C(1) << 32; |
---|
20 | |
---|
21 | static uint64_t from_ns_scaler = UINT64_C(1) << 32; |
---|
22 | |
---|
23 | uint64_t rtems_counter_ticks_to_nanoseconds( rtems_counter_ticks counter ) |
---|
24 | { |
---|
25 | return (uint32_t) ((counter * to_ns_scaler) >> 32); |
---|
26 | } |
---|
27 | |
---|
28 | rtems_counter_ticks rtems_counter_nanoseconds_to_ticks( uint32_t nanoseconds ) |
---|
29 | { |
---|
30 | return (rtems_counter_ticks) ((nanoseconds * from_ns_scaler) >> 32); |
---|
31 | } |
---|
32 | |
---|
33 | void rtems_counter_initialize_converter( uint32_t frequency ) |
---|
34 | { |
---|
35 | uint64_t ns_per_s = UINT64_C(1000000000); |
---|
36 | |
---|
37 | to_ns_scaler = ((ns_per_s << 32) + frequency - 1) / frequency; |
---|
38 | from_ns_scaler = ((UINT64_C(1) << 32) * frequency + ns_per_s - 1) / ns_per_s; |
---|
39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.