5.7 DEMO5
/* --------------------------------------------------------------------------- */
/* DEMO5 : INT_CHAN_0 & INT_CHAN_1 timer interrupt demo */
/* (It is designed to be a machine independent timer) */
/* Step 1: Run DEMO5.EXE under DOS */
/* ------------------------------------------------------------------------- */
#include "PIO.H"
#define A1_8259 0x20
#define A2_8259 0xA0
static void interrupt irq_service();
WORD wBase,wIrq;
int irqmask,now_int_state,new_int_state,int_c;
int INT0_L,INT0_H,INT1_L,INT1_H;
int b0,b1,invert;
int main()
{
int i,j;
WORD wBoards,wRetVal,t1,t2,t3,t4,t5,t6;
WORD wSubVendor,wSubDevice,wSubAux,wSlotBus,wSlotDevice;
clrscr();
/* Step 1: find address-mapping of PIO/PISO cards */
.
.
/* Step 2: enable all D/I/O port */
outportb(wBase,1);
/* /RESET -> 1 */
printf("\n\n(2) DEMO5 Interrupt test");
init_high();
/* interrupt initialize, INT_CHAN_0/1 is high now */
printf("\n\n*** Show the count of Low_pulse ***\n");
INT0_L=INT0_H=INT1_L=INT1_H=0;
for (;;)
{
gotoxy(1,10);
printf("\nINT0[%x,%x],INT1[%x,%x]",INT0_H,INT0_L,INT1_H,INT1_L);
if (kbhit()!=0) break;
}
outportb(wBase+5,0);
/* disable all interrupt */
PIO_DriverClose();
}
/* Use INT_CHAN_0 & INT_CHAN_1 as internal interrupt signal */
void init_high()
{
DWORD dwVal;
disable();
outportb(wBase+5,0);
/* disable all interrupt */
if (wIrq<8)
{
irqmask=inportb(1);
outportb(1,irqmask & (0xff ^ (1 << wIrq)));
setvect(wIrq+8, irq_service);
}
else
{
irqmask=inportb(1);
outportb(1,irqmask & 0xfb);
/* IRQ2 */
irqmask=inportb(1);
outportb(1,irqmask & (0xff ^ (1 << (wIrq-8))));
setvect(wIrq-8+0x70, irq_service);
}
PIO-DA/PISO-DA Series User Manual (Ver.2.9, Feb. 2011, PMH-009-29 )
66