if the accuracy of the sample rate is low enough i just poll the ADC interrupt flag or the DONE bit in the ADC registers...
since i usually use the various analog inputs, instead of using one and multiplexing before the ADC pin, my "selection" variable is the channel select bits!!
this pseudocode at least works on PICs, but i am sure you can adapt it to AVR
void ADC_Read() {
//This is a "Task", called inside the main loop.
if (!ADCIF) {
return;
}
switch(ADCONbits.ADCHS) {
case 0:
//AN0 has finished converting
data0 = ADRES;
ADCONbits.ADCHS = 1; //Next Step will be converting AN1
break;
case 1:
//AN1 has finished converting
data1 = ADRES;
ADCONbits.ADCHS = 2;
break;
// ...
default:
//Shouldn't come here.
ADCONbits.ADCHS = 0;
break;
}
ADCIF = 0;
ADCONbits.GO = 1;
}
newest PIC18 and i think also PIC16 with ADCC (ADC with Computation.. fancy name) will also have automatic sample/convert with channel scan
so this is not required, when the interrupt flag is set just get the whole buffer of scans..