From cc1a95a489924119e3ab372a6d06645c6729e936 Mon Sep 17 00:00:00 2001 From: Yurii Soldak Date: Mon, 17 Jan 2022 10:29:48 +0100 Subject: [PATCH] nrf: fix race in i2c --- src/machine/machine_nrf.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/machine/machine_nrf.go b/src/machine/machine_nrf.go index 635e314b..d3a31fbc 100644 --- a/src/machine/machine_nrf.go +++ b/src/machine/machine_nrf.go @@ -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.