Skip to content

Conversation

@kaysievers
Copy link

Revert a part of ccfc7db. It breaks I2C communcation.

#376

Revert a part of ccfc7db. It breaks
I2C communcation.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR partially reverts a previous commit (ccfc7db) that broke I2C communication by changing error handling in the sendDataMasterWIRE function. The change reverts from checking the general INTFLAG.bit.ERROR flag back to checking only the specific STATUS.bit.BUSERR flag.

Key Changes:

  • Reverted error detection in sendDataMasterWIRE from INTFLAG.bit.ERROR to STATUS.bit.BUSERR to fix I2C communication issues reported in issue #376

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// 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) {
if (sercom->I2CM.STATUS.bit.BUSERR) {
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change creates an inconsistency in error handling. Other similar I2C wait loops in this file check INTFLAG.bit.ERROR (lines 565, 578, 716), which according to the comment on line 563-564 includes all data transfer errors "rolled up from STATUS.reg".

Checking only STATUS.bit.BUSERR here may miss other error conditions like arbitration loss (ARBLOST), bus errors, etc. While this may fix the immediate I2C communication issue mentioned in #376, consider whether:

  1. The same change should be applied to the other similar wait loops for consistency
  2. Or if there's a different underlying issue that should be addressed

The comment on lines 606-607 also says "data transfer error" (plural) but only one error type is now being checked.

Suggested change
if (sercom->I2CM.STATUS.bit.BUSERR) {
if (sercom->I2CM.INTFLAG.bit.ERROR) {

Copilot uses AI. Check for mistakes.
Comment on lines 606 to 607
// If a data transfer error occurs, the MB bit may never be set.
// Check the error bit and bail if it's set.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "If a data transfer error occurs" (suggesting multiple error types), but the code now only checks for BUSERR. Consider updating the comment to be more specific, e.g., "If a bus error occurs" or explain why only BUSERR is checked here while other similar functions check all errors via INTFLAG.bit.ERROR.

Copilot uses AI. Check for mistakes.
Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we don't receive feedback by author of #367. Maybe we can do sercom->I2CM.INTFLAG.bit.ERROR || sercom->I2CM.STATUS.bit.BUSERR though I think reverting is safer choice here. Thank you for your patient.

@hathach hathach merged commit 2917083 into adafruit:master Dec 5, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants