source: rtems/c/src/lib/libbsp/m68k/mvme162/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: 2.3 KB
Line 
1/*
2 *  This routine initializes the Tick Timer 1 on the MVME162 board.
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.org/license/LICENSE.
10 *
11 *  Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
12 *  EISCAT Scientific Association. M.Savitski
13 *
14 *  This material is a part of the MVME162 Board Support Package
15 *  for the RTEMS executive. Its licensing policies are those of the
16 *  RTEMS above.
17 */
18
19#include <rtems.h>
20#include <rtems/btimer.h>
21#include <bsp.h>
22
23/* Periodic tick interval */
24#define TICK_INTERVAL         0x10000U
25#define TIMER_INT_LEVEL       6
26
27uint32_t            Ttimer_val;
28bool                benchmark_timer_find_average_overhead;
29
30rtems_isr timerisr(void);
31
32void benchmark_timer_initialize(void)
33{
34  (void) set_vector( timerisr, VBR0 * 0x10 + 0x8, 0 );
35
36  Ttimer_val = 0;                     /* clear timer ISR count */
37  lcsr->vector_base |= MASK_INT;      /* unmask VMEchip2 interrupts */
38  lcsr->intr_clear |= 0x01000000;     /* clear pending interrupt */
39  lcsr->to_ctl = 0xE7;                /* prescaler to 1 MHz (see Appendix A1) */
40  lcsr->timer_cmp_1 = TICK_INTERVAL;
41  lcsr->timer_cnt_1 = 0;              /* clear counter */
42  lcsr->board_ctl |= 7;               /* increment, reset-on-compare, */
43                                      /*   and clear-overflow-cnt */
44
45  lcsr->intr_level[0] |= TIMER_INT_LEVEL; /* set int level */
46  lcsr->intr_ena |= 0x01000000;           /* enable tick timer 1 interrupt */
47}
48
49#define AVG_OVERHEAD      3U    /* It typically takes 3.0 microseconds */
50                                /* (3 countdowns) to start/stop the timer. */
51#define LEAST_VALID       10U   /* Don't trust a value lower than this */
52
53benchmark_timer_t benchmark_timer_read(void)
54{
55  uint32_t            total;
56
57  total = (Ttimer_val * TICK_INTERVAL) + lcsr->timer_cnt_1;
58
59  if ( benchmark_timer_find_average_overhead == true )
60    return total;          /* in one-half microsecond units */
61
62  if ( total < LEAST_VALID )
63    return 0;            /* below timer resolution */
64
65  return (total-AVG_OVERHEAD) >> 1;
66}
67
68void benchmark_timer_disable_subtracting_average_overhead(
69  bool find_flag
70)
71{
72  benchmark_timer_find_average_overhead = find_flag;
73}
Note: See TracBrowser for help on using the repository browser.