Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisErnst authored Jul 21, 2024
1 parent ccfc7db commit 6e5580d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cores/arduino/SERCOM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ bool SERCOM::startTransmissionWIRE(uint8_t address, SercomWireReadWriteFlag flag
// Wait transmission complete

// If certain errors occur, the MB bit may never be set (RFTM: SAMD21 sec:28.10.6; SAMD51 sec:36.10.7).
// There are additional errors that can occur (including BUSERR) that are rolled up in INTFLAG.ERROR
// The data transfer errors that can occur (including BUSERR) are all
// rolled up into INTFLAG.bit.ERROR from STATUS.reg
if (sercom->I2CM.INTFLAG.bit.ERROR) {
return false;
}
Expand Down Expand Up @@ -605,9 +606,10 @@ bool SERCOM::sendDataMasterWIRE(uint8_t data)
//Wait transmission successful
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.
// There are additional errors that can occur (including BUSERR) that are rolled up in INTFLAG.ERROR
// If a data transfer error occurs, the MB bit may never be set.
// Check the error bit and bail if it's set.
// The data transfer errors that can occur (including BUSERR) are all
// rolled up into INTFLAG.bit.ERROR from STATUS.reg
if (sercom->I2CM.INTFLAG.bit.ERROR) {
return false;
}
Expand Down Expand Up @@ -715,7 +717,7 @@ uint8_t SERCOM::readDataWIRE( void )
// A variety of errors in the STATUS register can set the ERROR bit in the INTFLAG register
// In that case, send a stop condition and return false.
// readDataWIRE should really be able to indicate an error (which would never be used
// because the readDataWIRE caller should have checked availableWIRE() first and timed it
// because the readDataWIRE callers (in Wire.cpp) should have checked availableWIRE() first and timed it
// out if the data never showed up
if (sercom->I2CM.INTFLAG.bit.ERROR || sercom->I2CM.INTFLAG.bit.MB) {
sercom->I2CM.CTRLB.bit.CMD = 3; // Stop condition
Expand Down

0 comments on commit 6e5580d

Please sign in to comment.