public I2CHelper(I2cPeripheral device) { _device = device; _readTransaction = I2cPeripheral.CreateReadTransaction(_readWriteIndividualValueBuffer); _writeTransaction = I2cPeripheral.CreateWriteTransaction(_addressWriteIndividualValueBuffer); _writeUshortTransaction = I2cPeripheral.CreateWriteTransaction(_ushortWriteValueBuffer); _readTransactions = new[] { _readTransaction }; _writeTransactions = new[] { _writeTransaction }; _writeUshortTransactions = new[] { _writeUshortTransaction }; }
public byte[] ReadRegisters(byte registerAddress, ushort length) { _readWriteIndividualValueBuffer[0] = registerAddress; byte[] registerReadBuffer = new byte[length]; var registerReadTransaction = I2cPeripheral.CreateReadTransaction(registerReadBuffer); var readRegistersTransactions = new[] { _readTransaction, registerReadTransaction }; _device.Execute(readRegistersTransactions, 1000); return(registerReadBuffer); }