source: rtems/c/src/lib/libbsp/powerpc/tqm8xx/timer/timer.c @ 8fbe2e6

4.115
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[63de714c]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|                                                                 |
[c499856]18| http://www.rtems.org/license/LICENSE.                           |
[63de714c]19|                                                                 |
20+-----------------------------------------------------------------+
21| this file contains the console driver                           |
22\*===============================================================*/
23/*
[290da88f]24 * benchmark_timer_initialize()
[63de714c]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
32/*
33 *
34 *  Input parameters:  NONE
35 *
36 *  Output parameters:  NONE
37 *
38 *  NOTE: It is important that the timer start/stop overhead be
39 *        determined when porting or modifying this code.
40 *
41 *  COPYRIGHT (c) 1989-1999.
42 *  On-Line Applications Research Corporation (OAR).
43 *
44 *  The license and distribution terms for this file may be
45 *  found in the file LICENSE in this distribution or at
[c499856]46 *  http://www.rtems.org/license/LICENSE.
[63de714c]47 */
48
49#include <rtems.h>
50#include <bsp.h>
[d085040]51#include <rtems/btimer.h>
[63de714c]52#include <mpc8xx.h>
53
[290da88f]54bool benchmark_timer_find_average_overhead;
55
[63de714c]56void
[290da88f]57benchmark_timer_initialize (void)
[63de714c]58{
59        /*
60         * Reset timers 1 and 2
61         */
62        m8xx.tgcr &= ~0x00FF;
63        m8xx.tcn1 = 0;
64        m8xx.tcn2 = 0;
65        m8xx.ter1 = 0xFFFF;
66        m8xx.ter2 = 0xFFFF;
67
68        /*
69         * Cascade timers 1 and 2
70         */
71        m8xx.tgcr |= M8xx_TGCR_CAS2;
72
73        /*
74         * Configure timers 1 and 2 to a single 32-bit, BUS_clock timer.
75         */
76        m8xx.tmr2 = (0 << 8) | 0x2;
77        m8xx.tmr1 = 0;
78
79        /*
80         * Start the timers
81         */
82        m8xx.tgcr |=  0x0011;
83}
84
85/*
86 * Return timer value in microsecond units
87 */
[8fbe2e6]88benchmark_timer_t benchmark_timer_read(void)
[63de714c]89{
[d085040]90  uint32_t retval;
[63de714c]91  retval = *(uint32_t*)&m8xx.tcn1;
92  retval = retval * 1000000LL / BSP_bus_frequency;
93  return retval;
94}
95
[290da88f]96void benchmark_timer_disable_subtracting_average_overhead(
97  bool find_flag
98)
[63de714c]99{
[290da88f]100  benchmark_timer_find_average_overhead = find_flag;
[63de714c]101}
Note: See TracBrowser for help on using the repository browser.