/* DEMO2 : D/I/O demo for PIO-DA16/8/4 */ /* step1 : Connect CON1 & CON2 with a 20-pin 1 to 1 flat cable */ /* step2 : Run DEMO2.EXE */ /* -------------------------------------------------------------- */ #include "PIO.H" void pio_da16_di(WORD *wDi); void pio_da16_do(WORD wDo); WORD wBase,wIrq; int main() { int i,j,k; WORD wBoards,wRetVal,t1,t2,t3,t4,t5,t6; WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice; clrscr(); /* step1 : 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 "); ShowPioPiso(wSubVendor,wSubDevice,wSubAux); } PIO_GetConfigAddressSpace(0,&wBase,&wIrq,&t1,&t2,&t3,&t4,&t5); /* select card_0 */ /* step2 : enable all D/I/O port */ outportb(wBase,1); /* /RESET -> 1 */ printf("\n\n(2) DEMO2 D/I/O test"); j=1; for(;;) { pio_da16_do(j); pio_da16_di(&k); gotoxy(1,9); printf("DO = %4x , DI = %4x",j,k); if (k!=j) printf(" <-- Test Error "); else printf(" <-- Test Ok "); j++; j=j&0x0ffff;if (j==0) j=1; if (kbhit()!=0) break; } PIO_DriverClose(); } /* -------------------------------------------------------------- */ void pio_da16_di(WORD *wDi) { int in_l,in_h; in_l=inportb(wBase+0xe0)&0x0ff; /* 0xe0 : low byte address of DI */ in_h=inportb(wBase+0xe4)&0x0ff; /* 0xe4 :high byte address of DI */ (*wDi)=(in_h<<8)+in_l; } void pio_da16_do(WORD wDo) { outportb(wBase+0xf8,wDo); /* 0xf8 : low byte address of DO */ outportb(wBase+0xfc,(wDo>>8)); /* 0xfc :high byte address of DO */ }