X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=blobdiff_plain;f=firmware%2Fadc.c;h=f55a42792570670e464c1e66d035b809b6ecc298;hp=02af6b380724ae6f92ccca9407d1e1951a75c53f;hb=6193f6a3200efa660bbbe406e317fe7fa0473de0;hpb=4c6ff89995f620aadb6cd8ef9403adac8ef48478 diff --git a/firmware/adc.c b/firmware/adc.c index 02af6b3..f55a427 100644 --- a/firmware/adc.c +++ b/firmware/adc.c @@ -65,11 +65,13 @@ static void setup_mux(unsigned char n) static void start_next_adc() { - if (current_adc > 0) + if (current_adc > 0) { current_adc--; - else + } else { // TODO: kick the watchdog here. - current_adc = NUM_ADCS-1; + current_adc = NUM_ADCS; + return; + } adc_sum = 0; // we use the last iteration of zero_count to set up the MUX @@ -96,6 +98,14 @@ static void start_next_adc() ADCSRA |= _BV(ADSC); } +void timer_start_adcs() +{ + if (current_adc == NUM_ADCS) // Don't start if in progress + start_next_adc(); + else + log_byte(0x99); // overrun +} + /* * Single synchronous ADC conversion. * Has to be called with IRQs disabled (or with the ADC IRQ disabled).