summaryrefslogtreecommitdiff
path: root/src/app/wetterstation/main.cc
blob: 2c47d78cf7affb20b403185c328609af737d37b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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++;
}