/* 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;
}
/*===========================================================================
*
* WRITE_BIT
*
* This function takes two arguments :
*
*
* bit_number : The I/O pin to access is specified by bit_number 1 to 48.
*
* 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 */
Summary of Contents for EBC-LP
Page 68: ...APPENDIX C Mechanical Drawing...
Page 69: ......
Page 70: ......
Page 71: ...APPENDIX D WS16C48 I O Routines and Sample Program Listings...