source: rtems/c/src/lib/libbsp/m68k/mvme162/timer/timer.c @ 67c191b2

4.9
Last change on this file since 67c191b2 was 67c191b2, checked in by Joel Sherrill <joel.sherrill@…>, on 09/30/08 at 16:28:39

2008-09-30 Joel Sherrill <joel.sherrill@…>

  • timer/timer.c: Eliminate uses of old benchmark timer names.
  • 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.com/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 *  $Id$
19 */
20
21#include <rtems.h>
22#include <bsp.h>
23
24/* Periodic tick interval */
25#define TICK_INTERVAL         0x10000U
26#define TIMER_INT_LEVEL       6
27
28uint32_t            Ttimer_val;
29bool                benchmark_timer_find_average_overhead;
30
31rtems_isr timerisr(void);
32
33void benchmark_timer_initialize(void)
34{
35  (void) set_vector( timerisr, VBR0 * 0x10 + 0x8, 0 );
36
37  Ttimer_val = 0;                     /* clear timer ISR count */
38  lcsr->vector_base |= MASK_INT;      /* unmask VMEchip2 interrupts */
39  lcsr->intr_clear |= 0x01000000;     /* clear pending interrupt */
40  lcsr->to_ctl = 0xE7;                /* prescaler to 1 MHz (see Appendix A1) */
41  lcsr->timer_cmp_1 = TICK_INTERVAL;
42  lcsr->timer_cnt_1 = 0;              /* clear counter */
43  lcsr->board_ctl |= 7;               /* increment, reset-on-compare, */
44                                      /*   and clear-overflow-cnt */
45
46  lcsr->intr_level[0] |= TIMER_INT_LEVEL; /* set int level */
47  lcsr->intr_ena |= 0x01000000;           /* enable tick timer 1 interrupt */
48}
49
50#define AVG_OVERHEAD      3U    /* It typically takes 3.0 microseconds */
51                                /* (3 countdowns) to start/stop the timer. */
52#define LEAST_VALID       10U   /* Don't trust a value lower than this */
53
54int benchmark_timer_read(void)
55{
56  uint32_t            total;
57
58  total = (Ttimer_val * TICK_INTERVAL) + lcsr->timer_cnt_1;
59
60  if ( benchmark_timer_find_average_overhead == true )
61    return total;          /* in one-half microsecond units */
62
63  if ( total < LEAST_VALID )
64    return 0;            /* below timer resolution */
65
66  return (total-AVG_OVERHEAD) >> 1;
67}
68
69void benchmark_timer_disable_subtracting_average_overhead(
70  bool find_flag
71)
72{
73  benchmark_timer_find_average_overhead = find_flag;
74}
Note: See TracBrowser for help on using the repository browser.