src/AduProtocol.c
/**
 * Gets the value of the specified port. Since the input ports are only 4 bits
 * (and hence have a range of 0 to 0x0f), a return value of 0xff can be safely
 * used to indicate a failure.
 *
 * @param[in] inputPortChar The character of the port designation
 *
 * @return Returns the value of the port on success, or 0xff on failure
 */
Gets the value of the specified port. Since the input ports are only 4 bits
(and hence have a range of 0 to 0x0f), a return value of 0xff can be safely
used to indicate a failure.

@param[in] inputPortChar The character of the port designation

@return Returns the value of the port on success, or 0xff on failure
Gets the value of the specified port . Since the input ports are only 4 bits ( and hence have a range of 0 to 0x0f ) a return value of 0xff can be safely used to indicate a failure . @param [ in ] inputPortChar The character of the port designation @return Returns the value of the port on success or 0xff on failure
static uint8_t GetInputPortValue(char inputPortChar)
{
    uint8_t ret = 0xff;
    enum InputPort inputPort = CharToInputPort(inputPortChar);
    if (inputPort == INPUT_PORT_UNDEFINED)
    {
        BoardDebugPrint("%s: Undefined port: %c\r\n", __func__, inputPortChar);
    }
    else
    {
        uint8_t combinedPortValue = BoardReadDigitalInputs();
        unsigned portShift = INPUT_PORT_A_SHIFT;
        unsigned portMask = INPUT_PORT_A_MASK;
        if (inputPort == INPUT_PORT_B)
        {
            portShift = INPUT_PORT_B_SHIFT;
            portMask = INPUT_PORT_B_MASK;
        }
        ret = (combinedPortValue & portMask) >> portShift;
    }
    return ret;
}
static uint8_t GetInputPortValue ( char inputPortChar ) { uint8_t ret = 0xff ; enum InputPort inputPort = CharToInputPort ( inputPortChar ) ; if ( inputPort == INPUT_PORT_UNDEFINED ) { BoardDebugPrint ( " \r \n " , __func__ , inputPortChar ) ; } else { uint8_t combinedPortValue = BoardReadDigitalInputs ( ) ; unsigned portShift = INPUT_PORT_A_SHIFT ; unsigned portMask = INPUT_PORT_A_MASK ; if ( inputPort == INPUT_PORT_B ) { portShift = INPUT_PORT_B_SHIFT ; portMask = INPUT_PORT_B_MASK ; } ret = ( combinedPortValue & portMask ) >> portShift ; } return ret ; }
Gets the value of the specified port.
Gets the value of the specified port .
// Determine the input port being requested // Isolate the value of the requested port