Skip to content

Commit

Permalink
write config register in little endian
Browse files Browse the repository at this point in the history
  • Loading branch information
pauleyj authored and deadprogram committed Jun 15, 2017
1 parent 8f8a889 commit 5f2bb18
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/i2c/ina3221_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)})
}

0 comments on commit 5f2bb18

Please sign in to comment.