source: rtems/c/src/lib/libbsp/m32c/m32cbsp/timer/timer.c @ 183af89

4.115
Last change on this file since 183af89 was d085040, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/09/11 at 08:38:15

2011-02-09 Ralf Corsépius <ralf.corsepius@…>

  • timer/timer.c: Include <rtems/btimer.h>. Fix benchmark_timer_read() definition.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  This file implements a stub benchmark timer that is sufficient to
3 *  satisfy linking the RTEMS Benchmarks.
4 *
5 *  COPYRIGHT (c) 1989-2001.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *
9 *  $Id$
10 */
11
12#include <bsp.h>
13#include <rtems/btimer.h>
14
15#include <varvects.h>
16
17bool benchmark_timer_find_average_overhead;
18uint32_t benchmark_timer_overhead = 10;
19
20#define TABSR *((uint8_t *)0x340)
21#define TA0MR *((uint8_t *)0x356)
22#define TA0   *((uint16_t *)0x346)
23#define TA0IC *((uint8_t *)0x6c)
24
25static int benchmark_timer_interrupts;
26
27#define ivec_timer_a0 12
28
29void __attribute__((interrupt))
30timer_ra_interrupt(void)
31{
32  benchmark_timer_interrupts++;
33  TA0IC = 0x05;
34
35}
36
37void benchmark_timer_initialize(void)
38{
39  benchmark_timer_interrupts = 0;
40  _set_var_vect (timer_ra_interrupt, ivec_timer_a0);
41  TA0MR = 0x00;
42  TA0   = 0xffff;
43  TA0IC = 0x05;
44  TABSR = 0x55;
45}
46
47uint32_t benchmark_timer_read(void)
48{
49  uint32_t count;
50
51  count = 0xFFFF - TA0;
52  count += benchmark_timer_interrupts * 0xFFFFL;
53
54  if (!benchmark_timer_find_average_overhead) {
55    if ( count > benchmark_timer_overhead )
56      count -= benchmark_timer_overhead;
57    else
58      count = 0;
59  }
60  return count;
61}
62
63void benchmark_timer_disable_subtracting_average_overhead(
64  bool find_flag
65)
66{
67  benchmark_timer_find_average_overhead = find_flag;
68}
Note: See TracBrowser for help on using the repository browser.