source: rtems/c/src/lib/libcpu/arm/lpc22xx/timer/timer.c @ 359e537

4.104.115
Last change on this file since 359e537 was 359e537, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 05:09:41

Whitespace removal.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * RTL22xx board Timer driver
3 *
4 * This uses Timer1 for timing measurments.
5 *
6 *  By Ray xu<rayx.cn@gmail.com>, modify form Mc9328mxl RTEMS DSP
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 * Notes:
14 *  This file manages the benchmark timer used by the RTEMS Timing Test
15 *  Suite.  Each measured time period is demarcated by calls to
16 *  benchmark_timer_initialize() and benchmark_timer_read().  benchmark_timer_read() usually returns
17 *  the number of microseconds since benchmark_timer_initialize() exitted.
18 *
19 *  It is important that the timer start/stop overhead be determined
20 *  when porting or modifying this code.
21 *
22 *  $Id$
23*/
24
25#include <rtems.h>
26#include <bsp.h>
27#include <lpc22xx.h>
28#include "lpc_timer.h"
29uint32_t g_start;
30uint32_t g_freq;
31
32bool benchmark_timer_find_average_overhead;
33
34
35/*
36 * Set up Timer 1
37 */
38void benchmark_timer_initialize( void )
39{
40       g_freq = LPC22xx_Fpclk / 1000;
41}
42
43/*
44 *  The following controls the behavior of benchmark_timer_read().
45 *
46 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
47 *  is usually deducted from the number returned.
48 *
49 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
50 *  below this are "noise" and zero is returned.
51 */
52
53#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
54                             /* (Y countdowns) to start/stop the timer. */
55                             /* This value is in microseconds. */
56#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
57
58int benchmark_timer_read( void )
59{
60  return (T0TC/(LPC22xx_Fpclk/1000000));
61  /*
62   *  Total is calculated by taking into account the number of timer overflow
63   *  interrupts since the timer was initialized and clicks since the last
64   *  interrupts.
65   */
66}
67
68void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
69{
70  benchmark_timer_find_average_overhead = find_flag;
71}
72
Note: See TracBrowser for help on using the repository browser.