#include "ip470.h" /* {+D} SYSTEM: Acromag I/O Board MODULE NAME: isr_470.c - interrupt handler VERSION: A CREATION DATE: 10/30/95 CODED BY: FM ABSTRACT: These routines perform interrupt exception handling for interrupts on the IP470 I/O board. CALLING SEQUENCE: This subroutine runs as a result of an interrupt occuring. MODULE TYPE: I/O RESOURCES: SYSTEM RESOURCES: MODULES CALLED: REVISIONS: DATE BY PURPOSE -------- ---- ------------------------------------------------ {-D} */ /* MODULES FUNCTIONAL DETAILS: For level operation, each input bit must be connected to a switch input. The polarity of input bits is controlled in nibbles by a single bit in the Event Control Register. If this bit is a '1' positive edeges are sensed. If this bit is a '0' negative edeges are sensed. Each time an input changes to the state programmed into the sense register an interrupt is generated. */ void isr_470(void* pData) { /* Local data areas */ struct handler_data* hData; /* Interrupt handler structure */ struct cblk470* cblk; /* configuration block */ int i; /* loop control */ byte saved_bank; /* saved bank value */ byte i_stat; /* interrupt status */ byte p_mask; /* port interrupt bit mask */ /* Entry point of routine: */ hData = (struct handler_data*)pData; cblk = (struct cblk470*)hData->hd_ptr; saved_bank = bank_select(BANK1, cblk); /* set & save bank select */ i_stat = input_byte(&cblk->brd_ptr->port[6].b_select); /* interrupt status */ for(i = 0; i < 6; i++) /* check ports 0-5 for an interrupt pending */ { p_mask = ( 1 << i); /* form port interrupt bit mask */ if((p_mask & i_stat) != 0) /* port with interrupt pending? */ { cblk->event_status[i] |= input_byte(&cblk->brd_ptr->port[i].b_select); /* interrupt sense */ /* write 0s to clear the interrupting bits */ output_byte(&cblk->brd_ptr->port[i].b_select,(~(cblk->event_status[i]))); /* write 0 to clear the interrupting bit */ /* User code can be added here to complete the interrupt service routine Example: user_function(); */ output_byte(&cblk->brd_ptr->port[i].b_select, 0xFF); /* re-enable sense inputs */ } } bank_select(saved_bank, cblk); /* restore bank select */ } /* {+D} SYSTEM: Library Software MODULE NAME: bank_select - select bank on 470 board VERSION: A CREATION DATE: 10/18/95 CODED BY: FJM ABSTRACT: This module is used to select register banks on the IP470 board. CALLING SEQUENCE: old_bank = bank_select(new_bank, c_blk); where: cblk (pointer to structure) Pointer to the configuration block structure. new_bank (byte) New bank number 00, 01, 10 only old_bank (byte) Old bank number 00, 01, 10 only MODULE TYPE: void I/O RESOURCES: SYSTEM RESOURCES: MODULES CALLED: REVISIONS: DATE BY PURPOSE ------- ---- ------------------------------------------------ {-D} */ /* MODULES FUNCTIONAL DETAILS: This module is used to select register banks on the IP470 board. */ byte bank_select(new_bank, c_blk) byte new_bank; struct cblk470 *c_blk; { /* declare local storage */ byte old_bank; /* old bank number */ byte bank_bits; /* bank select info */ /* ENTRY POINT OF ROUTINE: */ bank_bits = input_byte(&c_blk->brd_ptr->port[7].b_select); /* get current */ old_bank = ((bank_bits & 0xC0) >> 6);/* isolate bank select bits */ if(old_bank == new_bank) /* same bank ? */ return(old_bank); /* no need to change bits */ if(old_bank == BANK1) /* special treatment required ? */ bank_bits = c_blk->ev_control[1]; /* yes must use ev_control bits */ bank_bits &= 0x3F; /* save all but bank select bits */ bank_bits |= (new_bank << 6); /* OR in new bank bits */ output_byte(&c_blk->brd_ptr->port[7].b_select, bank_bits); return(old_bank); }