mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-12 10:53:43 +00:00
i2c iface refactor: Resolve 559
This commit is contained in:
+6
-3
@@ -4,7 +4,10 @@
|
||||
|
||||
package tmp102 // import "tinygo.org/x/drivers/tmp102"
|
||||
|
||||
import "tinygo.org/x/drivers"
|
||||
import (
|
||||
"tinygo.org/x/drivers"
|
||||
"tinygo.org/x/drivers/internal/legacy"
|
||||
)
|
||||
|
||||
// Device holds the already configured I2C bus and the address of the sensor.
|
||||
type Device struct {
|
||||
@@ -36,7 +39,7 @@ func (d *Device) Configure(cfg Config) {
|
||||
// Connected checks if the config register can be read and that the configuration is correct.
|
||||
func (d *Device) Connected() bool {
|
||||
configData := make([]byte, 2)
|
||||
err := d.bus.ReadRegister(d.address, RegConfiguration, configData)
|
||||
err := legacy.ReadRegister(d.bus, d.address, RegConfiguration, configData)
|
||||
// Check the reset configuration values.
|
||||
if err != nil || configData[0] != 0x60 || configData[1] != 0xA0 {
|
||||
return false
|
||||
@@ -50,7 +53,7 @@ func (d *Device) ReadTemperature() (temperature int32, err error) {
|
||||
|
||||
tmpData := make([]byte, 2)
|
||||
|
||||
err = d.bus.ReadRegister(d.address, RegTemperature, tmpData)
|
||||
err = legacy.ReadRegister(d.bus, d.address, RegTemperature, tmpData)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user