Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:04

0001 /**
0002  * @file
0003  * @brief RTL22xx board Timer driver
0004  *
0005  * This uses Timer1 for timing measurments.
0006  */
0007 
0008 /*
0009  * By Ray Xu <rayx.cn@gmail.com>, modify form Mc9328mxl RTEMS DSP
0010  *
0011  * The license and distribution terms for this file may be
0012  * found in the file LICENSE in this distribution or at
0013  * http://www.rtems.org/license/LICENSE.
0014  */
0015 
0016 #include <bsp.h>
0017 #include <rtems.h>
0018 #include <rtems/btimer.h>
0019 #include <lpc22xx.h>
0020 #include "lpc_timer.h"
0021 
0022 uint32_t g_start;
0023 uint32_t g_freq;
0024 
0025 bool benchmark_timer_find_average_overhead;
0026 
0027 
0028 /*
0029  * Set up Timer 1
0030  */
0031 void benchmark_timer_initialize( void )
0032 {
0033        g_freq = LPC22xx_Fpclk / 1000;
0034 }
0035 
0036 /*
0037  *  The following controls the behavior of benchmark_timer_read().
0038  *
0039  *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
0040  *  is usually deducted from the number returned.
0041  *
0042  *  LEAST_VALID is the lowest number this routine should trust.  Numbers
0043  *  below this are "noise" and zero is returned.
0044  */
0045 
0046 #define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
0047                              /* (Y countdowns) to start/stop the timer. */
0048                              /* This value is in microseconds. */
0049 #define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
0050 
0051 benchmark_timer_t benchmark_timer_read( void )
0052 {
0053   return (T0TC/(LPC22xx_Fpclk/1000000));
0054   /*
0055    *  Total is calculated by taking into account the number of timer overflow
0056    *  interrupts since the timer was initialized and clicks since the last
0057    *  interrupts.
0058    */
0059 }
0060 
0061 void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
0062 {
0063   benchmark_timer_find_average_overhead = find_flag;
0064 }
0065