source: rtems/c/src/lib/libbsp/m68k/mrm332/timer/timer.c @ 8fbe2e6

4.11
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2014 at 1:59:49 PM

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1999.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#include <bsp.h>
11#include <rtems/btimer.h>
12
13bool benchmark_timer_find_average_overhead;
14
15extern rtems_isr Clock_isr(void);
16
17void benchmark_timer_initialize( void )
18{
19}
20
21/*
22 *  The following controls the behavior of benchmark_timer_read().
23 *
24 *  FIND_AVG_OVERHEAD *  instructs the routine to return the "raw" count.
25 *
26 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
27 *  is usually deducted from the number returned.
28 *
29 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
30 *  below this are "noise" and zero is returned.
31 */
32
33#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
34                             /* (Y countdowns) to start/stop the timer. */
35                             /* This value is in microseconds. */
36#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
37
38/*
39 * Return timer value in 1/2-microsecond units
40 */
41benchmark_timer_t benchmark_timer_read( void )
42{
43  uint32_t         total;
44  total = 0;
45
46  if ( benchmark_timer_find_average_overhead == true )
47    return total;          /* in XXX microsecond units */
48
49  if ( total < LEAST_VALID )
50    return 0;            /* below timer resolution */
51
52  return (total - AVG_OVERHEAD);
53}
54
55void benchmark_timer_disable_subtracting_average_overhead(
56  bool find_flag
57)
58{
59  benchmark_timer_find_average_overhead = find_flag;
60}
Note: See TracBrowser for help on using the repository browser.