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=b7dad0ad59b31a940acecec248c91fd14ba8b2aa;hp=fa0782c4248c6ee67917901cc1340dedfefea087;hb=210916486d18b3dc976c65c7b01b44bca446d856;hpb=5160421f0d1725356e74a24b334e68eaaa9b398c diff --git a/firmware/adc.c b/firmware/adc.c index fa0782c..b7dad0a 100644 --- a/firmware/adc.c +++ b/firmware/adc.c @@ -51,15 +51,15 @@ static void inline setup_mux(unsigned char n) static void start_next_adc() { - if (current_adc > 0) { + if (current_adc > 0) current_adc--; - // set up mux, start one-shot conversion - setup_mux(current_adc); - ADCSRA |= _BV(ADSC); - } else { - current_adc = NUM_ADCS; + else // TODO: kick the watchdog here. - } + current_adc = NUM_ADCS-1; + + // set up mux, start one-shot conversion + setup_mux(current_adc); + ADCSRA |= _BV(ADSC); } void init_adc() @@ -100,6 +100,8 @@ void init_adc() } ADCSRA |= _BV(ADIE); // enable IRQ + + start_next_adc(); } void susp_adc() @@ -151,13 +153,3 @@ ISR(ADC_vect) { // IRQ handler start_next_adc(); } -void timer_start_adcs() -{ - if (current_adc == NUM_ADCS) // Don't start if in progress - start_next_adc(); -#if 0 - else - log_byte(0x99); -#endif -} -