aboutsummaryrefslogtreecommitdiff
path: root/Client/ThirdParty/libfixmath/benchmarks/interface-avr.c
blob: c3bd4c2cf0a034b092af80d99af17c546076d627 (plain)
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
#include <avr/io.h>
#include <stdio.h>
#include "interface.h"
#include <stdint.h>

#define special_output_port (*((volatile char *)0x20))
static int output_char(char c, FILE *stream)
{
    special_output_port = c;
    return 0;
}

static FILE mystdout = FDEV_SETUP_STREAM(output_char, NULL, _FDEV_SETUP_WRITE);

void interface_init()
{
    // Set timer 1 to count cycles
    TCCR1B = 1;
    
    // Set output to simulator
    stdout = &mystdout;
    stderr = &mystdout;
}


void start_timing()
{
    TCNT1 = 0;
}

uint16_t end_timing()
{
    return TCNT1 - 9;
}