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

4.115
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

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.8 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 <rtems/btimer.h>
11#include <bsp.h>
12#include <rtems/zilog/z8036.h>
13
14#define TIMER 0xfffb0000   /* address of Z8036 on MVME136 */
15
16int Ttimer_val;
17bool benchmark_timer_find_average_overhead;
18
19rtems_isr timerisr(void);
20
21void benchmark_timer_initialize(void)
22{
23  (void) set_vector( timerisr, 66, 0 );       /* install ISR */
24
25  Ttimer_val = 0;                             /* clear timer ISR count */
26  Z8x36_WRITE( TIMER, MASTER_INTR, 0x01 ); /* reset */
27  Z8x36_WRITE( TIMER, MASTER_INTR, 0x00 ); /* clear reset */
28  Z8x36_WRITE( TIMER, MASTER_INTR, 0xe2 ); /* disable lower chain, no vec */
29                                           /*  set right justified addr */
30                                              /*  and master int enable */
31  Z8x36_WRITE( TIMER, CT1_MODE_SPEC,  0x80 ); /* T1 continuous, and   */
32                                              /* cycle/pulse output   */
33
34  *((uint16_t*)0xfffb0016) = 0x0000; /* write countdown value */
35/*
36  Z8x36_WRITE( TIMER, CT1_TIME_CONST_MSB, 0x00 );
37  Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0x00 );
38*/
39  Z8x36_WRITE( TIMER, MASTER_CFG,         0xc4 ); /* enable timer1        */
40
41  Z8x36_WRITE( TIMER, CT1_CMD_STATUS,     0xc6 ); /* set INTR enable (IE), */
42                                                 /*  trigger command      */
43                                                 /*  (TCB) and gate       */
44                                                 /* command (GCB) bits    */
45  *((uint8_t*)0xfffb0038) &= 0xfd;      /* enable timer INTR on  */
46                                                 /*    VME controller     */
47}
48
49#define AVG_OVERHEAD      6  /* It typically takes 3.0 microseconds */
50                             /* (6 countdowns) to start/stop the timer. */
51#define LEAST_VALID       10 /* Don't trust a value lower than this */
52
53benchmark_timer_t benchmark_timer_read(void)
54{
55/*
56  uint8_t          msb, lsb;
57*/
58  uint32_t         remaining, total;
59
60  Z8x36_WRITE( TIMER, CT1_CMD_STATUS,  0xce ); /* read the counter value */
61remaining = 0xffff - *((uint16_t*) 0xfffb0010);
62/*
63  Z8x36_READ(  TIMER, CT1_CUR_CNT_MSB, msb );
64  Z8x36_READ(  TIMER, CT1_CUR_CNT_LSB, lsb );
65
66  remaining = 0xffff - ((msb << 8) + lsb);
67*/
68  total = (Ttimer_val * 0x10000) + remaining;
69
70  if ( benchmark_timer_find_average_overhead == true )
71    return total;          /* in one-half microsecond units */
72
73  else {
74    if ( total < LEAST_VALID )
75      return 0;            /* below timer resolution */
76    return (total-AVG_OVERHEAD) >> 1;
77  }
78}
79
80void benchmark_timer_disable_subtracting_average_overhead(
81  bool find_flag
82)
83{
84  benchmark_timer_find_average_overhead = find_flag;
85}
Note: See TracBrowser for help on using the repository browser.