The function, Is_PPIO(), tests whether or not the PPIO is connected to the parallel port and functioning properly. This function should only be used if it is safe to toggle the state of the digital outputs.
int Is_PPIO (void)
{
unsigned int old_value; int status = 0x00;
/* Store the state of the digital outputs */ old_value = inp( Base_Address );
/* Check upper four digital outputs */
Output_Byte = 0xA0;
outp( Base_Address, Output_Byte );
Input_Byte = inp( Status_Address ) & 0xF0;
if( (Input_Byte & Output_Byte) == Output_Byte )
{
Output_Byte = 0x50;
outp( Base_Address, Output_Byte );
Input_Byte = inp( Status_Address ) & 0xF0;
if( (Input_Byte & Output_Byte) == Output_Byte )
{
status = 0x02;
}
}
/* Check lower four digital outputs */
Output_Byte = 0x0A;
outp( Base_Address, Output_Byte );
Input_Byte = inp( Control_Address ) & 0x0F;
if( (Input_Byte & Output_Byte) == Output_Byte )
{
Output_Byte = 0x05;
outp( Base_Address, Output_Byte );
24 | PPIO2899 Manual |
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph