Skip to content

Commit 69bfd43

Browse files
erian747cfriedt
authored andcommitted
drivers: i2c_stm32_v2: fix assert in i2c event isr
For systems where the CPU / NVIC bus are considerably faster than the peripheral bus used for I2C, there is a risk that the isr handler returns before I2C controller had time to clear its interrupt status flags This would cause immediate re-entry to isr handler which begins read from ISR register. During time it take to re-enter and read from ISR register, flags had time to be cleared The isr handler expects that a flag is set, and in this case when its not, an assert is triggered The solution here is to make a dummy read from the ISR register before returning from isr handler, this forces CPU to wait as long as needed to ensure all writes to the I2C peripheral are completed Fixes issue #97904 Signed-off-by: Erik Andersson <[email protected]>
1 parent 70fe961 commit 69bfd43

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/i2c/i2c_ll_stm32_v2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ void i2c_stm32_event(const struct device *dev)
578578
__ASSERT_NO_MSG(0);
579579
}
580580

581+
/* Make a dummy read from ISR to ensure we don't return before
582+
* i2c controller had a chance to clear its interrupt flags due
583+
* to bus delays
584+
*/
585+
(void)LL_I2C_ReadReg(regs, ISR);
581586
return;
582587

583588
irq_xfer_completed:

0 commit comments

Comments
 (0)