writeWordReg method

void writeWordReg(
  1. int address,
  2. int register,
  3. int wordValue, [
  4. BitOrder order = BitOrder.msbLast,
])

Writes a wordValue to the register of the I2C device with the address and the bit order.

The bit order depends on the I2C device.

Implementation

void writeWordReg(int address, int register, int wordValue,
    [BitOrder order = BitOrder.msbLast]) {
  var data = <I2Cmsg>[];
  var array = <int>[];
  array.add(register);
  if (order == BitOrder.msbLast) {
    array.add(wordValue & 0xff);
    array.add(wordValue >> 8);
  } else {
    array.add(wordValue >> 8);
    array.add(wordValue & 0xff);
  }
  data.add(I2Cmsg.buffer(address, [], array));
  var result = transfer(data);
  result.dispose();
}