Merge branch 'fix/i2c_rx_fifo_drain_before_event' into 'master'

fix(i2c): fixed potential multi-core race in I2C read

Closes IDFGH-18239

See merge request espressif/esp-idf!52501
This commit is contained in:
morris
2026-09-14 10:55:51 +08:00

View File

@@ -805,14 +805,15 @@ static void i2c_master_isr_handler_default(void *arg)
i2c_master->trans_done = true;
i2c_master->event = I2C_EVENT_DONE;
}
if (i2c_master->event != I2C_EVENT_ALIVE) {
xQueueSendFromISR(i2c_master->event_queue, (void *)&i2c_master->event, &HPTaskAwoken);
}
if (i2c_master->contains_read == true) {
if (int_mask & I2C_LL_INTR_MST_COMPLETE || int_mask & I2C_LL_INTR_END_DETECT) {
i2c_isr_receive_handler(i2c_master);
}
}
/* Wait for the ISR to finish copying RX FIFO before notifying the waiter so the caller's buffer is complete */
if (i2c_master->event != I2C_EVENT_ALIVE) {
xQueueSendFromISR(i2c_master->event_queue, (void *)&i2c_master->event, &HPTaskAwoken);
}
if (i2c_master->async_trans) {
i2c_master_dev_handle_t i2c_dev = NULL;