Listing 5. Main Reading Loop
/* Main reading loop */
for(i=0;i<num_in_chan;i++){
/* Set trigger to 1 */
outb((unsigned char)(0x3+(0x10*i)),
PC30AT_BASE+PORT_C30AT);
/* Set trigger to 0 to start conversion.
* At the same time, the next
* channel to convert is set up*/
outb((unsigned char)(0x2+(0x10*(i+1 %
num_in_chan))),PC30AT_BASE+PORT_C30AT);
/* Wait until conversion has finished */
while (((inb(PC30AT_BASE+PORT_B30AT))& (0x20))==0);
/* Read the converted data to the character
* buffer in two bytes */
current_adc[i].byte[0]=inb(PC30AT_BASE+PORT_A30AT);
current_adc[i].byte[1]=(inb(PC30AT_BASE+PORT_B30AT)
&0x0f);
}