source: rtems/c/src/lib/libbsp/sparc/leon/timer/timer.c @ b21b0ab

4.104.114.84.95
Last change on this file since b21b0ab was b21b0ab, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 13, 2000 at 10:40:29 PM

2000-11-13 Jiri Gaisler <jgais@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.in, times, clock/.cvsignore, clock/Makefile.am, clock/ckinit.c, console/.cvsignore, console/Makefile.am, console/console.c, console/consolereserveresources.c, console/debugputs.c, gnatsupp/.cvsignore, gnatsupp/Makefile.am, gnatsupp/gnatsupp.c, include/.cvsignore, include/Makefile.am, include/bsp.h, include/coverhd.h, include/leon.h, start/.cvsignore, start/Makefile.am, startup/.cvsignore, startup/Makefile.am, startup/boardinit.S, startup/linkcmds, startup/setvec.c, startup/spurious.c, timer/.cvsignore, timer/Makefile.am, timer/timer.c, tools/.cvsignore, tools/Makefile.am, tools/configure.in, tools/runtest.in, wrapup/.cvsignore, wrapup/Makefile.am: New file.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*  timer.c
2 *
3 *  This file implements a benchmark timer using timer 2.
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  Ported to LEON implementation of the SPARC by On-Line Applications
14 *  Research Corporation (OAR) under contract to the European Space
15 *  Agency (ESA).
16 *
17 *  LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995.
18 *  European Space Agency.
19 *
20 *  $Id$
21 */
22
23
24#include <bsp.h>
25
26rtems_boolean Timer_driver_Find_average_overhead;
27
28rtems_boolean Timer_driver_Is_initialized = FALSE;
29
30void Timer_initialize()
31{
32  /*
33   *  Timer runs long and accurate enough not to require an interrupt.
34   */
35
36  if ( Timer_driver_Is_initialized == FALSE ) {
37
38    /* approximately 1 us per countdown */
39    LEON_REG.Timer_Counter_2 = 0xffffff;
40    LEON_REG.Timer_Reload_2 = 0xffffff;
41
42  } else {
43    Timer_driver_Is_initialized = TRUE;
44  }
45
46  LEON_REG.Timer_Control_2 = ( 
47    LEON_REG_TIMER_COUNTER_ENABLE_COUNTING | 
48      LEON_REG_TIMER_COUNTER_LOAD_COUNTER
49  );
50
51}
52
53#define AVG_OVERHEAD      3  /* It typically takes 3.0 microseconds */
54                             /*     to start/stop the timer. */
55#define LEAST_VALID       2  /* Don't trust a value lower than this */
56
57int Read_timer()
58{
59  rtems_unsigned32  total;
60
61  total = LEON_REG.Timer_Counter_2;
62
63  total = 0xffffff - total;
64
65  if ( Timer_driver_Find_average_overhead == 1 )
66    return total;          /* in one microsecond units */
67
68  if ( total < LEAST_VALID )
69    return 0;            /* below timer resolution */
70
71  return total - AVG_OVERHEAD;
72}
73
74rtems_status_code Empty_function( void )
75{
76  return RTEMS_SUCCESSFUL;
77}
78
79void Set_find_average_overhead(
80  rtems_boolean find_flag
81)
82{
83  Timer_driver_Find_average_overhead = find_flag;
84}
Note: See TracBrowser for help on using the repository browser.