public bool Write(XI2CDevice.Configuration configuration, byte[] data) { _device.Config = configuration; XI2CDevice.I2CWriteTransaction transaction = XI2CDevice.CreateWriteTransaction(data); int transferred = _device.Execute(new XI2CDevice.I2CTransaction[] { transaction }, _writeTimeout); return(transferred == data.Length); }
public int ReadRegister(XI2CDevice.Configuration configuration, byte register, byte[] data, int length) { _device.Config = configuration; byte[] tmp = new byte[length]; XI2CDevice.I2CWriteTransaction write = XI2CDevice.CreateWriteTransaction(new byte[] { register }); XI2CDevice.I2CReadTransaction read = XI2CDevice.CreateReadTransaction(tmp); int transferred = _device.Execute(new XI2CDevice.I2CTransaction[] { write, read }, _readTimeout); if (transferred == (length + 1)) { Array.Copy(tmp, data, transferred - 1); return(transferred - 1); } return(-1); }