Ejemplo n.º 1
0
        public double Read(Ltc2305Channels channelNumber = Ltc2305Channels.Channel0)
        {
            //  SendReceive(byte address, byte[] dataToWrite, byte numBytesToRead)
            byte[] data   = I2c.SendReceive(this.address, new byte[] { (byte)((byte)channelNumber | (byte)Ltc2305ConfigBits.UnipolarMode) }, 2);
            int    code   = data[1] | (data[0] << 8);
            double retVal = CodeToVoltage(code, 5.0, Ltc2305ConfigBits.UnipolarMode);

            return(retVal);
        }
Ejemplo n.º 2
0
        // SMBus functions
        // Key to symbols
        // ==============

        // S     (1 bit) : Start bit
        // P     (1 bit) : Stop bit
        // Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
        // A, NA (1 bit) : Accept and reverse accept bit.
        // Addr  (7 bits): I2C 7 bit address. Note that this can be expanded as usual to
        //        get a 10 bit I2C address.
        // Comm  (8 bits): Command byte, a data byte which often selects a register on
        //        the device.
        // Data  (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh
        //        for 16 bit data.
        // Count (8 bits): A data byte containing the length of a block operation.

        // [..]: Data sent by I2C device, as opposed to data sent by the host adapter.

        /// <summary>
        ///
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>

        public byte ReadByte()
        {
            // S Addr Rd [A] [Data] NA P
            byte[] data = I2c.SendReceive(this.address, new byte[] { }, 1);
            return(data[0]);
        }
Ejemplo n.º 3
0
 void expanderWrite(int _data)
 {
     //_I2C.Write((byte)_Addr, new byte[] {(byte)(_data | _backlightval) });
     _I2C.SendReceive((byte)_Addr, new byte[] { (byte)(_data | _backlightval) }, 0);
     Thread.Sleep(2);
 }