source: rtems/c/src/lib/libbsp/m68k/mvme147/timer/timer.c @ 26c17377

4.115
Last change on this file since 26c17377 was 26c17377, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/09/11 at 12:15:54

2011-02-09 Ralf Corsépius <ralf.corsepius@…>

  • timer/timer.c: Include <rtems/btimer.h>. Fix benchmark_timer_read() definition.
  • Property mode set to 100644
File size: 1.9 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.com/license/LICENSE.
8 *
9 *  MVME147 port for TNI - Telecom Bretagne
10 *  by Dominique LE CAMPION (Dominique.LECAMPION@enst-bretagne.fr)
11 *  May 1996
12 *
13 *  $Id$
14 */
15
16#include <rtems/btimer.h>
17#include <bsp.h>
18
19#define TIMER_INT_LEVEL 6
20
21#define COUNTDOWN_VALUE 0
22/* Allows 0.4096 second delay betwin ints */
23/* Each tick is 6.25 us */
24
25int Ttimer_val;
26bool benchmark_timer_find_average_overhead;
27
28rtems_isr_entry timerisr(rtems_vector_number);
29
30void benchmark_timer_initialize(void)
31{
32  (void) set_vector(timerisr, TIMER_1_VECTOR, 0); /* install ISR */
33
34  Ttimer_val = 0;                 /* clear timer ISR count */
35  pcc->timer1_int_control = 0x00; /* Disable T1 Interr. */
36  pcc->timer1_preload = COUNTDOWN_VALUE;
37  /* write countdown preload value */
38  pcc->timer1_control = 0x00; /* load preload value */
39  pcc->timer1_control = 0x07; /* clear T1 overflow counter, enable counter */
40  pcc->timer1_int_control = TIMER_INT_LEVEL|0x08;
41  /* Enable Timer 1 and set its int. level */
42
43}
44
45#define AVG_OVERHEAD      0  /* No need to start/stop the timer to read
46                                its value on the MVME147 PCC: reads are not
47                                synchronized whith the counter updates*/
48#define LEAST_VALID       10 /* Don't trust a value lower than this */
49
50uint32_t benchmark_timer_read(void)
51{
52  uint32_t         total;
53  uint16_t         counter_value;
54
55  counter_value = pcc->timer1_count; /* read the counter value */
56
57  total = ((Ttimer_val * 0x10000) + counter_value); /* in 6.25 us units */
58  /* DC note : just look at the assembly generated
59     to see gcc's impressive optimization ! */
60  return total;
61
62}
63
64void benchmark_timer_disable_subtracting_average_overhead(
65  bool find_flag
66)
67{
68  benchmark_timer_find_average_overhead = find_flag;
69}
Note: See TracBrowser for help on using the repository browser.