summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-07-12 10:57:02 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-07-12 10:57:02 +0200
commit68eb5f7bf403f4a8cfc42b54b6a7fea087d34960 (patch)
tree2f8063bb7461a263610f45da3bf2c7008bae92e0
parent136d16ad4248d9cbd5aae871ffb76632ca8dfdc9 (diff)
Add delay_us on AVR arch
-rw-r--r--include/arch.h1
-rw-r--r--src/arch/arduino-nano/arch.cc6
2 files changed, 7 insertions, 0 deletions
diff --git a/include/arch.h b/include/arch.h
index b588e66..70bc41c 100644
--- a/include/arch.h
+++ b/include/arch.h
@@ -9,6 +9,7 @@ class Arch {
Arch () {}
void setup();
void idle_loop();
+ void delay_us(unsigned char const us);
};
extern Arch arch;
diff --git a/src/arch/arduino-nano/arch.cc b/src/arch/arduino-nano/arch.cc
index f35cb1d..16d09fb 100644
--- a/src/arch/arduino-nano/arch.cc
+++ b/src/arch/arduino-nano/arch.cc
@@ -1,6 +1,7 @@
#include "arch.h"
#include <avr/io.h>
#include <avr/interrupt.h>
+#include <util/delay.h>
void Arch::setup(void)
{
@@ -54,6 +55,11 @@ void Arch::idle_loop(void)
}
}
+void Arch::delay_us(unsigned char const us)
+{
+ __builtin_avr_delay_cycles(1600);
+}
+
Arch arch;
#if defined(WITH_LOOP) || defined(TIMER_S)