WinSystems EBC-LP Operation Manual page 75

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

Advertisement

/* Adjust the bit_number to 0 to 47 numbering */
--bit_number;
/* Calculate the I/O port address based on the updated bit_number */
port = (bit_number / 8) + base_port;
/* Get the current contents of the port */
val = inportb(port);
/* Get just the bit we specified */
val = val & (1 << (bit_number % 8));
/* Adjust the return for a 0 or 1 value */
if(val)
return 1;
return 0;
}
/*===========================================================================
*
*
*
* This function takes two arguments :
*
*
*
bit_number :
*
*
val
:
The setting for the specified bit, either 1 or 0.
*
*
This function sets the specified I/O pin to either high or low as dictated
*
by the val argument. A non zero value for val sets the bit.
*
*===========================================================================*/
void write_bit(int bit_number, int val)
{
unsigned port;
unsigned temp;
unsigned mask;
/* Adjust bit_number for 0 based numbering */
--bit_number;
/* Calculate the I/O address of the port based on the bit number */
port = (bit_number / 8) + base_port;
/* Use the image value to avoid having to read the port first. */
temp = port_images[bit_number / 8]; /* Get current value */
/* Calculate a bit mask for the specified bit */
WRITE_BIT
The I/O pin to access is specified by bit_number 1 to 48.

Advertisement

Table of Contents
loading

Table of Contents