/* DEMO2.C : PIO-D64 D/I/O demo */ /* step 1 : connect DO[0..15] to DI[0..15], DO[16] to STROBE1 */ /* step 2 : run DEMO2.EXE */ /* -------------------------------------------------------------- */ #include "PIO.H" long pio_d64_CN2_di(void); long pio_d64_CN4_di(void); void pio_d64_CN1_do(long lDoValue); void pio_d64_CN3_do(long lDoValue); WORD wBase,wIrq; int main() { int i,j,k1,k2,l1,l2,jj,dd,j1,i1,j2,i2; WORD wBoards,wRetVal,t1,t2,t3,t4,t5; WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice; long lOutPad1,lOutPad2,lInPad1,lInPad2; char c; _clearscreen(0); /* step 1: find address-mapping of PIO/PISO cards */ wRetVal=PIO_DriverInit(&wBoards,0x80,0x01,0x20); /* for PIO-D64 */ printf("\nThrer are %d PIO_D64 Cards in this PC",wBoards); if (wBoards==0) exit(0); printf("\n--------------- The Configuration Space ---------------"); for(i=0; i "); ShowPioPiso(wSubVendor,wSubDevice,wSubAux); } /* select card_0 */ PIO_GetConfigAddressSpace(0,&wBase,&wIrq,&t1,&t2,&t3,&t4,&t5); /* step 2: enable all D/I/O port */ outp(wBase,1); /* enable D/I/O */ printf("\n\n"); lOutPad1=1; lOutPad2=1; printf("Press 's' or 'S' to emulate state changed of external STROBE1\n"); for(;;) { pio_d64_CN3_do(lOutPad2); /* emulate external STROBE1 signal */ pio_d64_CN1_do(lOutPad1); lInPad1=pio_d64_CN2_di(); printf("\rOutput CN1=[%4lx]=>Input CN2=[%4lx] (STROBE1=%1lx) ",lOutPad1,lInPad1,(lOutPad2&0x1)); lOutPad1=((lOutPad1<<1)&0xffff); if (lOutPad1==0) lOutPad1=1; if (kbhit()!=0) { c=getch(); if ((c=='q')||(c=='Q')) { break; } else { if ((c=='s')||(c=='S')) { lOutPad2=~lOutPad2; } } } } PIO_DriverClose(); } /* -------------------------------------------------------------- */ void pio_d64_CN1_do(long lDoValue) { outp(wBase+0xc0,(lDoValue&0xff)); outp(wBase+0xc4,((lDoValue>>8)&0xff)); } /* -------------------------------------------------------------- */ void pio_d64_CN3_do(long lDoValue) { outp(wBase+0xc8,(lDoValue&0xff)); outp(wBase+0xcc,((lDoValue>>8)&0xff)); } /* -------------------------------------------------------------- */ long pio_d64_CN2_di(void) { long lDiValue; lDiValue=(inp(wBase+0xc4)<<8); lDiValue=(lDiValue|(inp(wBase+0xc0)))&0xffff; return(lDiValue); } /* -------------------------------------------------------------- */ long pio_d64_CN4_di(void) { long lDiValue; lDiValue=(inp(wBase+0xcc)<<8); lDiValue=(lDiValue|(inp(wBase+0xc8))&0xffff); return(lDiValue); }