summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/edb7312/timer
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-11-13 17:55:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-11-13 17:55:09 +0000
commit3d6669ccf7960af91b93d5b8781b78160547c0d1 (patch)
tree80667b374c0bcd965f95072ee63cbe5902d98509 /c/src/lib/libbsp/arm/edb7312/timer
parent2002-11-13 Jay Monkman <jtm@smoothsmoothie.com> (diff)
downloadrtems-3d6669ccf7960af91b93d5b8781b78160547c0d1.tar.bz2
2002-11-13 Jay Monkman <jtm@smoothsmoothie.com>
* New BSP. * .cvsignore, ChangeLog, Makefile.am, bsp_specs, configure.ac, README, times, clock/.cvsignore, clock/Makefile.am, clock/clockdrv.c, console/.cvsignore, console/Makefile.am, console/uart.c, include/.cvsignore, include/Makefile.am, include/bsp.h, include/ep7312.h, irq/.cvsignore, irq/Makefile.am, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, network/Makefile.am, network/network.c, start/.cvsignore, start/Makefile.am, start/start.S, startup/.cvsignore, startup/Makefile.am, startup/bspstart.c, startup/exit.c, startup/linkcmds, timer/.cvsignore, timer/Makefile.am, timer/timer.c, wrapup/.cvsignore, wrapup/Makefile.am: New file.
Diffstat (limited to 'c/src/lib/libbsp/arm/edb7312/timer')
-rw-r--r--c/src/lib/libbsp/arm/edb7312/timer/.cvsignore14
-rw-r--r--c/src/lib/libbsp/arm/edb7312/timer/Makefile.am33
-rw-r--r--c/src/lib/libbsp/arm/edb7312/timer/timer.c93
3 files changed, 140 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/edb7312/timer/.cvsignore b/c/src/lib/libbsp/arm/edb7312/timer/.cvsignore
new file mode 100644
index 0000000000..d29e5050f5
--- /dev/null
+++ b/c/src/lib/libbsp/arm/edb7312/timer/.cvsignore
@@ -0,0 +1,14 @@
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+config.cache
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+missing
+mkinstalldirs
diff --git a/c/src/lib/libbsp/arm/edb7312/timer/Makefile.am b/c/src/lib/libbsp/arm/edb7312/timer/Makefile.am
new file mode 100644
index 0000000000..56ac482989
--- /dev/null
+++ b/c/src/lib/libbsp/arm/edb7312/timer/Makefile.am
@@ -0,0 +1,33 @@
+##
+## $Id$
+##
+
+VPATH = @srcdir@:@srcdir@/../../../shared
+
+PGM = $(ARCH)/timer.rel
+
+C_FILES = timer.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
+
+OBJS = $(C_O_FILES)
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+all-local: $(ARCH) $(OBJS) $(PGM)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = timer.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/arm/edb7312/timer/timer.c b/c/src/lib/libbsp/arm/edb7312/timer/timer.c
new file mode 100644
index 0000000000..954a35f86c
--- /dev/null
+++ b/c/src/lib/libbsp/arm/edb7312/timer/timer.c
@@ -0,0 +1,93 @@
+/*
+ * Cirrus EP7312 Timer driver
+ *
+ * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ *
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * Notes:
+ * This file manages the benchmark timer used by the RTEMS Timing Test
+ * Suite. Each measured time period is demarcated by calls to
+ * Timer_initialize() and Read_timer(). Read_timer() usually returns
+ * the number of microseconds since Timer_initialize() exitted.
+ *
+ * It is important that the timer start/stop overhead be determined
+ * when porting or modifying this code.
+ *
+ * $Id$
+*/
+
+#include <rtems.h>
+#include <bsp.h>
+#include <ep7312.h>
+
+rtems_unsigned16 tstart;
+rtems_boolean Timer_driver_Find_average_overhead;
+
+void Timer_initialize( void )
+{
+ *EP7312_SYSCON1 |= EP7312_SYSCON1_TC2_512KHZ;
+ *EP7312_TC2D = 0xffff;
+}
+
+/*
+ * The following controls the behavior of Read_timer().
+ *
+ * AVG_OVEREHAD is the overhead for starting and stopping the timer. It
+ * is usually deducted from the number returned.
+ *
+ * LEAST_VALID is the lowest number this routine should trust. Numbers
+ * below this are "noise" and zero is returned.
+ */
+
+#define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */
+ /* (Y countdowns) to start/stop the timer. */
+ /* This value is in microseconds. */
+#define LEAST_VALID 1 /* Don't trust a clicks value lower than this */
+
+int Read_timer( void )
+{
+ rtems_unsigned16 t;
+ rtems_unsigned32 total;
+ t = *EP7312_TC2D;
+
+ /*
+ * Total is calculated by taking into account the number of timer overflow
+ * interrupts since the timer was initialized and clicks since the last
+ * interrupts.
+ */
+
+ total = (unsigned32)0x0000ffff - t; /* result is 1/512000 = ~2 uS */
+ total = (total * 1953) / 1000; /* convert to uS */
+ if ( Timer_driver_Find_average_overhead == 1 )
+ return total; /* in XXX microsecond units */
+ else {
+ if ( total < LEAST_VALID )
+ return 0; /* below timer resolution */
+ /*
+ * Somehow convert total into microseconds
+ */
+ return (total - AVG_OVERHEAD);
+ }
+}
+
+/*
+ * Empty function call used in loops to measure basic cost of looping
+ * in Timing Test Suite.
+ */
+
+rtems_status_code Empty_function( void )
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+void Set_find_average_overhead(
+ rtems_boolean find_flag
+)
+{
+ Timer_driver_Find_average_overhead = find_flag;
+}
+