Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PeriphDrivers): Issue #1293: MAX32670 I2C Driver causes a Double-Read #1359

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dnguye14-adi
Copy link

Description

Add more while-loop to wait until the I2C bus is not busy. They fix the double-read issue as well as the issue of hang due to quick transaction.

@Brandon-Hurst
Copy link
Contributor

Hello, as I mentioned in the issue #1293, I recommend changing the first while loop to an if statement. This will prevent the possibility of infinite loops if the I2C peripheral is busy / hanging. Returning an error indicating the I2C controller is busy is sufficient in this case, and a while loop should not be needed. I tested this as well and left screenshots in the issue linked.

I would propose changing this:

while(i2c->status & MXC_F_I2C_REVA_STATUS_BUSY) {}
// Wait until last transaction finished and bus ready

to this:

// If there is an active transaction, return a BUSY error
if (i2c->status & MXC_F_I2C_REVA_STATUS_BUSY) {
    return E_BUSY;
}

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