4. Using the I/O Address Map
36
CNT16-8(FIT)GY,
CNT16-8L(FIT)GY
int
i;
for (i = 0; i < CH; i++) {
printf("%dch %04XH, ", i, CountData.Whole[i].count );
}
printf("interrupt count = %03d, status = %02X\n", intcnt, (int)intstatus);
}
/* ------ restore vector -----------------------------------------------------
*/
void
ResVect( void )
{
_disable();
/* disable */
if ( IrqLevel > IRQ7 ) {
/* restore IMR */
outp( 0x21, OrgMasterImr );
outp( 0xa1, OrgSlaveImr );
}
else
outp( 0x21, OrgMasterImr );
_dos_setvect( IntVector[IrqLevel], OrgVect );
/* restore orgvect */
_enable();
/* enable */
}
/* ----- interrupt handler ---------------------------------------------------
*/
void
_interrupt _far inthandler( void )
{
_enable();
/* enable */
+;
/* count interrupt */
outp( ADR+0x10, 0x12 );
/* status sence */
intstatus = (unsigned char)inp(ADR+0x11);
outp( ADR+0x10, 0x12 );
/* sense reset */
outp( ADR+0x11, 0xff );
_disable();
/* disable */
if ( IrqLevel > IRQ7 ) {
/* EOI */
outp( 0xa0, 0x20 );
outp( 0xa0, 0x0b );
if ( !inp( 0xa0 ) ) {
outp( 0x20, 0x20 );
}
}
else
{
outp( 0x20, 0x20 );
}
}
/* ------ main --------------------------------------------------------------
*/
void main(
void
)
{
unsigned char i;
ChgVect();
/* change vector */
for (i = 0; i < CH; i++) {
CountData.Whole[i].count = 0x0000;
/* count data */
Initialize(i);
/* initialize */
}
outp( ADR+0x2, IntEnable[IrqLevel] );
/* interrupt level */