Beispiel #1
0
            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));
                }
            }
Beispiel #2
0
        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));
            }
        }
Beispiel #3
0
        public void SelectDiffrentialChannelPlusMinus(CHANNEL ChannelInPlus, CHANNEL ChannelInMinus, bool Enable)
        {
            byte Prehumble = 0x80;
            byte SG = 0;
            byte ODD_SIGN = 0;
            byte A2, A1, A0;
            byte dataToWrite = 0;
            byte enable      = (byte)(Enable == true ? 0x20 : 0);

            Tuple <CHANNEL, CHANNEL> t = new Tuple <CHANNEL, CHANNEL>(ChannelInPlus, ChannelInMinus);

            SG       = m_diffMuxPlusMinus[t].Item1;
            ODD_SIGN = m_diffMuxPlusMinus[t].Item2;
            A2       = m_diffMuxPlusMinus[t].Item3;
            A1       = m_diffMuxPlusMinus[t].Item4;
            A0       = m_diffMuxPlusMinus[t].Item5;

            dataToWrite = (byte)(Prehumble | enable | SG << 4 | ODD_SIGN << 3 | A2 << 2 | A1 << 1 | A0);

            //see table here:  http://www.analog.com/media/en/technical-documentation/data-sheets/2497fb.pdf

            m_i2c.Write(m_slaveAddress, dataToWrite);
        }