From 11dbf858a761f16dd74cb5b4b9a8931c5703b1a0 Mon Sep 17 00:00:00 2001 From: Ag Primatic Date: Wed, 30 Dec 2020 10:19:33 -0500 Subject: [PATCH] Update SERCOM.cpp Added check for ARBLOST in sendDataMasterWIRE so misbehaving I2C slaves don't cause the Zero to get stuck in an endless loop. --- cores/arduino/SERCOM.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/arduino/SERCOM.cpp b/cores/arduino/SERCOM.cpp index b9fbf05b9..03ecea7ea 100644 --- a/cores/arduino/SERCOM.cpp +++ b/cores/arduino/SERCOM.cpp @@ -568,8 +568,8 @@ bool SERCOM::sendDataMasterWIRE(uint8_t data) while(!sercom->I2CM.INTFLAG.bit.MB) { // If a bus error occurs, the MB bit may never be set. - // Check the bus error bit and bail if it's set. - if (sercom->I2CM.STATUS.bit.BUSERR) { + // Check the bus error bit and ARBLOST bit and bail if either is set. + if (sercom->I2CM.STATUS.bit.BUSERR || sercom->I2CM.STATUS.bit.ARBLOST) { return false; } }