-
Notifications
You must be signed in to change notification settings - Fork 82
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): Fix I2C DMA Issues When Slave Does Not ACK Address, Fix 1-length I2C DMA Transactions #1109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed the review notification last week.
/** | ||
* @brief Interrupt handler function for DMA0 | ||
* @details Used by some internal drivers that automatically assign DMA handlers. | ||
* This is equivalent to "MXC_DMA_Handler(MXC_DMA0);" | ||
*/ | ||
void MXC_DMA_DMA0_Handler(void); | ||
|
||
/** | ||
* @brief Interrupt handler function for DMA0 | ||
* @details Used by some internal drivers that automatically assign DMA handlers. | ||
* This is equivalent to "MXC_DMA_Handler(MXC_DMA1);" | ||
*/ | ||
void MXC_DMA_DMA1_Handler(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside of the precedent set when the DMA drivers were first set up... :(
@sihyung-maxim No worries, thanks for all your reviews. I'm spamming you recently :) |
Description
This PR fixes various I2C DMA issues that are caused by slaves that intentionally NACK their I2C address, such as the MS8607.
Fixes #987
Ex:
Previously,
MXC_I2C_MasterTransactionDMA
would send the read request and then immediately start reading from the I2C RX FIFO with DMA. If the slave NACKs that address, no further bytes will be sent. Therefore the DMA request will never complete and DMA callbacks will never be hit, all the while the master locks up and holds the SCL line low.Now, we wait to see if we got an ACK or a NACK immediately after we send the read request. If we get a NACK, we abort the transaction, issue a STOP signal, and pass the communication error along to the user's callback and the return code. This solves the master "lockup" and allows the user application to decide what to do from here, such as retry the transaction.
It also applies a logical fix that corrects issues with TX/RX transactions with a length of 1.
Tested with an MS8607 Adafruit module and MAX78002EVKIT
Test Code
Complete analyzer trace: gh-987-fixed.zip
Master issues the TX Command...
... Polls the device with an RX command that is NACK'd...
... Continues polling...
... Until an ACK is received. DMA unloads the data bytes successfully...
Checklist Before Requesting Review