]> www.fi.muni.cz Git - tinyboard.git/blob - projects/step-up/wdt.c
wdt.c: fix for interrupt-only watchdog mode
[tinyboard.git] / projects / step-up / wdt.c
1 #include <avr/io.h>
2 #include <avr/interrupt.h>
3 #include <avr/wdt.h>
4
5 #include "lights.h"
6
7 void init_wdt()
8 {
9         WDTCR = _BV(WDIE) | _BV(WDP1); // interrupt mode, 64 ms
10 }
11
12 void susp_wdt()
13 {
14         wdt_disable();
15 }
16
17 ISR(WDT_vect) {
18         ++jiffies;
19
20         if (jiffies & 0x000F) {
21                 need_battery_adc = 1; // about every 1s
22         }
23
24         patterns_next_tick();
25         timer_check_buttons();
26 }