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

/* DEMO1.C : VxC-182i 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,0x161,0x01,0x00);  /* for VXC-182I */

	printf("\nThere are %d VXC-182i 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_142_CONFIG); /* VXC-142/142i/182i */



	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_142_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;

}

