writeWordReg method
void
writeWordReg(
- int address,
- int register,
- int wordValue, [
- BitOrder order = BitOrder.msbLast,
- RegisterWidth width = RegisterWidth.bits8,
Writes a wordValue to the register of the I2C device with
the address and the bit order. The optional register
parameters bit width enables 16-bit register.
The bit order depends on the I2C device.
Implementation
void writeWordReg(int address, int register, int wordValue,
[BitOrder order = BitOrder.msbLast,
RegisterWidth width = RegisterWidth.bits8]) {
var data = <I2Cmsg>[];
var array = <int>[];
array.addAll(_adjustRegister(register, order, width));
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();
}