reduce analog subsystem use of interrupts

This commit is contained in:
Michael Moon 2010-10-19 10:39:53 +11:00
parent d0c3744f92
commit 97c5218304
1 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,9 @@ ISR(ADC_vect) {
if (adc_counter == 8) {
adc_counter = 0;
adc_running_mask = 1;
// relax interrupt use for analog subsystem- stop after last analog read
ADCSRA &= ~MASK(ADIE);
}
} while ((adc_running_mask & ANALOG_MASK) == 0);
@ -61,5 +64,9 @@ uint16_t analog_read(uint8_t channel) {
r = adc_result[channel];
// restore interrupt flag
SREG = sreg;
// re-enable analog read loop so we can get new values
ADCSRA |= MASK(ADIE);
return r;
}