diff options
author | chai <chaifix@163.com> | 2021-11-30 22:25:37 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-30 22:25:37 +0800 |
commit | 9e0e01b7f4375063f06e494113187d48614628e0 (patch) | |
tree | 21a4901612ad92c121f4c887a33b1bbbe87c6b00 /Client/ThirdParty/libfixmath/benchmarks/interface-avr.c |
+init
Diffstat (limited to 'Client/ThirdParty/libfixmath/benchmarks/interface-avr.c')
-rw-r--r-- | Client/ThirdParty/libfixmath/benchmarks/interface-avr.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Client/ThirdParty/libfixmath/benchmarks/interface-avr.c b/Client/ThirdParty/libfixmath/benchmarks/interface-avr.c new file mode 100644 index 0000000..c3bd4c2 --- /dev/null +++ b/Client/ThirdParty/libfixmath/benchmarks/interface-avr.c @@ -0,0 +1,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; +} |