summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 12:08:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:52:19 +0200
commite0dd8a5ad830798bc8082b03b8c42c32fb9660e0 (patch)
treed147bfc4d670fcdfbd2e2d2e75eb209f92e07df1 /c/src/lib/libbsp/arm
parentbsps: Move startup files to bsps (diff)
downloadrtems-e0dd8a5ad830798bc8082b03b8c42c32fb9660e0.tar.bz2
bsps: Move benchmark timer to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'c/src/lib/libbsp/arm')
-rw-r--r--c/src/lib/libbsp/arm/csb336/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/csb336/timer/timer.c93
-rw-r--r--c/src/lib/libbsp/arm/csb337/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/csb337/timer/timer.c91
-rw-r--r--c/src/lib/libbsp/arm/edb7312/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/edb7312/timer/timer.c80
-rw-r--r--c/src/lib/libbsp/arm/gumstix/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/gumstix/timer/timer.c75
-rw-r--r--c/src/lib/libbsp/arm/lpc176x/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/lpc176x/timer/timer.c407
-rw-r--r--c/src/lib/libbsp/arm/rtl22xx/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/rtl22xx/timer/lpc_timer.h48
-rw-r--r--c/src/lib/libbsp/arm/rtl22xx/timer/timer.c65
-rw-r--r--c/src/lib/libbsp/arm/smdk2410/Makefile.am2
-rw-r--r--c/src/lib/libbsp/arm/smdk2410/timer/timer.c100
15 files changed, 7 insertions, 966 deletions
diff --git a/c/src/lib/libbsp/arm/csb336/Makefile.am b/c/src/lib/libbsp/arm/csb336/Makefile.am
index 58bab61c7f..8702c2cbb6 100644
--- a/c/src/lib/libbsp/arm/csb336/Makefile.am
+++ b/c/src/lib/libbsp/arm/csb336/Makefile.am
@@ -28,7 +28,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/sbrk.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterread.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterdiff.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/csb336/clock/clockdrv.c
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/csb336/btimer/btimer.c
# console
librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/csb336/console/uart.c
# IRQ
diff --git a/c/src/lib/libbsp/arm/csb336/timer/timer.c b/c/src/lib/libbsp/arm/csb336/timer/timer.c
deleted file mode 100644
index 66ff4a0bf4..0000000000
--- a/c/src/lib/libbsp/arm/csb336/timer/timer.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * @file
- * @brief Cogent CSB336 Timer driver
- *
- * This uses timer 2 for timing measurments.
- */
-
-/*
- * Copyright (c) 2004 Cogent Computer Systems
- * Written by Jay Monkman <jtm@lopingdog.com>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <rtems.h>
-#include <bsp.h>
-#include <rtems/btimer.h>
-#include <mc9328mxl.h>
-
-uint32_t g_start;
-uint32_t g_freq;
-
-bool benchmark_timer_find_average_overhead;
-
-
-/*
- * Set up Timer 1
- */
-void benchmark_timer_initialize( void )
-{
- MC9328MXL_TMR2_TCTL = (MC9328MXL_TMR_TCTL_CLKSRC_PCLK1 |
- MC9328MXL_TMR_TCTL_FRR |
- MC9328MXL_TMR_TCTL_TEN);
- /* set prescaler to 1 (register value + 1) */ \
- MC9328MXL_TMR2_TPRER = 0;
-
- /* get freq of counter in KHz */
- g_freq = get_perclk1_freq() / 1000;
-
- g_start = MC9328MXL_TMR2_TCN;
-}
-
-/*
- * The following controls the behavior of benchmark_timer_read().
- *
- * 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 */
-
-benchmark_timer_t benchmark_timer_read( void )
-{
- uint32_t t;
- unsigned long long total;
-
- t = MC9328MXL_TMR2_TCN;
- /*
- * 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 = (t - g_start);
-
- /* convert to nanoseconds */
- total = (total * 1000)/ g_freq;
-
- if ( benchmark_timer_find_average_overhead == 1 ) {
- return (int) total;
- } else if ( total < LEAST_VALID ) {
- return 0;
- }
- /*
- * Somehow convert total into microseconds
- */
-
- return (total - AVG_OVERHEAD);
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
-
diff --git a/c/src/lib/libbsp/arm/csb337/Makefile.am b/c/src/lib/libbsp/arm/csb337/Makefile.am
index c837aef45a..2d9394965c 100644
--- a/c/src/lib/libbsp/arm/csb337/Makefile.am
+++ b/c/src/lib/libbsp/arm/csb337/Makefile.am
@@ -38,7 +38,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounter
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterdiff.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/csb337/start/pmc.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/csb337/clock/clock.c
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/csb337/btimer/btimer.c
# console
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/legacy-console.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/legacy-console-control.c
diff --git a/c/src/lib/libbsp/arm/csb337/timer/timer.c b/c/src/lib/libbsp/arm/csb337/timer/timer.c
deleted file mode 100644
index c65dd8096a..0000000000
--- a/c/src/lib/libbsp/arm/csb337/timer/timer.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * @file
- * @brief Cogent CSB337 Timer driver
- *
- * This uses timer 0 for timing measurments.
- */
-
-/*
- * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <rtems.h>
-#include <rtems/btimer.h>
-#include <at91rm9200.h>
-#include <at91rm9200_pmc.h>
-
-uint16_t tstart;
-bool benchmark_timer_find_average_overhead;
-uint32_t tick_time;
-/*
- * Set up TC0 -
- * timer_clock2 (MCK/8)
- * capture mode - this shouldn't matter
- */
-void benchmark_timer_initialize( void )
-{
- uint32_t tmr_freq;
-
- /* since we are using timer_clock2, divide mck by 8 */
- tmr_freq = at91rm9200_get_mck() / 8;
-
- TC_TC0_REG(TC_CMR) = TC_CMR_TCCLKS(1); /* timer_clock2 */
- TC_TC0_REG(TC_CCR) = (TC_CCR_CLKEN /* enable the counter */
- | TC_CCR_SWTRG); /* start it up */
-
- /* tick time in nanoseconds */
- tick_time = 1000000000/tmr_freq;
-
-}
-
-/*
- * The following controls the behavior of benchmark_timer_read().
- *
- * 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 */
-
-benchmark_timer_t benchmark_timer_read( void )
-{
- uint16_t t;
- uint32_t total;
- t = TC_TC0_REG(TC_CV);
-
- /*
- * 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 = t * tick_time;
-
- if ( benchmark_timer_find_average_overhead == 1 )
- return total; /* in nanosecond units */
- else {
- if ( total < LEAST_VALID )
- return 0; /* below timer resolution */
- /*
- * Somehow convert total into microseconds
- */
- return (total - AVG_OVERHEAD);
- }
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
-
diff --git a/c/src/lib/libbsp/arm/edb7312/Makefile.am b/c/src/lib/libbsp/arm/edb7312/Makefile.am
index ce0e11324a..eb15e50200 100644
--- a/c/src/lib/libbsp/arm/edb7312/Makefile.am
+++ b/c/src/lib/libbsp/arm/edb7312/Makefile.am
@@ -34,7 +34,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/legacy-console
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/legacy-console-select.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/edb7312/console/uart.c
# timer
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/edb7312/btimer/btimer.c
# irq
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
diff --git a/c/src/lib/libbsp/arm/edb7312/timer/timer.c b/c/src/lib/libbsp/arm/edb7312/timer/timer.c
deleted file mode 100644
index b795122ff3..0000000000
--- a/c/src/lib/libbsp/arm/edb7312/timer/timer.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.rtems.org/license/LICENSE.
- *
- * Notes:
- * This file manages the benchmark timer used by the RTEMS Timing Test
- * Suite. Each measured time period is demarcated by calls to
- * benchmark_timer_initialize() and benchmark_timer_read(). benchmark_timer_read() usually returns
- * the number of microseconds since benchmark_timer_initialize() exitted.
- *
- * It is important that the timer start/stop overhead be determined
- * when porting or modifying this code.
-*/
-
-#include <rtems.h>
-#include <bsp.h>
-#include <rtems/btimer.h>
-#include <ep7312.h>
-
-uint16_t tstart;
-bool benchmark_timer_find_average_overhead;
-
-void benchmark_timer_initialize( void )
-{
- *EP7312_SYSCON1 |= EP7312_SYSCON1_TC2_512KHZ;
- *EP7312_TC2D = 0xffff;
-}
-
-/*
- * The following controls the behavior of benchmark_timer_read().
- *
- * 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 */
-
-benchmark_timer_t benchmark_timer_read( void )
-{
- uint16_t t;
- uint32_t 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 = (uint32_t)0x0000ffff - t; /* result is 1/512000 = ~2 uS */
- total = (total * 1953) / 1000; /* convert to uS */
- if ( benchmark_timer_find_average_overhead == true )
- 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);
- }
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(
- bool find_flag
-)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
diff --git a/c/src/lib/libbsp/arm/gumstix/Makefile.am b/c/src/lib/libbsp/arm/gumstix/Makefile.am
index 4f36cded13..6eac30b7c9 100644
--- a/c/src/lib/libbsp/arm/gumstix/Makefile.am
+++ b/c/src/lib/libbsp/arm/gumstix/Makefile.am
@@ -27,7 +27,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/gumstix/start/memmap.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterread.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterdiff.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/gumstix/clock/clock.c
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/gumstix/btimer/btimer.c
#console
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/legacy-console.c
diff --git a/c/src/lib/libbsp/arm/gumstix/timer/timer.c b/c/src/lib/libbsp/arm/gumstix/timer/timer.c
deleted file mode 100644
index 7eb3d5b811..0000000000
--- a/c/src/lib/libbsp/arm/gumstix/timer/timer.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * @file
- * @brief PXA255 timer
- */
-
-/*
- * PXA255 timer by Yang Xi <hiyangxi@gmail.com>
- * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <rtems.h>
-#include <rtems/btimer.h>
-#include <pxa255.h>
-
-uint32_t tstart;
-static uint32_t tick_time;
-bool benchmark_timer_find_average_overhead;
-
-bool benchmark_timer_is_initialized = false;
-
-/*
- * Use the timer count register to measure.
- * The frequency of it is 3.4864MHZ
- * The longest period we are able to capture is 4G/3.4864MHZ
- */
-void benchmark_timer_initialize(void)
-{
- tick_time = XSCALE_OS_TIMER_TCR;
-}
-
-/*
- * 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 */
-
-benchmark_timer_t benchmark_timer_read(void)
-{
-
- uint32_t total;
- total = XSCALE_OS_TIMER_TCR;
- if(total>=tick_time)
- total -= tick_time;
- else
- total += 0xffffffff - tick_time; /*Round up but not overflow*/
-
- if ( benchmark_timer_find_average_overhead == true )
- return total; /*Counter cycles*/
-
- if ( total < LEAST_VALID )
- return 0; /* below timer resolution */
-
- return total;
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(
- bool find_flag
-)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
diff --git a/c/src/lib/libbsp/arm/lpc176x/Makefile.am b/c/src/lib/libbsp/arm/lpc176x/Makefile.am
index 6597630f80..1437b12ea3 100644
--- a/c/src/lib/libbsp/arm/lpc176x/Makefile.am
+++ b/c/src/lib/libbsp/arm/lpc176x/Makefile.am
@@ -84,7 +84,7 @@ librtemsbsp_a_SOURCES += pwmout/pwmout.c
librtemsbsp_a_SOURCES += adc/adc.c
# Timer
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/lpc176x/btimer/btimer.c
# Benchmark Timer
librtemsbsp_a_SOURCES += benchmark_timer/benchmark_timer.c
diff --git a/c/src/lib/libbsp/arm/lpc176x/timer/timer.c b/c/src/lib/libbsp/arm/lpc176x/timer/timer.c
deleted file mode 100644
index 36c720b4fb..0000000000
--- a/c/src/lib/libbsp/arm/lpc176x/timer/timer.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/**
- * @file timer.c
- *
- * @ingroup lpc176x
- *
- * @brief Timer controller for the mbed lpc1768 board.
- */
-
-/*
- * Copyright (c) 2014 Taller Technologies.
- *
- * @author Boretto Martin (martin.boretto@tallertechnologies.com)
- * @author Diaz Marcos (marcos.diaz@tallertechnologies.com)
- * @author Lenarduzzi Federico (federico.lenarduzzi@tallertechnologies.com)
- * @author Daniel Chicco (daniel.chicco@tallertechnologies.com)
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <stdio.h>
-#include <rtems/status-checks.h>
-#include <bsp.h>
-#include <bsp/irq.h>
-#include <bsp/io.h>
-#include <bsp/timer.h>
-
-/**
- * @brief Represents all the timers.
- */
-const lpc176x_timer timers[ LPC176X_TIMER_COUNT ] =
-{
- {
- .device = (lpc176x_timer_device *) LPC176X_TMR0_BASE_ADDR,
- .module = LPC176X_MODULE_TIMER_0,
- .pinselcap = LPC176X_TIMER0_CAPTURE_PORTS,
- .pinselemat = LPC176X_TIMER0_EMATCH_PORTS,
- },
- {
- .device = (lpc176x_timer_device *) LPC176X_TMR1_BASE_ADDR,
- .module = LPC176X_MODULE_TIMER_1,
- .pinselcap = LPC176X_TIMER1_CAPTURE_PORTS,
- .pinselemat = LPC176X_TIMER1_EMATCH_PORTS,
- },
- {
- .device = (lpc176x_timer_device *) LPC176X_TMR2_BASE_ADDR,
- .module = LPC176X_MODULE_TIMER_2,
- .pinselcap = LPC176X_TIMER2_CAPTURE_PORTS,
- .pinselemat = LPC176X_TIMER2_EMATCH_PORTS,
- },
- {
- .device = (lpc176x_timer_device *) LPC176X_TMR3_BASE_ADDR,
- .module = LPC176X_MODULE_TIMER_3,
- .pinselcap = LPC176X_TIMER3_CAPTURE_PORTS,
- .pinselemat = LPC176X_TIMER3_EMATCH_PORTS,
- }
-};
-
-/**
- * @brief Represents all the functions according to the timers.
- */
-lpc176x_timer_functions functions_vector[ LPC176X_TIMER_COUNT ] =
-{
- {
- .funct_vector = NULL
- },
- {
- .funct_vector = NULL
- },
- {
- .funct_vector = NULL
- },
- {
- .funct_vector = NULL
- }
-};
-
-/**
- * @brief Calls the corresponding interrupt function and pass the timer
- * as parameter.
- *
- * @param timer The specific device.
- * @param interruptnumber Interrupt number.
- */
-static inline void lpc176x_call_desired_isr(
- const lpc176x_timer_number number,
- const lpc176x_isr_function interruptfunction
-)
-{
- if ( ( *functions_vector[ number ].funct_vector )[ interruptfunction ] !=
- NULL ) {
- ( *functions_vector[ number ].funct_vector )[ interruptfunction ]( number );
- }
-
- /* else implies that the function vector points NULL. Also,
- there is nothing to do. */
-}
-
-/**
- * @brief Gets true if the selected interrupt is pending
- *
- * @param number: the number of the timer.
- * @param interrupt: the interrupt we are checking for.
- * @return TRUE if the interrupt is pending.
- */
-static inline bool lpc176x_timer_interrupt_is_pending(
- const lpc176x_timer_number tnumber,
- const lpc176x_isr_function function
-)
-{
- assert( ( tnumber < LPC176X_TIMER_COUNT )
- && ( function < LPC176X_ISR_FUNCTIONS_COUNT ) );
-
- return ( timers[ tnumber ].device->IR &
- LPC176X_TIMER_INTERRUPT_SOURCE_BIT( function ) );
-}
-
-/**
- * @brief Resets interrupt status for the selected interrupt
- *
- * @param tnumber: the number of the timer
- * @param interrupt: the interrupt we are resetting
- */
-static inline void lpc176x_timer_reset_interrupt(
- const lpc176x_timer_number tnumber,
- const lpc176x_isr_function function
-)
-{
- assert( ( tnumber < LPC176X_TIMER_COUNT )
- && ( function < LPC176X_ISR_FUNCTIONS_COUNT ) );
- timers[ tnumber ].device->IR =
- LPC176X_TIMER_INTERRUPT_SOURCE_BIT( function );
-}
-
-inline rtems_status_code lpc176x_timer_reset(
- const lpc176x_timer_number tnumber )
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- timers[ tnumber ].device->TCR = LPC176X_TIMER_RESET;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-inline rtems_status_code lpc176x_timer_set_mode(
- const lpc176x_timer_number tnumber,
- const lpc176x_timer_mode mode
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- timers[ tnumber ].device->CTCR = mode;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-inline rtems_status_code lpc176x_timer_start(
- const lpc176x_timer_number tnumber )
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- timers[ tnumber ].device->TCR = LPC176X_TIMER_START;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-inline rtems_status_code lpc176x_timer_is_started(
- const lpc176x_timer_number tnumber,
- bool *is_started
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- *is_started = ( timers[ tnumber ].device->TCR & LPC176X_TIMER_START ) ==
- LPC176X_TIMER_START;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-inline rtems_status_code lpc176x_timer_set_resolution(
- const lpc176x_timer_number tnumber,
- const lpc176x_microseconds resolution
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- timers[ tnumber ].device->PR = ( LPC176X_CCLK /
- LPC176X_TIMER_PRESCALER_DIVISOR ) *
- resolution;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-rtems_status_code lpc176x_timer_match_config(
- const lpc176x_timer_number tnumber,
- const lpc176x_match_port match_port,
- const lpc176x_match_function function,
- const uint32_t match_value
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( ( tnumber < LPC176X_TIMER_COUNT )
- && ( match_port < LPC176X_EMATCH_PORTS_COUNT )
- && ( function < LPC176X_TIMER_MATCH_FUNCTION_COUNT ) ) {
- timers[ tnumber ].device->MCR =
- LPC176X_SET_MCR( timers[ tnumber ].device->MCR,
- match_port, function );
- timers[ tnumber ].device->MR[ match_port ] = match_value;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number, or a match port or a function
- is invalid. Also, an invalid number is returned. */
-
- return status_code;
-}
-
-inline rtems_status_code lpc176x_timer_capture_config(
- const lpc176x_timer_number tnumber,
- const lpc176x_capture_port capture_port,
- const lpc176x_capture_function function
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( ( tnumber < LPC176X_TIMER_COUNT )
- && ( capture_port < LPC176X_CAPTURE_PORTS_COUNT )
- && ( function < LPC176X_TIMER_CAPTURE_FUNCTION_COUNT ) ) {
- timers[ tnumber ].device->CCR =
- LPC176X_SET_CCR( timers[ tnumber ].device->CCR,
- capture_port, function );
- lpc176x_pin_select( timers[ tnumber ].pinselcap[ capture_port ],
- LPC176X_PIN_FUNCTION_11 );
- }
-
- /* else implies that the timer number or the capture port is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-inline rtems_status_code lpc176x_timer_external_match_config(
- const lpc176x_timer_number number,
- const lpc176x_match_port match_port,
- const lpc176x_ext_match_function function
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( ( number < LPC176X_TIMER_COUNT )
- && ( match_port < LPC176X_EMATCH_PORTS_COUNT ) ) {
- timers[ number ].device->EMR =
- LPC176X_SET_EMR( timers[ number ].device->EMR,
- match_port, function );
- lpc176x_pin_select( timers[ number ].pinselemat[ match_port ],
- LPC176X_PIN_FUNCTION_11 );
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number or the match port is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-inline uint32_t lpc176x_timer_get_capvalue(
- const lpc176x_timer_number number,
- const lpc176x_capture_port capture_port
-)
-{
- assert( ( number < LPC176X_TIMER_COUNT )
- && ( capture_port < LPC176X_CAPTURE_PORTS_COUNT ) );
-
- return timers[ number ].device->CR[ capture_port ];
-}
-
-inline uint32_t lpc176x_timer_get_timer_value(
- const lpc176x_timer_number tnumber )
-{
- assert( tnumber < LPC176X_TIMER_COUNT );
-
- return timers[ tnumber ].device->TC;
-}
-
-inline rtems_status_code lpc176x_timer_set_timer_value(
- const lpc176x_timer_number tnumber,
- const uint32_t timer_value
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- timers[ tnumber ].device->TC = timer_value;
- status_code = RTEMS_SUCCESSFUL;
- }
-
- /* else implies that the timer number is invalid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-void lpc176x_timer_isr( void *arg )
-{
- const lpc176x_timer_number tnumber = (lpc176x_timer_number) arg;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- lpc176x_isr_function i;
-
- for ( i = 0; i < LPC176X_ISR_FUNCTIONS_COUNT; ++i ) {
- if ( lpc176x_timer_interrupt_is_pending( tnumber, i ) ) {
- lpc176x_call_desired_isr( tnumber, i );
- lpc176x_timer_reset_interrupt( tnumber, i );
- }
-
- /* else implies that the current timer is not pending. Also,
- there is nothing to do. */
- }
- }
-
- /* else implies that the timer number is not valid. Also,
- there is nothing to do. */
-}
-
-rtems_status_code lpc176x_timer_init( const lpc176x_timer_number tnumber )
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- if ( tnumber < LPC176X_TIMER_COUNT ) {
- status_code = lpc176x_module_enable( timers[ tnumber ].module,
- LPC176X_MODULE_PCLK_DEFAULT );
- RTEMS_CHECK_SC( status_code, "Enabling the timer module." );
-
- status_code = lpc176x_timer_reset( tnumber );
- status_code = lpc176x_timer_set_mode( tnumber,
- LPC176X_TIMER_MODE_TIMER );
- status_code = lpc176x_timer_set_resolution( tnumber,
- LPC176X_TIMER_DEFAULT_RESOLUTION );
-
- timers[ tnumber ].device->MCR = LPC176X_TIMER_CLEAR_FUNCTION;
- timers[ tnumber ].device->CCR = LPC176X_TIMER_CLEAR_FUNCTION;
- timers[ tnumber ].device->EMR = LPC176X_TIMER_CLEAR_FUNCTION;
- }
-
- /* else implies that the timer number is not valid. Also,
- an invalid number is returned. */
-
- return status_code;
-}
-
-rtems_status_code lpc176x_timer_init_with_interrupt(
- const lpc176x_timer_number tnumber,
- const lpc176x_isr_funct_vector *const vector
-)
-{
- rtems_status_code status_code = RTEMS_INVALID_NUMBER;
-
- char isrname[ LPC176X_ISR_NAME_STRING_SIZE ];
-
- snprintf( isrname, LPC176X_ISR_NAME_STRING_SIZE, "TimerIsr%d", tnumber );
-
- if ( tnumber < LPC176X_TIMER_COUNT && vector != NULL ) {
- functions_vector[ tnumber ].funct_vector = vector;
-
- status_code = lpc176x_timer_init( tnumber );
- status_code = rtems_interrupt_handler_install(
- LPC176X_TIMER_VECTOR_NUMBER( tnumber ),
- isrname,
- RTEMS_INTERRUPT_UNIQUE,
- lpc176x_timer_isr,
- (void *) tnumber );
- }
-
- return status_code;
-} \ No newline at end of file
diff --git a/c/src/lib/libbsp/arm/rtl22xx/Makefile.am b/c/src/lib/libbsp/arm/rtl22xx/Makefile.am
index aff940c6ab..7a8ff9e58e 100644
--- a/c/src/lib/libbsp/arm/rtl22xx/Makefile.am
+++ b/c/src/lib/libbsp/arm/rtl22xx/Makefile.am
@@ -27,7 +27,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/sbrk.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/getentropy/getentropy-cpucounter.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterread.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterdiff.c
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/rtl22xx/btimer/btimer.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/rtl22xx/clock/clockdrv.c
# console
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/legacy-console.c
diff --git a/c/src/lib/libbsp/arm/rtl22xx/timer/lpc_timer.h b/c/src/lib/libbsp/arm/rtl22xx/timer/lpc_timer.h
deleted file mode 100644
index 364812ddb8..0000000000
--- a/c/src/lib/libbsp/arm/rtl22xx/timer/lpc_timer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __LPC_TIMER_H
-#define __LPC_TIMER_H
-
-/*************************************************************************
- *
- * File name : Timer.h
- *
- **************************************************************************/
-
-/* Timer Control register bit descriptions */
-#define TCR_ENABLE_BIT 0
-#define TCR_RESET_BIT 1
-
-// The channel name which is used in matching, in fact they represent
-// corresponding Match Register
-#define CH_MAXNUM 4
-#define CH0 0
-#define CH1 1
-#define CH2 2
-#define CH3 3
-
-// The channel name which is used in capturing, in fact they represent
-// corresponding Capture Register
-#define CPCH_MAXNUM 4
-#define CPCH0 0
-#define CPCH1 1
-#define CPCH2 2
-#define CPCH3 3
-
-//The actions when matching
-#define TimerAction_Interrupt 0x1
-#define TimerAction_ResetTimer 0x2
-#define TimerAction_StopTimer 0x4
-
-//Interrupt source type
-#define TIMERMR0Int 0x01
-#define TIMERMR1Int 0x02
-#define TIMERMR2Int 0x04
-#define TIMERMR3Int 0x08
-#define TIMERCR0Int 0x10
-#define TIMERCR1Int 0x20
-#define TIMERCR2Int 0x40
-#define TIMERCR3Int 0x80
-
-#define TIMERALLInt 0xFF
-
-#endif //__LPC_Timer_H
-
diff --git a/c/src/lib/libbsp/arm/rtl22xx/timer/timer.c b/c/src/lib/libbsp/arm/rtl22xx/timer/timer.c
deleted file mode 100644
index ad73aeda3c..0000000000
--- a/c/src/lib/libbsp/arm/rtl22xx/timer/timer.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * @file
- * @brief RTL22xx board Timer driver
- *
- * This uses Timer1 for timing measurments.
- */
-
-/*
- * By Ray Xu <rayx.cn@gmail.com>, modify form Mc9328mxl RTEMS DSP
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <rtems.h>
-#include <rtems/btimer.h>
-#include <lpc22xx.h>
-#include "lpc_timer.h"
-
-uint32_t g_start;
-uint32_t g_freq;
-
-bool benchmark_timer_find_average_overhead;
-
-
-/*
- * Set up Timer 1
- */
-void benchmark_timer_initialize( void )
-{
- g_freq = LPC22xx_Fpclk / 1000;
-}
-
-/*
- * The following controls the behavior of benchmark_timer_read().
- *
- * 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 */
-
-benchmark_timer_t benchmark_timer_read( void )
-{
- return (T0TC/(LPC22xx_Fpclk/1000000));
- /*
- * Total is calculated by taking into account the number of timer overflow
- * interrupts since the timer was initialized and clicks since the last
- * interrupts.
- */
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
-
diff --git a/c/src/lib/libbsp/arm/smdk2410/Makefile.am b/c/src/lib/libbsp/arm/smdk2410/Makefile.am
index dcfae9b564..6fe9190c4b 100644
--- a/c/src/lib/libbsp/arm/smdk2410/Makefile.am
+++ b/c/src/lib/libbsp/arm/smdk2410/Makefile.am
@@ -27,7 +27,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/sbrk.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspgetworkarea-default.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterread.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/cpucounter/cpucounterdiff.c
-librtemsbsp_a_SOURCES += timer/timer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/arm/smdk2410/btimer/btimer.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/smdk2410/clock/clockdrv.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/arm/smdk2410/clock/support.c
# console
diff --git a/c/src/lib/libbsp/arm/smdk2410/timer/timer.c b/c/src/lib/libbsp/arm/smdk2410/timer/timer.c
deleted file mode 100644
index 2bc599df75..0000000000
--- a/c/src/lib/libbsp/arm/smdk2410/timer/timer.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * @file
- * @brief S3C2400 Timer driver
- *
- * This uses timer 1 for timing measurments.
- */
-
-/*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <rtems.h>
-#include <rtems/btimer.h>
-#include <s3c24xx.h>
-
-uint32_t g_start;
-uint32_t g_freq;
-
-bool benchmark_timer_find_average_overhead;
-
-
-/*
- * Set up Timer 1
- */
-void benchmark_timer_initialize( void )
-{
- uint32_t cr;
-
- /* stop TIMER1*/
- cr=rTCON & 0xFFFFF0FF;
- rTCON=(cr | (0x0 << 8));
-
- /* set MUX for Timer1 to 1/2 */
- cr=rTCFG1 & 0xFFFFFF0F;
- rTCFG1=(cr | (0<<4));
-
- /* input freq=PLCK/2 Mhz*/
- g_freq = get_PCLK() / 2000;
- rTCNTB1 = 0xFFFF;
-
- /* start TIMER1 with manual reload */
- cr=rTCON & 0xFFFFF0FF;
- rTCON=(cr | (0x1 << 9));
- rTCON=(cr | (0x1 << 8));
-
- g_start = rTCNTO1;
-}
-
-/*
- * The following controls the behavior of benchmark_timer_read().
- *
- * 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 */
-
-benchmark_timer_t benchmark_timer_read( void )
-{
- uint32_t t;
- unsigned long long total;
-
- t = rTCNTO1;
- /*
- * 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 = (g_start - t);
-
- /* convert to microseconds */
- total = (total*1000) / g_freq;
-
- if ( benchmark_timer_find_average_overhead == 1 ) {
- return (int) total;
- } else if ( total < LEAST_VALID ) {
- return 0;
- }
-
- /*
- * Somehow convert total into microseconds
- */
- return (total - AVG_OVERHEAD);
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
-