OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [mvme162/] [timer/] [timer.c] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Timer_init()
2
 *
3
 *  This routine initializes the Tick Timer 1 on the MVME162 board.
4
 *
5
 *  Input parameters:  NONE
6
 *
7
 *  Output parameters:  NONE
8
 *
9
 *  NOTE: This routine will not work if the optimizer is enabled
10
 *        for some compilers.  The multiple writes
11
 *        may be optimized away.
12
 *
13
 *        It is important that the timer start/stop overhead be
14
 *        determined when porting or modifying this code.
15
 *
16
 *  COPYRIGHT (c) 1989-1999.
17
 *  On-Line Applications Research Corporation (OAR).
18
 *
19
 *  The license and distribution terms for this file may be
20
 *  found in the file LICENSE in this distribution or at
21
 *  http://www.OARcorp.com/rtems/license.html.
22
 *
23
 *  Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
24
 *  EISCAT Scientific Association. M.Savitski
25
 *
26
 *  This material is a part of the MVME162 Board Support Package
27
 *  for the RTEMS executive. Its licensing policies are those of the
28
 *  RTEMS above.
29
 *
30
 *  $Id: timer.c,v 1.2 2001-09-27 12:00:18 chris Exp $
31
 */
32
 
33
#include <rtems.h>
34
#include <bsp.h>
35
 
36
/* Periodic tick interval */
37
#define TICK_INTERVAL         0x10000U
38
#define TIMER_INT_LEVEL       6
39
 
40
rtems_unsigned32    Ttimer_val;
41
rtems_boolean       Timer_driver_Find_average_overhead;
42
 
43
rtems_isr timerisr();
44
 
45
void Timer_initialize()
46
{
47
  (void) set_vector( timerisr, VBR0 * 0x10 + 0x8, 0 );
48
 
49
  Ttimer_val = 0;                     /* clear timer ISR count */
50
  lcsr->vector_base |= MASK_INT;      /* unmask VMEchip2 interrupts */
51
  lcsr->intr_clear |= 0x01000000;     /* clear pending interrupt */
52
  lcsr->to_ctl = 0xE7;                /* prescaler to 1 MHz (see Appendix A1) */
53
  lcsr->timer_cmp_1 = TICK_INTERVAL;
54
  lcsr->timer_cnt_1 = 0;              /* clear counter */
55
  lcsr->board_ctl |= 7;               /* increment, reset-on-compare, */
56
                                      /*   and clear-overflow-cnt */
57
 
58
  lcsr->intr_level[0] |= TIMER_INT_LEVEL; /* set int level */
59
  lcsr->intr_ena |= 0x01000000;           /* enable tick timer 1 interrupt */
60
}
61
 
62
#define AVG_OVERHEAD      3U    /* It typically takes 3.0 microseconds */
63
                                /* (3 countdowns) to start/stop the timer. */
64
#define LEAST_VALID       10U   /* Don't trust a value lower than this */
65
 
66
int Read_timer()
67
{
68
  rtems_unsigned32    total;
69
 
70
  total = (Ttimer_val * TICK_INTERVAL) + lcsr->timer_cnt_1;
71
 
72
  if ( Timer_driver_Find_average_overhead == 1 )
73
    return total;          /* in one-half microsecond units */
74
 
75
  if ( total < LEAST_VALID )
76
    return 0;            /* below timer resolution */
77
 
78
  return (total-AVG_OVERHEAD) >> 1;
79
}
80
 
81
 
82
rtems_status_code Empty_function( void )
83
{
84
  return RTEMS_SUCCESSFUL;
85
}
86
 
87
void Set_find_average_overhead(
88
  rtems_boolean find_flag
89
)
90
{
91
  Timer_driver_Find_average_overhead = find_flag;
92
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.