From ce0cd4bdafacbaee74eba78f15acccf5488a5a36 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 5 Jul 2020 21:43:08 +0200 Subject: add anemometer app --- src/app/wetterstation/main.cc | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/app/wetterstation/main.cc (limited to 'src/app/wetterstation/main.cc') 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 + +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++; +} -- cgit v1.2.3