summaryrefslogtreecommitdiff
path: root/src/app/wetterstation/main.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-07-05 21:43:08 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-07-05 21:43:08 +0200
commitce0cd4bdafacbaee74eba78f15acccf5488a5a36 (patch)
tree6f132917ed056d9ebcd7f9d5f73fa1c387f03204 /src/app/wetterstation/main.cc
parent9942173a2b46d5eb28fc41faf1627afc9929902d (diff)
add anemometer app
Diffstat (limited to 'src/app/wetterstation/main.cc')
-rw-r--r--src/app/wetterstation/main.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/app/wetterstation/main.cc b/src/app/wetterstation/main.cc
new file mode 100644
index 0000000..2c47d78
--- /dev/null
+++ b/src/app/wetterstation/main.cc
@@ -0,0 +1,44 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+
+#include <avr/interrupt.h>
+
+volatile uint16_t anemometer_count = 0;
+
+void loop(void)
+{
+ static uint8_t loop_count = 0;
+ static uint16_t anemometer_copy;
+ if (++loop_count == 10) {
+
+ cli();
+ anemometer_copy = anemometer_count;
+ anemometer_count = 0;
+ sei();
+
+ kout << "Anemometer Count = " << anemometer_copy << endl;
+ loop_count = 0;
+ }
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+
+ gpio.output(GPIO::pd2, 0);
+ gpio.input(GPIO::pd3, 1);
+
+ EICRA = _BV(ISC11);
+ EIMSK = _BV(INT1);
+
+ arch.idle_loop();
+
+ return 0;
+}
+
+ISR(INT1_vect) {
+ anemometer_count++;
+}