/* ndemo5 : interrupt demo, int source=initial High, active Low */ /* step 1 : connect DO1 (pin1 of CON3) to ECLK11 (pin16 of CON1) */ /* step 2 : J25 select EXT */ /* step 3 : run ndemo5.exe */ /* step 4 : press any key to test, press Q to stop */ /* ------------------------------------------------------------- */ #include "PCITMC12.H" #define A1_8259 0x20 #define A2_8259 0xA0 #define EOI 0x20 WORD pci_tmc12_do(WORD wDo); WORD pci_tmc12_do2(WORD wDo); WORD init_interrupt(); WORD wBaseAddr,wIrq,wPLX,int_count; static void interrupt irq_service(); int irqmask; int main() { int i,j; WORD wBoards,wRetVal,old_count; char c; DWORD dwVal; clrscr(); wRetVal=PTMC12_DriverInit(&wBoards); printf("\n(1) Threr are %d PCI-TMC12 Cards in this PC",wBoards); if ( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("(1) There are no PCI-TMC12 card in this PC !!!\n"); exit(0); } printf("\n(2) Show the Configuration Space of all PCI-TMC12:"); for(i=0; i initial High, active Low */ init_interrupt(); old_count=1; for (;;) { if (old_count != int_count) { printf("\nint_count=%d",int_count); old_count=int_count; } if (kbhit()!=0) { c=getch(); if ((c=='q') || (c=='Q')) break; pci_tmc12_do(0); /* generate a Low pulse to */ pci_tmc12_do(1); /* DO1=ECLK11=J25=int source */ printf(" --> Generate a Low interrupt pulse"); } } PTMC12_DriverClose(); _outpd(wPLX+0x4c,0); /* disable all interrupt */ } /* -------------------------------------------------------------------- */ WORD init_interrupt() { DWORD dwVal; int_count=0; pci_tmc12_do2(0x1000); /* set IntXor On to invert the int source */ inport(wBaseAddr+0x18);/* pre-set int_signal_to_PC to High value */ /* to enable next interrupt operation */ disable(); _outpd(wPLX+0x4c,0x41); /* channel_1, interrupt active_Low */ if (wIrq<8) { irqmask=inportb(A1_8259+1); outportb(A1_8259+1,irqmask & (0xff ^ (1 << wIrq))); setvect(wIrq+8, irq_service); } else { irqmask=inportb(A1_8259+1); outportb(A1_8259+1,irqmask & 0xfb); /* IRQ2 */ outportb(A1_8259+1,irqmask & (0xff ^ (1 << wIrq))); irqmask=inportb(A2_8259+1); outportb(A2_8259+1,irqmask & (0xff ^ (1 << (wIrq-8)))); setvect(wIrq-8+0x70, irq_service); } enable(); } void interrupt irq_service() { /* now the int_signal_to_PC is in Low state */ inport(wBaseAddr+0x18); /* pre-set int_signal_to_pc to High value */ /* to enable next interrupt operation */ int_count++; if (wIrq>=8) outportb(A2_8259,0x20); outportb(A1_8259,0x20); } /* ----------------------------------------------------------- */ WORD pci_tmc12_do(WORD wDo) { outport(wBaseAddr+0x14,wDo); return(NoError); } /* ----------------------------------------------------------- */ WORD pci_tmc12_do2(WORD wDo) { outport(wBaseAddr+0x18,wDo); return(NoError); }