1 | /*===============================================================*\ |
---|
2 | | Project: RTEMS generic mcf548x BSP | |
---|
3 | +-----------------------------------------------------------------+ |
---|
4 | | File: timer.c | |
---|
5 | +-----------------------------------------------------------------+ |
---|
6 | | The file contains the diagnostic timer code of generic MCF548x | |
---|
7 | | BSP. | |
---|
8 | +-----------------------------------------------------------------+ |
---|
9 | | Copyright (c) 2007 | |
---|
10 | | Embedded Brains GmbH | |
---|
11 | | Obere Lagerstr. 30 | |
---|
12 | | D-82178 Puchheim | |
---|
13 | | Germany | |
---|
14 | | rtems@embedded-brains.de | |
---|
15 | +-----------------------------------------------------------------+ |
---|
16 | | | |
---|
17 | | Parts of the code has been derived from the "dBUG source code" | |
---|
18 | | package Freescale is providing for M548X EVBs. The usage of | |
---|
19 | | the modified or unmodified code and it's integration into the | |
---|
20 | | generic mcf548x BSP has been done according to the Freescale | |
---|
21 | | license terms. | |
---|
22 | | | |
---|
23 | | The Freescale license terms can be reviewed in the file | |
---|
24 | | | |
---|
25 | | Freescale_license.txt | |
---|
26 | | | |
---|
27 | +-----------------------------------------------------------------+ |
---|
28 | | | |
---|
29 | | The generic mcf548x BSP has been developed on the basic | |
---|
30 | | structures and modules of the av5282 BSP. | |
---|
31 | | | |
---|
32 | +-----------------------------------------------------------------+ |
---|
33 | | | |
---|
34 | | The license and distribution terms for this file may be | |
---|
35 | | found in the file LICENSE in this distribution or at | |
---|
36 | | | |
---|
37 | | http://www.rtems.com/license/LICENSE. | |
---|
38 | | | |
---|
39 | +-----------------------------------------------------------------+ |
---|
40 | | | |
---|
41 | | date history ID | |
---|
42 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
---|
43 | | 12.11.07 1.0 ras | |
---|
44 | | | |
---|
45 | \*===============================================================*/ |
---|
46 | |
---|
47 | /* |
---|
48 | * Timer Init |
---|
49 | * |
---|
50 | * Use the second slice timer (SLT1) as the diagnostic timer. |
---|
51 | */ |
---|
52 | |
---|
53 | #include <rtems.h> |
---|
54 | #include <rtems/btimer.h> |
---|
55 | #include <bsp.h> |
---|
56 | #include <mcf548x/mcf548x.h> |
---|
57 | |
---|
58 | bool benchmark_timer_find_average_overhead; |
---|
59 | static uint32_t microsecond_timer_value = 0; |
---|
60 | |
---|
61 | void benchmark_timer_initialize(void) |
---|
62 | { |
---|
63 | MCF548X_SLT_SLTCNT1 = 0xFFFFFFFF; |
---|
64 | MCF548X_SLT_SCR1 |= (MCF548X_SLT_SCR_TEN | MCF548X_SLT_SCR_RUN); |
---|
65 | } |
---|
66 | |
---|
67 | /* |
---|
68 | * Return timer value in microsecond units |
---|
69 | * XLB clock 100 MHz / 1us is equal to 100 counts |
---|
70 | */ |
---|
71 | uint32_t |
---|
72 | benchmark_timer_read(void) |
---|
73 | { |
---|
74 | microsecond_timer_value = (0xFFFFFFFF - MCF548X_SLT_SCNT1)/100; |
---|
75 | |
---|
76 | return microsecond_timer_value; |
---|
77 | } |
---|
78 | |
---|
79 | void |
---|
80 | benchmark_timer_disable_subtracting_average_overhead(bool find_flag) |
---|
81 | { |
---|
82 | benchmark_timer_find_average_overhead = find_flag; |
---|
83 | } |
---|