/* -------------------------------------------------------------- */

/* DEMO1.C : VxC-112A status read & led on/off control            */

/* step 1  : run DEMO1.EXE					  */

/* -------------------------------------------------------------- */



#include "..\PIO.H"

#include "..\VxCard.h"



WORD wBase,wIrq;



int main()

{

	int  i;

	WORD wBoards,wRetVal,t1,t2,t3,t4,t5;

	WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice;

	char c,DO,ReadBack;



	clrscr();



	wRetVal=PIO_DriverInit(&wBoards,0x1D61,0x00,0x00);  /* for VXC-112A */

	printf("\nThere are %d VXC-112A Cards in this PC, Ret:%d",wBoards, wRetVal);

	if (wBoards==0) return 1;



	printf("\n--------------- The Configuration Space ---------------");

	for(i=0; i<wBoards; i++)

	{

		PIO_GetConfigAddressSpace(i,&wBase,&wIrq,&wSubVendor,&wSubDevice,

								&wSubAux,&wSlotBus,&wSlotDevice);

		printf("\nCard_%d: wBase=%x,wIrq=%x,subID=[%x,%x],SlotID=[%x,%x]",i,wBase,wIrq,wSubVendor,wSubDevice,wSlotBus,wSlotDevice);

		printf(" --> ");

		ShowPioPiso(wSubVendor,wSubDevice,wSubAux);

	}



	PIO_GetConfigAddressSpace(0,&wBase,&wIrq,&t1,&t2,&t3,&t4,&t5);



	outportb(wBase, 1);				  /* enable D/I/O */

	Vxc_SetConfig(wBase, VXC_112A_CONFIG); /* VXC-112A */



	for (;;)

	{

		Vxc_SetLed(wBase, VXC_LED_OFF);

		printf("\nLed OFF, Hardware ID=%2x, press Q to stop", Vxc_GetBoardID(wBase) );

		c=getch(); if ((c=='q') || (c=='Q')) break;

		Vxc_SetLed(wBase, VXC_112A_LED_ON);

		printf("\nLed ON , Hardware ID=%2x, press Q to stop", Vxc_GetBoardID(wBase) );

		c=getch(); if ((c=='q') || (c=='Q')) break;

	}



	PIO_DriverClose();

	return 0;

}

