i2c iface refactor: Resolve 559

This commit is contained in:
soypat
2023-05-28 18:03:19 -03:00
committed by Ron Evans
parent e20c6d05f8
commit e6f82fad2e
37 changed files with 313 additions and 247 deletions
+15
View File
@@ -0,0 +1,15 @@
package legacy
import "tinygo.org/x/drivers"
type I2C struct {
i2c drivers.I2C
}
func ReadRegister(i2c drivers.I2C, addr uint8, reg uint8, buf []byte) error {
return i2c.Tx(uint16(addr), []byte{reg}, buf)
}
func WriteRegister(i2c drivers.I2C, addr uint8, reg uint8, buf []byte) error {
return i2c.Tx(uint16(addr), append([]byte{reg}, buf...), nil)
}