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