source: rtems/c/src/lib/libbsp/powerpc/tqm8xx/timer/timer.c @ 3c12a247

4.104.114.95
Last change on this file since 3c12a247 was 3c12a247, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 09/08/08 at 15:44:26

added missing files, fixed some minors

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*===============================================================*\
2| Project: RTEMS TQM8xx BSP                                       |
3+-----------------------------------------------------------------+
4| This file has been adapted to MPC8xx by                         |
5|    Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>         |
6|                    Copyright (c) 2008                           |
7|                    Embedded Brains GmbH                         |
8|                    Obere Lagerstr. 30                           |
9|                    D-82178 Puchheim                             |
10|                    Germany                                      |
11|                    rtems@embedded-brains.de                     |
12|                                                                 |
13| See the other copyright notice below for the original parts.    |
14+-----------------------------------------------------------------+
15| The license and distribution terms for this file may be         |
16| found in the file LICENSE in this distribution or at            |
17|                                                                 |
18| http://www.rtems.com/license/LICENSE.                           |
19|                                                                 |
20+-----------------------------------------------------------------+
21| this file contains the console driver                           |
22\*===============================================================*/
23/*
24 * Timer_init()
25 *
26 * Use TIMER 1 and TIMER 2 for Timing Test Suite
27 *
28 * this is derived from "timer.c" available in the m68k/gen68360 BSP
29 * adapted by Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
30 *
31 *  $Id$
32 */
33
34/*
35 *
36 *  Input parameters:  NONE
37 *
38 *  Output parameters:  NONE
39 *
40 *  NOTE: It is important that the timer start/stop overhead be
41 *        determined when porting or modifying this code.
42 *
43 *  COPYRIGHT (c) 1989-1999.
44 *  On-Line Applications Research Corporation (OAR).
45 *
46 *  The license and distribution terms for this file may be
47 *  found in the file LICENSE in this distribution or at
48 *  http://www.rtems.com/license/LICENSE.
49 */
50
51#include <rtems.h>
52#include <bsp.h>
53#include <mpc8xx.h>
54
55void
56Timer_initialize (void)
57{
58        /*
59         * Reset timers 1 and 2
60         */
61        m8xx.tgcr &= ~0x00FF;
62        m8xx.tcn1 = 0;
63        m8xx.tcn2 = 0;
64        m8xx.ter1 = 0xFFFF;
65        m8xx.ter2 = 0xFFFF;
66
67        /*
68         * Cascade timers 1 and 2
69         */
70        m8xx.tgcr |= M8xx_TGCR_CAS2;
71
72        /*
73         * Configure timers 1 and 2 to a single 32-bit, BUS_clock timer.
74         */
75        m8xx.tmr2 = (0 << 8) | 0x2;
76        m8xx.tmr1 = 0;
77
78        /*
79         * Start the timers
80         */
81        m8xx.tgcr |=  0x0011;
82}
83
84/*
85 * Return timer value in microsecond units
86 */
87int
88Read_timer (void)
89{
90  int retval;
91  retval = *(uint32_t*)&m8xx.tcn1;
92  retval = retval * 1000000LL / BSP_bus_frequency;
93  return retval;
94}
95
96/*
97 * Empty function call used in loops to measure basic cost of looping
98 * in Timing Test Suite.
99 */
100rtems_status_code
101Empty_function (void)
102{
103        return RTEMS_SUCCESSFUL;
104}
105
106void
107Set_find_average_overhead(bool find_flag)
108{
109}
Note: See TracBrowser for help on using the repository browser.