OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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 PCC timer on the MVME147 board.
4
 *
5
 *  Input parameters:  NONE
6
 *
7
 *  Output parameters:  NONE
8
 *
9
 *  NOTE: It is important that the timer start/stop overhead be
10
 *        determined when porting or modifying this code.
11
 *
12
 *  COPYRIGHT (c) 1989-1999.
13
 *  On-Line Applications Research Corporation (OAR).
14
 *
15
 *  The license and distribution terms for this file may be
16
 *  found in the file LICENSE in this distribution or at
17
 *  http://www.OARcorp.com/rtems/license.html.
18
 *
19
 *  MVME147 port for TNI - Telecom Bretagne
20
 *  by Dominique LE CAMPION (Dominique.LECAMPION@enst-bretagne.fr)
21
 *  May 1996
22
 *
23
 *  $Id: timer.c,v 1.2 2001-09-27 12:00:16 chris Exp $
24
 */
25
 
26
#include <bsp.h>
27
 
28
#define TIMER_INT_LEVEL 6
29
 
30
#define COUNTDOWN_VALUE 0
31
/* Allows 0.4096 second delay betwin ints */
32
/* Each tick is 6.25 us */
33
 
34
int Ttimer_val;
35
rtems_boolean Timer_driver_Find_average_overhead;
36
 
37
rtems_isr timerisr();
38
 
39
void Timer_initialize()
40
{
41
  (void) set_vector(timerisr, TIMER_1_VECTOR, 0); /* install ISR */
42
 
43
  Ttimer_val = 0;                 /* clear timer ISR count */
44
  pcc->timer1_int_control = 0x00; /* Disable T1 Interr. */
45
  pcc->timer1_preload = COUNTDOWN_VALUE;
46
  /* write countdown preload value */
47
  pcc->timer1_control = 0x00; /* load preload value */
48
  pcc->timer1_control = 0x07; /* clear T1 overflow counter, enable counter */
49
  pcc->timer1_int_control = TIMER_INT_LEVEL|0x08;
50
  /* Enable Timer 1 and set its int. level */
51
 
52
}
53
 
54
#define AVG_OVERHEAD      0  /* No need to start/stop the timer to read
55
                                its value on the MVME147 PCC: reads are not
56
                                synchronized whith the counter updates*/
57
#define LEAST_VALID       10 /* Don't trust a value lower than this */
58
 
59
int Read_timer()
60
{
61
  rtems_unsigned32 total;
62
  rtems_unsigned16 counter_value;
63
 
64
  counter_value = pcc->timer1_count; /* read the counter value */
65
 
66
  total = ((Ttimer_val * 0x10000) + counter_value); /* in 6.25 us units */
67
  /* DC note : just look at the assembly generated
68
     to see gcc's impressive optimization ! */
69
  return total;
70
 
71
}
72
 
73
rtems_status_code Empty_function( void )
74
{
75
  return RTEMS_SUCCESSFUL;
76
}
77
 
78
void Set_find_average_overhead(
79
  rtems_boolean find_flag
80
)
81
{
82
  Timer_driver_Find_average_overhead = find_flag;
83
}

powered by: WebSVN 2.1.0

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