for (;;)
{
printf("\n(CNT_L, CNT_H) = (%d,%d) (%d,%d) (%d,%d) (%d,%d) %x", CNT_L1,CNT_H1,CNT_L2,CNT_H2,CNT_L3,CNT_H3,CNT_L4,CNT_H4,
int_num);
if (kbhit()!=0) {getch(); break;}
}
outp(wBase+5,0); | /* disable all interrupt */ |
|
PIO_DriverClose(); |
|
|
} |
|
|
/* | */ | |
/* Use PC0 as external interrupt signal | */ | |
WORD init_low() |
|
|
{ |
|
|
DWORD dwVal; |
|
|
disable(); |
|
|
outp(wBase+5,0); | /* disable all interrupt */ |
|
if (wIrq<8) |
|
|
{
irqmask=inp(A1_8259+1);
outp(A1_8259+1,irqmask & (0xff ^ (1 << wIrq))); setvect(wIrq+8, irq_service);
}
else
{
irqmask=inp(A1_8259+1); | /* IRQ2 */ |
outp(A1_8259+1,irqmask & 0xfb); |
outp(A1_8259+1,irqmask & (0xff ^ (1 << wIrq))); irqmask=inp(A2_8259+1); outp(A2_8259+1,irqmask & (0xff ^ (1 <<
}
invert=0x05; |
| /* | CN1_PC0 = | ||
outp(wBase+0x2a,invert); | |||||
/* | CN1_PC1 | = | inverte input */ | ||
/* | CN1_PC2 | = | |||
/* | CN1_PC3 | = | |||
now_int_state=0x0a; |
| /* Now | CN1_PC0 = low | */ | |
/* | CN1_PC1 | = high |
| */ | |
/* | CN1_PC2 | = low |
| */ | |
/* | CN1_PC3 | = high |
| */ |
CNT_L1=CNT_L2=CNT_L3=CNT_L4=0; | /* low pulse count */ | |
CNT_H1=CNT_H2=CNT_H3=CNT_H4=0; | /* high pulse count */ | |
int_num=0; | /* enable interrupt PC0,PC1,PC2,PC3 of CN1 */ | |
outp(wBase+5,0x0f); | ||
enable(); |
|
|
} |
|
|
void interrupt irq_service()
{
char cc;
int_num++;
new_int_state=inp(wBase+0x07)&0xff; int_c=new_int_state ^ now_int_state;
|