mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-19 14:14:00 +00:00
fix uses of legacy i2c WriteRegister calls
This commit is contained in:
@@ -159,7 +159,7 @@ func (r *i2cRegister) write(bus drivers.I2C, deviceAddress uint8, value uint16)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the register from the buffer over I2C
|
// 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)
|
// after successful I2C write, cache this value if the host register (if also readable)
|
||||||
// Note we cache the entire buffer without applying shift/mask
|
// Note we cache the entire buffer without applying shift/mask
|
||||||
if nil == err && r.host.attributes®_read != 0 {
|
if nil == err && r.host.attributes®_read != 0 {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ package lps22hb
|
|||||||
import (
|
import (
|
||||||
"machine"
|
"machine"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"tinygo.org/x/drivers/internal/legacy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Configure sets up the LPS22HB device for communication.
|
// Configure sets up the LPS22HB device for communication.
|
||||||
|
|||||||
+3
-2
@@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"tinygo.org/x/drivers"
|
"tinygo.org/x/drivers"
|
||||||
|
"tinygo.org/x/drivers/internal/legacy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Device wraps I2C or SPI connection.
|
// 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)
|
// tx sends data to the display (I2CBus implementation)
|
||||||
func (b *I2CBus) tx(data []byte, isCommand bool) {
|
func (b *I2CBus) tx(data []byte, isCommand bool) {
|
||||||
if isCommand {
|
if isCommand {
|
||||||
b.wire.WriteRegister(uint8(b.Address), 0x00, data)
|
legacy.WriteRegister(b.wire, uint8(b.Address), 0x00, data)
|
||||||
} else {
|
} else {
|
||||||
b.wire.WriteRegister(uint8(b.Address), 0x40, data)
|
legacy.WriteRegister(b.wire, uint8(b.Address), 0x40, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user