blob: 73d7a7c310203fd0e1d8596869ec246f6327d7ee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* RTEMS for Nintendo DS performance timer driver.
*
* Copyright (c) 2008 by Benjamin Ratier <agho.pwn@gmail.com>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.rtems.com/license/LICENSE
*/
#include <rtems.h>
#include <rtems/btimer.h>
#include <bsp.h>
#include <nds.h>
bool benchmark_timer_find_average_overhead;
void
benchmark_timer_initialize (void)
{
TIMER_CR (1) = 0x0000;
TIMER_CR (2) = 0x0000;
TIMER_DATA (1) = TIMER_FREQ (1000000);
TIMER_DATA (2) = 0x0000;
TIMER_CR (1) = TIMER_ENABLE | TIMER_DIV_1;
TIMER_CR (2) = TIMER_ENABLE | TIMER_CASCADE;
}
/*
* values taken out from gba bsp.
*/
#define AVG_OVERHEAD 3
#define LEAST_VALID 1
uint32_t
benchmark_timer_read (void)
{
uint32_t ticks;
/* stop counters */
TIMER_CR (1) = 0x0000;
TIMER_CR (2) = 0x0000;
/* read counter */
ticks = (TIMER_DATA (2) << 16) | TIMER_DATA (1);
return ticks;
}
void
benchmark_timer_disable_subtracting_average_overhead (bool find_flag)
{
benchmark_timer_find_average_overhead = find_flag;
}
|