WinSystems EBC-LP Operation Manual page 77

Small, high-performance, embeddable computer system on a single board
Table of Contents

Advertisement

*
*
polarity
: This specifies the polarity of the interrupt. A non-zero
*
argument enables rising-edge interrupt. A zero argument
*
enables the interrupt on the flling edge.
*
*
This function enables within the 16C48 an interrupt for the specified bit
*
at the specified polarity. This function does not setup the interrupt
*
controller, nor does it supply an interrupr handler.
*
*============================================================================*/
void enab_int(int bit_number, int polarity)
{
unsigned port;
unsigned temp;
unsigned mask;
/* Adjust for 0 based numbering */
--bit_number;
/* Calculate the I/O address based uppon the bit number */
port = (bit_number / 8) + base_port + 8;
/* Calculate a bit mask based on the specified bit number */
mask = (1 << (bit_number % 8));
/* Turn on page 2 access */
outportb(base_port+7,0x80);
/* Get the current state of the interrupt enable register */
temp = inportb(port);
/* Set the enable bit for our bit number */
temp = temp | mask;
/* Now update the interrupt enable register */
outportb(port,temp);
/* Turn on access to page 1 for polarity control */
outportb(base_port+7,0x40);
/* Get the current state of the polarity register */
temp = inportb(port);
/* Set the polarity according to the argument in the image value */
if(polarity)
temp = temp | mask;
else
temp = temp & ~mask;
/* Write out the new polarity value */
/* Get current polarity settings */
/* If the bit is to be set */

Advertisement

Table of Contents
loading

Table of Contents