/* demo1 : D/O demo for PIO-D48 */ /* step 1 : connect CN1 of PIO-D48 to DB-24C */ /* step 2 : connect CN2 of PIO-D48 to another DB-24C */ /* step 3 : run DEMO1.EXE */ /* ----------------------------------------------------------- */ #include "PIO.H" WORD wBase,wIrq; WORD wBase2,wIrq2; int main() { int i,j,k,jj,dd; WORD wBoards,wRetVal; WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice,t1,t2,t3,t4,t5; char c; /* step 1: find address-mapping of PIO/PISO cards */ clrscr(); wRetVal=PIO_DriverInit(&wBoards,0x80,0x01,0x30); /* for PIO-D48 */ printf("\nThrer are %d PIO_D48 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 */ outportb(wBase,1); /* enable D/I/O */ /* step 3: program 8255-1-PA-PB-PC as output port */ outportb(wBase+0xcc,0x80); /* 8255-1-PA,PB,PC are all output port */ outportb(wBase+0xc0,0); /* 8255-1-PA initial=0 */ outportb(wBase+0xc4,0); /* 8255-1-PB initial=0 */ outportb(wBase+0xc8,0); /* 8255-1-PB initial=0 */ /* step 4: program 8255-2-PA-PB-PC as output port */ outportb(wBase+0xdc,0x80); /* 8255-2-PA,PB,PC are all output port */ outportb(wBase+0xd0,0); /* 8255-2-PA initial=0 */ outportb(wBase+0xd4,0); /* 8255-2-PB initial=0 */ outportb(wBase+0xd8,0); /* 8255-2-PB initial=0 */ printf("\n----------- Test D/O (DB-24C)--------------"); i=1; for (;;) { /* send test pattern to CN1 of PIO_D48 */ outportb(wBase+0xc0,i); printf("\nOutput=%x",i); outportb(wBase+0xc4,i); outportb(wBase+0xc8,i); /* send test pattern to CN2 of PIO_D48 */ outportb(wBase+0xd0,i); outportb(wBase+0xd4,i); outportb(wBase+0xd8,i); delay(1000); if (kbhit()!=0) { c=getch(); if ((c=='q') || (c=='Q')) return; } i=i<<1; /* next bit */ if (i>0x80) { i=1; c=getch(); if ((c=='Q') || (c=='q')) return; printf("\n----------- Test D/O (DB-24C)--------------"); } } PIO_DriverClose(); }