summaryrefslogtreecommitdiff
path: root/src/app/wetterstation/main.cc
diff options
context:
space:
mode:
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++;
+}