5.4 DEMO1
/* -------------------------------------------------------------------------- */
/* DEMO1: D/O demo for PIO-DA16/8/4 */
/* Step 1: Run DEMO1.EXE under DOS */
/* Step 2: Check the LEDs of DB-24C will turn on sequentially */
/* ------------------------------------------------------------------------- */
#include "PIO.H"
void pio_da16_do(WORD wDo);
WORD wBase,wIrq;
int main()
{
int i,j;
WORD wBoards,wRetVal,t1,t2,t3,t4,t5,t6;
WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice;
clrscr();
/* Step 1: find address-mapping of PIO/PISO cards */
wRetVal=PIO_DriverInit(&wBoards,0x80,0x04,0x00);
/*for PIO-DA16/8/4*/
printf("\n(1) Threr are %d PIO-DA16/8/4 Cards in this PC",wBoards);
if ( wBoards==0 ) exit(0);
printf("\n\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,%x],
SlotID=[%x,%x]",i,wBase,wIrq,wSubVendor,wSubDevice,wSubAux,
wSlotBus,wSlotDevice);
printf(" --> ");
ShowPioPiso(wSubVendor,wSubDevice,wSubAux);
}
PIO_GetConfigAddressSpace(0,&wBase,&wIrq,&t1,&t2,&t3,&t4,&t5);
/* select card_0 */
/* Step 2: enable all D/I/O port */
outportb(wBase,1);
/* /RESET -> 1 */
printf("\n\n(2) DEMO1 D/O test");
j=1;
for(;;)
{
gotoxy(1,8);
pio_da16_do(j);
printf("\nDO ==> %4x",j);
delay(10000);
if (kbhit()!=0) break;
j=j<<1; j=j&0x0ffff;if (j==0) j=1;
}
PIO_DriverClose();
}
/* ------------------------------------------------------------------------------------ */
void pio_da16_do(WORD wDo)
{
outportb(wBase+0xf8,wDo);
/* 0xf8 : low byte of DO port */
outportb(wBase+0xfc,(wDo>>8));
/* 0xfc : high byte of DO port */
}
PIO-DA/PISO-DA Series User Manual (Ver.2.9, Feb. 2011, PMH-009-29 )
62