diff options
| author | Petteri.Aimonen <Petteri.Aimonen@gmail.com> | 2012-02-27 16:40:45 +0000 |
|---|---|---|
| committer | Petteri.Aimonen <Petteri.Aimonen@gmail.com> | 2012-02-27 16:40:45 +0000 |
| commit | 90973e833d69a93525ef2c4eb5ab687ee13342df (patch) | |
| tree | c154fc48cca12a87b8a82f9892c53d593f5da592 /benchmarks/interface-avr.c | |
| parent | e929442f7113dd321057293b8addd7b6e781d77f (diff) | |
| download | libfixmath-90973e833d69a93525ef2c4eb5ab687ee13342df.tar.gz | |
Benchmark suite using simulators
Diffstat (limited to 'benchmarks/interface-avr.c')
| -rw-r--r-- | benchmarks/interface-avr.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/benchmarks/interface-avr.c b/benchmarks/interface-avr.c new file mode 100644 index 0000000..02731aa --- /dev/null +++ b/benchmarks/interface-avr.c @@ -0,0 +1,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); +} |
