/****************************************************************************

IOEDGL96.C

	Sample program for IOE-DGL96 digital i/o board.
	Ground any Port A input pin or pins on PIO 3,4, or 5  and watch the
	readout change. All output pins on PIO 2 port A should be high (check
	with voltmeter). On PIO 0 & 1 port A, one side of output pins should be
	high and the other low. 

****************************************************************************/
#use 96io.lib

main(){

	// Set PIO 0-2 A ports for output
	hitwd();
	Set_Port_Dir(0,0,0,0);  
	Set_Port_Dir(0,1,0,0);
	Set_Port_Dir(0,2,0,0);

	// Set PIO 3-5 A ports for input
	Set_Port_Dir(0,3,0,255);
	Set_Port_Dir(0,4,0,255);
	Set_Port_Dir(0,5,0,255);

	// Output to PIO 0-2 A ports
	hitwd();
	Write_Port(0,0,0,0xAA);        // set 1 row of pins high
	Write_Port(0,1,0,0x55);        // set other row of pins high
	Write_Port(0,2,0,0xFF);        // set both rows of pins high

	// Output PIO 3-5 A ports continuously
	printf("port a, pio 3 = \n");
	printf("port a, pio 4 = \n");
	printf("port a, pio 5 = \n");
	while(1){
		hitwd();
		gotoxy(17,0);
		printf("%03d",(int)Read_Port(0,3,0,STRIP_MODE));
		gotoxy(17,1);
		printf("%03d",(int)Read_Port(0,4,0,STRIP_MODE));
		gotoxy(17,2);
		printf("%03d",(int)Read_Port(0,5,0,STRIP_MODE));
	}
}

// move cursor
gotoxy (int x, int y)
{       
   x += 0x20;
   y += 0x20;
   printf ( "\x1B=%c%c",x,y );
}

