/* ******************************************************************* This function reads the byte value of the specified port and returns the result in the variable pointer sent to the function. Valid ports are PORTA, PORTB, PORTCL and PORTCH. *********************************************************************** */ int DIn(int Port, int *Value) { int result; int BitData; switch (Port) { case PORTA: result = DBitIn(Port, 4, &BitData); printf("The value of BitData is --> %d.\n", BitData); if (BitData == 0) return(3); /* error - not configured for input */ break; case PORTB: result = DBitIn(Port, 1, &BitData); if (BitData == 0) return(3); /* error - not configured for input */ break; case PORTCL: result = DBitIn(Port, 0, &BitData); if (BitData == 0) return(3); /* error - not configured for input */ break; case PORTCH: result = DBitIn(Port, 3, &BitData); if (BitData == 0) return(3); /* error - not configured for input */ break; default: return (0); /* error - illegal port */ break; } *Value = inb(Port); /* read the port data */ return(0); /* no errors detected */ }