source: rtems/c/src/lib/libcpu/arm/pxa255/timer/timer.c @ d7a915da

4.104.115
Last change on this file since d7a915da was d7a915da, checked in by Joel Sherrill <joel.sherrill@…>, on 06/04/09 at 16:33:31

2009-06-04 Xi Yang <hiyangxi@…>

  • Makefile.am, configure.ac, preinstall.am: New Gumstix BSP and PXA255 support.
  • pxa255/clock/clock.c, pxa255/ffuart/ffuart.c, pxa255/include/bits.h, pxa255/include/ffuart.h, pxa255/include/pxa255.h, pxa255/irq/bsp_irq_asm.S, pxa255/irq/bsp_irq_init.c, pxa255/irq/irq.c, pxa255/irq/irq.h, pxa255/pmc/pmc.c, pxa255/timer/timer.c: New files.
  • Property mode set to 100755
File size: 2.3 KB
Line 
1/*
2 *PXA255 timer by Yang Xi <hiyangxi@gmail.com>
3 * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
4 *
5 * Notes:
6 *  This file manages the benchmark timer used by the RTEMS Timing Test
7 *  Suite.  Each measured time period is demarcated by calls to
8 *  Timer_initialize() and Read_timer().  Read_timer() usually returns
9 *  the number of microseconds since Timer_initialize() exitted.
10 *
11 *  It is important that the timer start/stop overhead be determined
12 *  when porting or modifying this code.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20 *  $Id$
21 */
22
23#include <rtems.h>
24#include <bsp.h>
25#include <pxa255.h>
26
27uint32_t tstart;
28bool Timer_driver_Find_average_overhead;
29static uint32_t tick_time;
30/*
31 * Use the timer count register to measure.
32 * The frequency of it is 3.4864MHZ
33 *The longest period we are able to capture is 4G/3.4864MHZ
34 *   
35 *   
36 */
37void Timer_initialize( void )
38{
39
40  tick_time = XSCALE_OS_TIMER_TCR;
41
42}
43
44/*
45 *  The following controls the behavior of Read_timer().
46 *
47 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
48 *  is usually deducted from the number returned.
49 *
50 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
51 *  below this are "noise" and zero is returned.
52 */
53
54#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
55                             /* (Y countdowns) to start/stop the timer. */
56                             /* This value is in microseconds. */
57#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
58
59int Read_timer( void )
60{
61
62  uint32_t total;
63  total = XSCALE_OS_TIMER_TCR;
64  if(total>=tick_time)
65    total -= tick_time;
66  else
67    total += 0xffffffff-tick_time; /*Round up but not overflow*/
68     
69  if ( Timer_driver_Find_average_overhead == 1 )
70    return total;          /*Counter cycles*/
71  else {
72    if ( total < LEAST_VALID )
73      return 0;            /* below timer resolution */
74    return total;
75  }
76
77}
78
79/*
80 *  Empty function call used in loops to measure basic cost of looping
81 *  in Timing Test Suite.
82 */
83
84rtems_status_code Empty_function( void )
85{
86  return RTEMS_SUCCESSFUL;
87}
88
89void Set_find_average_overhead(
90  bool find_flag
91)
92{
93  Timer_driver_Find_average_overhead = find_flag;
94}
95
Note: See TracBrowser for help on using the repository browser.