Skip to content

Commit 5e6e91e

Browse files
committed
machine,nrf528,i2c: fix multiple resume-stop on bus error
1 parent 3869f76 commit 5e6e91e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/machine/machine_nrf528xx.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ func (i2c *I2C) Tx(addr uint16, w, r []byte) (err error) {
7878
// Allow scheduler to run
7979
gosched()
8080

81-
// Handle errors by ensuring STOP sent on bus
82-
if i2c.Bus.EVENTS_ERROR.Get() != 0 {
81+
// Handle first occurrence of error by ensuring STOP sent on bus
82+
if err == nil && i2c.Bus.EVENTS_ERROR.Get() != 0 {
83+
err = twiCError(i2c.Bus.ERRORSRC.Get())
8384
if i2c.Bus.EVENTS_STOPPED.Get() == 0 {
8485
// STOP cannot be sent during SUSPEND
8586
i2c.Bus.TASKS_RESUME.Set(1)
8687
i2c.Bus.TASKS_STOP.Set(1)
8788
}
88-
err = twiCError(i2c.Bus.ERRORSRC.Get())
8989
}
9090
}
9191

0 commit comments

Comments
 (0)