fix uses of legacy i2c WriteRegister calls

This commit is contained in:
Kenneth Bell
2023-08-07 22:10:52 +01:00
committed by Ron Evans
parent eef03917ab
commit 996f1b047f
3 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -159,7 +159,7 @@ func (r *i2cRegister) write(bus drivers.I2C, deviceAddress uint8, value uint16)
}
// Write the register from the buffer over I2C
err := bus.WriteRegister(deviceAddress, r.host.address, buf)
err := legacy.WriteRegister(bus, deviceAddress, r.host.address, buf)
// after successful I2C write, cache this value if the host register (if also readable)
// Note we cache the entire buffer without applying shift/mask
if nil == err && r.host.attributes&reg_read != 0 {
+2
View File
@@ -5,6 +5,8 @@ package lps22hb
import (
"machine"
"time"
"tinygo.org/x/drivers/internal/legacy"
)
// Configure sets up the LPS22HB device for communication.
+3 -2
View File
@@ -10,6 +10,7 @@ import (
"time"
"tinygo.org/x/drivers"
"tinygo.org/x/drivers/internal/legacy"
)
// Device wraps I2C or SPI connection.
@@ -277,9 +278,9 @@ func (d *Device) Tx(data []byte, isCommand bool) {
// tx sends data to the display (I2CBus implementation)
func (b *I2CBus) tx(data []byte, isCommand bool) {
if isCommand {
b.wire.WriteRegister(uint8(b.Address), 0x00, data)
legacy.WriteRegister(b.wire, uint8(b.Address), 0x00, data)
} else {
b.wire.WriteRegister(uint8(b.Address), 0x40, data)
legacy.WriteRegister(b.wire, uint8(b.Address), 0x40, data)
}
}