unsigned char i;
current_adc = 0;
adc_is_on = 1;
+ slow_adcs_wanted = FIRST_1S_ADC;
ADCSRA = _BV(ADEN) // enable
| _BV(ADPS1) | _BV(ADPS0) // CLK/8 = 125 kHz
ISR(ADC_vect) { // IRQ handler
uint16_t adcval = ADCW;
+ /*
+ * After the timer interrupt, drop the current reading.
+ * We may have changed the PWM outputs, so the value is
+ * probably useless anyway.
+ * FIXME: possible race condition - we should make an explicit
+ * notification inside the timer IRQ handler.
+ */
+ if (slow_adcs_wanted) {
+ start_next_adc();
+ return;
+ }
+
if (zero_count) {
if (zero_count > 1) {
ADCSRA |= _BV(ADSC);
ADCSRA |= _BV(ADSC);
adc_sum += adcval;
read_count--;
+ pwm_timer();
return;
}