nrf: fix race in i2c

This commit is contained in:
Yurii Soldak
2022-01-17 10:29:48 +01:00
committed by Ron Evans
parent 431e223803
commit cc1a95a489
+4 -1
View File
@@ -1,3 +1,4 @@
//go:build nrf
// +build nrf
package machine
@@ -284,7 +285,9 @@ func (i2c *I2C) Tx(addr uint16, w, r []byte) (err error) {
// To trigger stop task when last byte is received, set before resume task.
i2c.Bus.SHORTS.Set(nrf.TWI_SHORTS_BB_STOP)
}
i2c.Bus.TASKS_RESUME.Set(1) // re-start transmission for reading
if i > 0 {
i2c.Bus.TASKS_RESUME.Set(1) // re-start transmission for reading
}
if r[i], err = i2c.readByte(); err != nil {
// goto/break are practically equivalent here,
// but goto makes this more easily understandable for maintenance.