summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-05-24 09:09:24 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-05-24 09:09:24 +0200
commitc0b7a8420fb4105c0dd86d1eaf35f6e339769570 (patch)
treecb9779c81d32d40e136600f469a046fb8d609562 /src
parentabac017d275d8bd090d6520a5e521f26a06c03a1 (diff)
add waittest app
Diffstat (limited to 'src')
-rw-r--r--src/app/waittest/Makefile.inc3
-rw-r--r--src/app/waittest/main.cc52
2 files changed, 55 insertions, 0 deletions
diff --git a/src/app/waittest/Makefile.inc b/src/app/waittest/Makefile.inc
new file mode 100644
index 0000000..9d375f1
--- /dev/null
+++ b/src/app/waittest/Makefile.inc
@@ -0,0 +1,3 @@
+loop ?= 1
+timer_s ?= 1
+arch_drivers += ,timer
diff --git a/src/app/waittest/main.cc b/src/app/waittest/main.cc
new file mode 100644
index 0000000..f6aaea8
--- /dev/null
+++ b/src/app/waittest/main.cc
@@ -0,0 +1,52 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#include "driver/timer.h"
+#include "driver/uptime.h"
+
+#ifndef F_TIMER
+#define F_TIMER 100000
+#endif
+
+volatile unsigned char timer_done = 0;
+
+inline void await_timer()
+{
+ timer_done = 0;
+ timer.start(1);
+ while (!timer_done) {
+ arch.idle();
+ }
+ timer.stop();
+}
+
+void loop(void)
+{
+ gpio.led_toggle(1);
+ kout << "start waiting" << endl;
+ await_timer();
+ kout << "done waiting" << endl;
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+#if F_TIMER > 999
+ timer.setup_khz(F_TIMER / 1000);
+#else
+ timer.setup_hz(F_TIMER);
+#endif
+
+ gpio.led_on(0);
+ kout << "Timer set at " << dec << F_TIMER << " Hz" << endl;
+
+ arch.idle_loop();
+
+ return 0;
+}
+
+ON_TIMER_INTERRUPT_head
+ timer_done = 1;
+ON_TIMER_INTERRUPT_tail