/* demo 1 : D/O demo */ /* step 1 : connect a DB-24C to CN1 of PIO-D144 */ /* step 2 : run DEMO1.EXE */ /* step 3 : check the LEDs of DB-24C will turn on sequentially */ /* ----------------------------------------------------------- */ #include "PIO.H" int main() { int i; WORD wBoards; WORD wBase,wIrq,wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice; char c; clrscr(); PIO_DriverInit(&wBoards,0x80,0x01,0x00); /* for PIO-D144 */ printf("\n(1) Threr are %d PIO-D144 Cards in this PC",wBoards); if ( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("(1) There are no PIO-D144 card in this PC !!!\n"); exit(0); } printf("\n(2) The Configuration Space -> wBase"); for(i=0; i only CN1_PA, CN1_PB, CN1_PC are D/O port */ /* step 2: enable all D/I/O port */ outp(wBase,1); /* enable D/I/O */ /* step 3: select the active port */ outp(wBase+0xc4,0); /* select CN1_PA */ /* step 4: send initial-value to D/O latch register of active port */ outp(wBase+0xc0,0); /* set CN1_PA0 to CN1_PA7 to 0 */ /* step 5: repeat for all D/O ports */ outp(wBase+0xc4,1); /* select CN1_PB */ outp(wBase+0xc0,0); /* set CN1_PB0 to CN1_PB7 to 0 */ outp(wBase+0xc4,2); /* select CN1_PC */ outp(wBase+0xc0,0); /* set CN1_PC0 to CN1_PC7 to 0 */ /* step 6: configure all I/O port */ outp(wBase+0xc8,0x00); /* CN1_PA/PB/PC to CN2_PA/PB/PC are all output */ outp(wBase+0xcc,0x00); /* CN3_PA/PB/PC to CN4_PA/PB/PC are all output */ outp(wBase+0xd0,0x00); /* CN5_PA/PB/PC to CN6_PA/PB/PC are all output */ for (;;) { printf("\nCN1 : PA=0x55, PB=0xAA, PC=0x5A, press Q to stop"); outp(wBase+0xc4,0); /* select port-0 */ outp(wBase+0xc0,0x55); /* set PA=0x55 */ outp(wBase+0xc4,1); /* select port-1 */ outp(wBase+0xc0,0xaa); /* set PB=0xaa */ outp(wBase+0xc4,2); /* select port-2 */ outp(wBase+0xc0,0x5a); /* set PC=0x5a */ c=getch(); if ((c=='Q') || (c=='q')) break; printf("\nCN1 : PA=0xAA, PB=0x55, PC=0xA5, press Q to stop"); outp(wBase+0xc4,0); /* select port-0 */ outp(wBase+0xc0,0xAA); /* set PA=0xAA */ outp(wBase+0xc4,1); /* select port-1 */ outp(wBase+0xc0,0x55); /* set PB=0x55 */ outp(wBase+0xc4,2); /* select port-2 */ outp(wBase+0xc0,0xa5); /* set PC=0xA5 */ c=getch(); if ((c=='Q') || (c=='q')) break; } PIO_DriverClose(); }