source: rtems/c/src/lib/libbsp/m32c/m32cbsp/timer/timer.c @ 99a7f55

4.115
Last change on this file since 99a7f55 was 99a7f55, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/14 at 21:05:01

m32c/m32csim/timer/timer.c: Fix warnings

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