blob: 02731aa2ad41d9a32aedbef560b0668db481f2c8 (
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
|
#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;
}
void print_value(const char *label, int32_t value)
{
printf("%-20s %ld\n", label, value);
}
|