ushort GetCommandRegister() { try { byte[] receiveBuffer = new byte[2]; m_i2c.Write(m_slaveAddress, AD7291_REG_COMMAND); receiveBuffer[0] = m_i2c.Read(m_slaveAddress); receiveBuffer[1] = m_i2c.Read(m_slaveAddress); ushort registerValue = (ushort)((receiveBuffer[0] << 8) + receiveBuffer[1]); return(registerValue); } catch (Exception err) { throw (new SystemException(err.Message)); } }
byte retrievePortData(byte reg, byte port) { try { if (port > 5) { throw (new SystemException("Invalid port number for PCA9505")); } byte data = (byte)((reg + port) | PCA9505_AI_OFF); m_i2c.Write(m_slaveAddress, data); data = m_i2c.Read(m_slaveAddress); return(data); } catch (Exception err) { throw (new SystemException(err.Message)); } }
byte [] Read24Bit() { byte [] data = { 0, 0, 0 }; m_i2c.Read(data, 0, 3); return(data); }