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
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).
#define PWMLED_ADC_SHIFT 3 /* 1<<3 measurements per single callback */
void init_adc();
void susp_adc();
+void timer_start_adcs();
/* pwm.c */
/*
patterns_next_tick();
pattern_div = PATTERN_DIV;
}
+
+ timer_start_adcs();
}