raspberrypi/I2CTarget: Fixed bug where I2C starts were seen as restarts.#10474
Open
MarkEbrahim wants to merge 1 commit intoadafruit:mainfrom
Open
raspberrypi/I2CTarget: Fixed bug where I2C starts were seen as restarts.#10474MarkEbrahim wants to merge 1 commit intoadafruit:mainfrom
MarkEbrahim wants to merge 1 commit intoadafruit:mainfrom
Conversation
The Rasperry Pi Pico, based on the RP2040, has a register that maintains the status of I2C interrupt flags called IC_INTR_STAT. The bits of this register are set by hardware and cleared by software. Before this commit, the I2CTarget library did not clear the restart bit (R_RESTART_DET) in this register after an I2C transaction ended, causing the is_restart field of the i2ctarget_i2c_target_request_obj_t struct to always be true after the first I2C transaction. This commit causes the restart and stop bits to get cleared when the I2C transaction ends. Signed-off-by: Amaar Ebrahim <amaaraebrahim@gmail.com>
tannewt
requested changes
Jul 14, 2025
Member
tannewt
left a comment
There was a problem hiding this comment.
Thank you for the fix! One request before we merge it.
Comment on lines
+129
to
+137
| // Interrupt bits must be cleared by software. Clear the STOP and | ||
| // RESTART interrupt bits after an I2C transaction finishes. | ||
| if (self->peripheral->hw->raw_intr_stat & I2C_IC_INTR_STAT_R_STOP_DET_BITS) { | ||
| self->peripheral->hw->clr_stop_det; | ||
| self->peripheral->hw->clr_restart_det; | ||
| return 1; | ||
| } else { | ||
| return 0; | ||
| } |
Member
There was a problem hiding this comment.
Please move this into is_addressed. There is no need for a separate function because it is used in one place and the return value is ignored.
Collaborator
There was a problem hiding this comment.
Hi @AmaarEbrahim are you able to address this? It would be good to get this fixed for the 10.0.0 release. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Rasperry Pi Pico, based on the RP2040, has a register that maintains the status of I2C interrupt flags called IC_INTR_STAT. The bits of this register are set by hardware and cleared by software. Before this commit, the I2CTarget library did not clear the restart bit (R_RESTART_DET) in this register after an I2C transaction ended, causing the is_restart field of the i2ctarget_i2c_target_request_obj_t struct to always be true after the first I2C transaction that involved a restart. This commit causes the restart and stop bits to get cleared when the I2C transaction ends.