5.6 DEMO3
/* --------------------------------------------------------------------------------------- */
/* DEMO3: INT_CHAN_1, timer interrupt demo (initial high) */
/* (It is designed to be a machine independent timer) */
/* Step1: Run DEMO3.EXE under DOS */
/* -------------------------------------------------------------------------------------- */
#include "PIO.H"
#define A1_8259 0x20
#define A2_8259 0xA0
static void interrupt irq_service();
void pio_da16_c0(char cConfig, char cLow, char cHigh);
void pio_da16_c1(char cConfig, char cLow, char cHigh);
void pio_da16_c2(char cConfig, char cLow, char cHigh);
void init_int1_high();
WORD wBase,wIrq;
int COUNT_L,COUNT_H,irqmask,now_int_state;
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) DEMO3 Interrupt (1Hz) test");
init_int1_high();
/* interrupt initialize, INT1 is high now */
COUNT_L=0;COUNT_H=0;
printf("\n\n*** Show the count of Low_pulse ***\n");
for (;;)
{
gotoxy(1,10);
printf("\nINT count = %d",COUNT_L);
if (kbhit()!=0) break;
}
outportb(wBase+5,0);
/* disable all interrupt */
PIO_DriverClose();
}
/* Use INT_CHAN_1 as internal interrupt signal */
void init_int1_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 )
64