From 972126fd2406030dbd3abd1a705bb0ae1af9abb3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 15 Dec 2017 14:55:27 +0100 Subject: Add AVR (Arduino Nano) support --- src/arch/arduino-nano/arch.cc | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/arch/arduino-nano/arch.cc (limited to 'src/arch/arduino-nano/arch.cc') diff --git a/src/arch/arduino-nano/arch.cc b/src/arch/arduino-nano/arch.cc new file mode 100644 index 0000000..28fe34b --- /dev/null +++ b/src/arch/arduino-nano/arch.cc @@ -0,0 +1,58 @@ +#include "arch.h" +#include +#include + +void Arch::setup(void) +{ +#ifdef TIMER_CYCLES + TCCR0A = 0; + TCCR0B = _BV(CS00); +#endif + +#if defined(WITH_LOOP) || defined(TIMER_S) + TCCR1A = 0; + TCCR1B = _BV(WGM12) | _BV(CS12) | _BV(CS10); // /1024 + OCR1A = 15625; + TIMSK1 = _BV(OCIE1A); +#endif + +#ifdef TIMER_US + // 16MHz/8 -> 2MHz timer + TCCR2A = 0; + TCCR2B = _BV(CS21); +#endif + sei(); +} + +#if defined(WITH_LOOP) || defined(TIMER_S) + +#include "driver/uptime.h" +extern void loop(); + +#endif + +void Arch::idle_loop(void) +{ + while (1) { + SMCR = _BV(SE); + asm("sleep"); + SMCR = 0; + asm("wdr"); +#ifdef WITH_LOOP + loop(); +#endif +#ifdef TIMER_S + uptime.tick_s(); +#endif + } +} + +Arch arch; + +#if defined(WITH_LOOP) || defined(TIMER_S) + +ISR(TIMER1_COMPA_vect) +{ +} + +#endif -- cgit v1.2.3