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 | * MVME147 port for TNI - Telecom Bretagne |
---|
10 | * by Dominique LE CAMPION (Dominique.LECAMPION@enst-bretagne.fr) |
---|
11 | * May 1996 |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems/btimer.h> |
---|
15 | #include <bsp.h> |
---|
16 | |
---|
17 | #define TIMER_INT_LEVEL 6 |
---|
18 | |
---|
19 | #define COUNTDOWN_VALUE 0 |
---|
20 | /* Allows 0.4096 second delay betwin ints */ |
---|
21 | /* Each tick is 6.25 us */ |
---|
22 | |
---|
23 | int Ttimer_val; |
---|
24 | bool benchmark_timer_find_average_overhead; |
---|
25 | |
---|
26 | rtems_isr_entry timerisr(rtems_vector_number); |
---|
27 | |
---|
28 | void benchmark_timer_initialize(void) |
---|
29 | { |
---|
30 | (void) set_vector(timerisr, TIMER_1_VECTOR, 0); /* install ISR */ |
---|
31 | |
---|
32 | Ttimer_val = 0; /* clear timer ISR count */ |
---|
33 | pcc->timer1_int_control = 0x00; /* Disable T1 Interr. */ |
---|
34 | pcc->timer1_preload = COUNTDOWN_VALUE; |
---|
35 | /* write countdown preload value */ |
---|
36 | pcc->timer1_control = 0x00; /* load preload value */ |
---|
37 | pcc->timer1_control = 0x07; /* clear T1 overflow counter, enable counter */ |
---|
38 | pcc->timer1_int_control = TIMER_INT_LEVEL|0x08; |
---|
39 | /* Enable Timer 1 and set its int. level */ |
---|
40 | |
---|
41 | } |
---|
42 | |
---|
43 | #define AVG_OVERHEAD 0 /* No need to start/stop the timer to read |
---|
44 | its value on the MVME147 PCC: reads are not |
---|
45 | synchronized whith the counter updates*/ |
---|
46 | #define LEAST_VALID 10 /* Don't trust a value lower than this */ |
---|
47 | |
---|
48 | uint32_t benchmark_timer_read(void) |
---|
49 | { |
---|
50 | uint32_t total; |
---|
51 | uint16_t counter_value; |
---|
52 | |
---|
53 | counter_value = pcc->timer1_count; /* read the counter value */ |
---|
54 | |
---|
55 | total = ((Ttimer_val * 0x10000) + counter_value); /* in 6.25 us units */ |
---|
56 | /* DC note : just look at the assembly generated |
---|
57 | to see gcc's impressive optimization ! */ |
---|
58 | return total; |
---|
59 | |
---|
60 | } |
---|
61 | |
---|
62 | void benchmark_timer_disable_subtracting_average_overhead( |
---|
63 | bool find_flag |
---|
64 | ) |
---|
65 | { |
---|
66 | benchmark_timer_find_average_overhead = find_flag; |
---|
67 | } |
---|