From 5f2bb180ee7d880b8742eb755a3dda22e61e19b6 Mon Sep 17 00:00:00 2001 From: John Pauley Date: Wed, 10 May 2017 18:20:35 -0400 Subject: [PATCH] write config register in little endian --- drivers/i2c/ina3221_driver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/ina3221_driver.go b/drivers/i2c/ina3221_driver.go index 4a12f0a8..e850b452 100644 --- a/drivers/i2c/ina3221_driver.go +++ b/drivers/i2c/ina3221_driver.go @@ -193,7 +193,7 @@ func (i *INA3221Driver) readWordFromRegister(reg uint8) (uint16, error) { return 0, err } - return uint16((val << 8) | ((val >> 8) & 0xFF)), nil + return uint16((val << 8) | ((val >> 8) & 0x00FF)), nil } // initialize initializes the INA3221 device @@ -208,5 +208,5 @@ func (i *INA3221Driver) initialize() error { ina3221ConfigMode1 | ina3221ConfigMode0 - return i.connection.WriteWordData(ina3221RegConfig, config) + return i.connection.WriteBlockData(ina3221RegConfig, []byte{byte(config >> 8), byte(config & 0x00FF)}) }