8000 fix(PeriphDrivers): MSDK-1242: Fix false stop detection in I2C interrupt handler by Jacob-Scheiffler · Pull Request #765 · analogdevicesinc/msdk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(PeriphDrivers): MSDK-1242: Fix false stop detection in I2C interrupt handler #765

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

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions Libraries/PeriphDrivers/Source/I2C/i2c_reva.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,9 +1531,36 @@ void MXC_I2C_RevA_SlaveAsyncHandler(mxc_i2c_reva_regs_t *i2c, mxc_i2c_reva_slave
}
}

// Check if transaction completed or restart occurred
if (int_en[0] & MXC_F_I2C_REVA_INTFL0_DONE) {
if (tFlags & MXC_F_I2C_REVA_INTFL0_STOP) {
// Stop/NACK condition occurred, transaction complete
*retVal = E_NO_ERROR;

if (callback != NULL) {
callback(i2c, MXC_I2C_REVA_EVT_TRANS_COMP, retVal);
}

i2c->intfl0 = MXC_F_I2C_REVA_INTFL0_STOP;
int_en[0] = 0;
int_en[1] = 0;
AsyncRequests[MXC_I2C_GET_IDX((mxc_i2c_regs_t *)i2c)] = NULL;
} else if (tFlags & MXC_F_I2C_REVA_INTFL0_DONE) {
// Restart detected, re-arm address match interrupt
i2c->intfl0 = MXC_F_I2C_REVA_INTFL0_DONE;
int_en[0] = MXC_F_I2C_REVA_INTFL0_ADDR_MATCH;
}
}

// Check for address match interrupt
if (int_en[0] & MXC_F_I2C_REVA_INTFL0_ADDR_MATCH) {
if (tFlags & MXC_F_I2C_REVA_INTFL0_ADDR_MATCH) {
// Address match occurred, prepare for transaction
if (tFlags & MXC_F_I2C_REVA_INTFL0_STOP && !(tFlags & MXC_F_I2C_REVA_INTFL0_DONE)) {
// Clear stop flag if it was asserted in a previous transaction
i2c->intfl0 = MXC_F_I2C_REVA_INTFL0_STOP;
}

if (i2c->ctrl & MXC_F_I2C_REVA_CTRL_READ) {
// Read request received from the master
if (callback != NULL) {
Expand Down Expand Up @@ -1561,27 +1588,6 @@ void MXC_I2C_RevA_SlaveAsyncHandler(mxc_i2c_reva_regs_t *i2c, mxc_i2c_reva_slave
}
}
}

// Check if transaction completed or restart occurred
if (int_en[0] & MXC_F_I2C_REVA_INTFL0_DONE) {
if (tFlags & MXC_F_I2C_REVA_INTFL0_STOP) {
// Stop/NACK condition occurred, transaction complete
*retVal = E_NO_ERROR;

if (callback != NULL) {
callback(i2c, MXC_I2C_REVA_EVT_TRANS_COMP, retVal);
}

i2c->intfl0 = MXC_F_I2C_REVA_INTFL0_STOP;
int_en[0] = 0;
int_en[1] = 0;
AsyncRequests[MXC_I2C_GET_IDX((mxc_i2c_regs_t *)i2c)] = NULL;
} else if (tFlags & MXC_F_I2C_REVA_INTFL0_DONE) {
// Restart detected, re-arm address match interrupt
i2c->intfl0 = MXC_F_I2C_REVA_INTFL0_DONE;
int_en[0] = MXC_F_I2C_REVA_INTFL0_ADDR_MATCH;
}
}
}

void MXC_I2C_RevA_AsyncHandler(mxc_i2c_reva_regs_t *i2c, uint32_t interruptCheck)
Expand Down
0