/*
	MG2ADC1.C

	Sample program to read data from the ADC TLC1543 of the BL15xx/MicroG2.

	The first four channels of the ADC4 board are read. The data are displayed
	showing the raw A/D readings.
	Refer to sample mg2adc3.c for calibrating the ADC channels for voltage
	readings.
*/

main()
{
int data0, data1, data2, data3;

	printf("Toggle F4 (DOS only) to make keyboard input active as STDIO.\n");
	printf("Hit any key to read A/D data.\n");
	
	for(;;)
	{
		while(!kbhit())			// wait for key from STDIO
		{
			hitwd();					// hit the watchdog
			runwatch();         	// watch window
		}
		getchar();                          // get the key 
	
		data0 = mg2adc_read(0);   // read A/D channel 0
		data1 = mg2adc_read(1);   // read A/D channel 1
		data2 = mg2adc_read(2);   // read A/D channel 2
		data3 = mg2adc_read(3);   // read A/D channel 3   

		printf("\nData for the ADC channels 0-3 !!!\n");
		printf("chan 0 >> %6d\n", data0);
		printf("chan 1 >> %6d\n", data1);
		printf("chan 2 >> %6d\n", data2);
		printf("chan 3 >> %6d\n", data3);
	}
}

