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

4.104.114.84.95
Last change on this file since f52111f was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*  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$
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
34int Ttimer_val;
35rtems_boolean Timer_driver_Find_average_overhead;
36
37rtems_isr timerisr();
38
39void 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
59int 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
73rtems_status_code Empty_function( void )
74{
75  return RTEMS_SUCCESSFUL;
76}
77
78void Set_find_average_overhead(
79  rtems_boolean find_flag
80)
81{
82  Timer_driver_Find_average_overhead = find_flag;
83}
Note: See TracBrowser for help on using the repository browser.