4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Converts Microseconds to Ticks |
---|
5 | * |
---|
6 | * @ingroup ScoreTOD |
---|
7 | */ |
---|
8 | |
---|
9 | /* COPYRIGHT (c) 1989-2011. |
---|
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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/system.h> |
---|
23 | #include <rtems/config.h> |
---|
24 | #include <rtems/score/tod.h> |
---|
25 | |
---|
26 | uint32_t TOD_MICROSECONDS_TO_TICKS( |
---|
27 | uint32_t microseconds |
---|
28 | ) |
---|
29 | { |
---|
30 | uint32_t ticks; |
---|
31 | uint32_t microseconds_per_tick; |
---|
32 | |
---|
33 | /** |
---|
34 | * We should ensure the ticks not be truncated by integer division. We |
---|
35 | * need to have it be greater than or equal to the requested time. It |
---|
36 | * should not be shorter. |
---|
37 | */ |
---|
38 | microseconds_per_tick = rtems_configuration_get_microseconds_per_tick(); |
---|
39 | ticks = microseconds / microseconds_per_tick; |
---|
40 | if ( (microseconds % microseconds_per_tick) != 0 ) |
---|
41 | ticks += 1; |
---|
42 | |
---|
43 | return ticks; |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.