tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/internal/legacy/i2clegacy.go (about) 1 package legacy 2 3 import "tinygo.org/x/drivers" 4 5 func ReadRegister(bus drivers.I2C, addr uint8, reg uint8, data []byte) error { 6 return bus.Tx(uint16(addr), []byte{reg}, data) 7 } 8 9 func WriteRegister(bus drivers.I2C, addr uint8, reg uint8, data []byte) error { 10 buf := make([]uint8, len(data)+1) 11 buf[0] = reg 12 copy(buf[1:], data) 13 return bus.Tx(uint16(addr), buf, nil) 14 }