source: rtems/c/src/lib/libcpu/arm/lpc22xx/timer/timer.c @ 8fbe2e6

4.11
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2014 at 1:59:49 PM

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 * @brief RTL22xx board Timer driver
4 *
5 * This uses Timer1 for timing measurments.
6 */
7
8/*
9 * By Ray Xu <rayx.cn@gmail.com>, modify form Mc9328mxl RTEMS DSP
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#include <bsp.h>
17#include <rtems.h>
18#include <rtems/btimer.h>
19#include <lpc22xx.h>
20#include "lpc_timer.h"
21
22uint32_t g_start;
23uint32_t g_freq;
24
25bool benchmark_timer_find_average_overhead;
26
27
28/*
29 * Set up Timer 1
30 */
31void benchmark_timer_initialize( void )
32{
33       g_freq = LPC22xx_Fpclk / 1000;
34}
35
36/*
37 *  The following controls the behavior of benchmark_timer_read().
38 *
39 *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
40 *  is usually deducted from the number returned.
41 *
42 *  LEAST_VALID is the lowest number this routine should trust.  Numbers
43 *  below this are "noise" and zero is returned.
44 */
45
46#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
47                             /* (Y countdowns) to start/stop the timer. */
48                             /* This value is in microseconds. */
49#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
50
51benchmark_timer_t benchmark_timer_read( void )
52{
53  return (T0TC/(LPC22xx_Fpclk/1000000));
54  /*
55   *  Total is calculated by taking into account the number of timer overflow
56   *  interrupts since the timer was initialized and clicks since the last
57   *  interrupts.
58   */
59}
60
61void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
62{
63  benchmark_timer_find_average_overhead = find_flag;
64}
65
Note: See TracBrowser for help on using the repository browser.