X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=projects%2Fstep-up%2Fwdt.c;h=cb94ec8bc5260b054170404846ef50f61ead66ea;hp=050c0c550f5c762242a345fbb80e81db5915f2c3;hb=HEAD;hpb=56ad7e84d0f55301169aa2c9e8f80f0c871f63da diff --git a/projects/step-up/wdt.c b/projects/step-up/wdt.c index 050c0c5..cb94ec8 100644 --- a/projects/step-up/wdt.c +++ b/projects/step-up/wdt.c @@ -6,7 +6,7 @@ void init_wdt() { - wdt_enable(WDTO_1S); + WDTCR = _BV(WDIE) | _BV(WDP1); // interrupt mode, 64 ms } void susp_wdt() @@ -14,3 +14,19 @@ void susp_wdt() wdt_disable(); } +ISR(WDT_vect) { + ++jiffies; + + if (pwm_enabled) { + need_pwmled_adc = 1; + } + + if (jiffies & 0x000F) { + need_battery_adc = 1; // about every 1s + } + + patterns_next_tick(); + timer_check_buttons(); + if (!adc_enabled) + start_next_adc(); // only if not running +}