source: rtems/c/src/lib/libbsp/arm/tms570/clock/benchmark_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.2 KB
Line 
1/**
2 * @file benchmark_timer.c
3 *
4 * @ingroup tms570
5 *
6 * @brief clock functions definitions.
7 */
8
9/*
10 * Copyright (c) 2014 Pavel Pisa <pisa@cmp.felk.cvut.cz>
11 *
12 * Czech Technical University in Prague
13 * Zikova 1903/4
14 * 166 36 Praha 6
15 * Czech Republic
16 *
17 * Based on LPC24xx and LPC1768 BSP
18 * by embedded brains GmbH and others
19 *
20 * The license and distribution terms for this file may be
21 * found in the file LICENSE in this distribution or at
22 * http://www.rtems.org/license/LICENSE.
23 */
24
25#include <stdlib.h>
26
27#include <rtems.h>
28#include <bsp.h>
29#include <bsp/system-clocks.h>
30#include <rtems/btimer.h>
31
32bool benchmark_timer_find_average_overhead = false;
33
34static uint32_t benchmark_timer_base;
35
36void benchmark_timer_initialize(void)
37{
38  benchmark_timer_base = _CPU_Counter_read();
39}
40
41benchmark_timer_t benchmark_timer_read(void)
42{
43  uint32_t delta = _CPU_Counter_read() - benchmark_timer_base;
44
45  if (benchmark_timer_find_average_overhead) {
46    return delta;
47  } else {
48    /* TODO check on hardware */
49    if (delta > 74) {
50      return delta - 74;
51    } else {
52      return 0;
53    }
54  }
55}
56
57void benchmark_timer_disable_subtracting_average_overhead(bool find_average_overhead )
58{
59  benchmark_timer_find_average_overhead = find_average_overhead;
60}
Note: See TracBrowser for help on using the repository browser.