blob: 6f621af92620f2474a3350ab017ba9fd2720d796 (
plain) (
blame)
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
45
46
47
48
49
50
51
52
53
|
#include <avr/interrupt.h>
#include <avr/io.h>
#include <stdbool.h>
#include <util/delay.h>
#include "button.h"
#include "display.h"
#include "rtc.h"
// Config for attiny84a + external 32KHz crystal osc taken from
// https://github.com/ingepnet/breadboardwatch/blob/master/Makefile#L26
#include <avr/fuse.h>
FUSES = {
.low = 0xe6,
.high = 0xd7,
.extended = 0xff,
};
// Display interrupt
// Timer 0 has lower priority than timer 1, so some ticks could get skipped on
// interrupt starvation
ISR(TIM0_COMPA_vect, ISR_FLATTEN) { display_render(); }
// RTC interrupt
ISR(TIM1_COMPA_vect, ISR_FLATTEN) { rtc_increment(); }
int main(void) {
PRR = 0b0011; // Power reduction register. Shut down USI and ADC
display_setup();
rtc_setup();
sei();
while (1) {
// switch (button_tick()) {
// case BUTTON_PRESSED:
// seconds += 5;
// break;
// case BUTTON_LONG_PRESSED:
// seconds += 10;
// break;
// default:
// break;
// }
#ifdef STUBBED
stub_run_timers();
_delay_ms(100);
#endif
}
return 0;
}
|