WinSystems EBC-LP Operation Manual page 74

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

Advertisement

*
*
This function initializes all I/O pins for input, disables all interrupt
*
sensing, and sets the image values.
*
*===========================================================================*/
void init_io(unsigned io_address)
{
int x;
/* Save the specified address for later use */
base_port = io_address;
/* Clear all of the I/O ports. This also makes them inputs */
for(x=0; x < 7; x++)
outportb(base_port+x, 0);
/* Clear our image values as well */
for(x=0; x < 6; x++)
port_images[x] = 0;
/* Set page 2 access, for interrupt enables */
outportb(base_port+7,0x80);
/* Clear all interrupt enables */
outportb(base_port+8,0);
outportb(base_port+9,0);
outportb(base_port+0x0a,0);
/* Restore normal page 0 register access */
outportb(base_port+7,0);
}
/*===========================================================================
*
*
*
*
*
This function takes a single argument :
*
*
*
bit_number
*
*
*
return value : The current state of the specified bit, 1 or 0.
*
*
This function returns the state of the current I/O pin specified by
*
the argument bit_number.
*
*===========================================================================*/
int read_bit(int bit_number)
{
unsigned port;
int val;
READ_BIT
:
The integer argument specifies the bit number to read.
Valid arguments are from 1 to 48.

Advertisement

Table of Contents
loading

Table of Contents