Skip to content

Commit 1d6b675

Browse files
kbidanihenrikbrixandersen
authored andcommitted
drivers: i2c: stm32: Fix STM32 I2C hang on read
ensure LL_I2C_TransmitData8() is always called when TXIS is set, even if read_processed() returns an error. This prevents the peripheral from clock-stretching indefinitely and blocking the I2C bus when the master reads from the slave. Signed-off-by: Khaoula Bidani <[email protected]>
1 parent 936876b commit 1d6b675

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/i2c/i2c_ll_stm32_v2.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,14 @@ static void i2c_stm32_slave_event(const struct device *dev)
343343
slave_cb = slave_cfg->callbacks;
344344

345345
if (LL_I2C_IsActiveFlag_TXIS(i2c)) {
346-
uint8_t val;
346+
uint8_t val = 0x00;
347347

348348
if (slave_cb->read_processed(slave_cfg, &val) < 0) {
349349
LOG_ERR("Error continuing reading");
350-
} else {
351-
LL_I2C_TransmitData8(i2c, val);
352350
}
351+
352+
LL_I2C_TransmitData8(i2c, val);
353+
353354
return;
354355
}
355356

0 commit comments

Comments
 (0)