From bdfa4d28cfbbc553ca2a3567af952fbe832ba56c Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 5 Jan 2020 07:45:10 +0100 Subject: [PATCH] machine/atsamd51: fix obvious bug in I2C code I2C uses a hardcoded peripheral instead of referring to a specific peripheral. In addition to that, it refers to the wrong SERCOM (SERCOM3), which isn't used on any of the atsamd51 boards for I2C. --- src/machine/machine_atsamd51.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_atsamd51.go b/src/machine/machine_atsamd51.go index 95850cbc..5408519f 100644 --- a/src/machine/machine_atsamd51.go +++ b/src/machine/machine_atsamd51.go @@ -1008,7 +1008,7 @@ func (i2c I2C) WriteByte(data byte) error { timeout := i2cTimeout for !i2c.Bus.INTFLAG.HasBits(sam.SERCOM_I2CM_INTFLAG_MB) { // check for bus error - if sam.SERCOM3_I2CM.STATUS.HasBits(sam.SERCOM_I2CM_STATUS_BUSERR) { + if i2c.Bus.STATUS.HasBits(sam.SERCOM_I2CM_STATUS_BUSERR) { return errors.New("I2C bus error") } timeout--