Skip to content

Commit 38e84d5

Browse files
committed
Merge branch 'fix/i2c_ci_esp32c5' into 'master'
test(i2c): Re-enable i2c test on esp32c5 Closes IDFCI-2895 See merge request espressif/esp-idf!39040
2 parents 764d722 + c758af7 commit 38e84d5

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

components/esp_driver_i2c/i2c_slave.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ esp_err_t i2c_slave_transmit(i2c_slave_dev_handle_t i2c_slave, const uint8_t *da
336336
ESP_RETURN_ON_FALSE((i2c_slave->fifo_mode == I2C_SLAVE_FIFO), ESP_ERR_NOT_SUPPORTED, TAG, "non-fifo mode is not supported in this API, please set access_ram_en to false");
337337
esp_err_t ret = ESP_OK;
338338
i2c_hal_context_t *hal = &i2c_slave->base->hal;
339+
#if CONFIG_IDF_TARGET_ESP32C5
340+
// Workaround for c5 digital bug. Please note that following code has no
341+
// functionality. It's just use for workaround the potential issue for avoiding
342+
// secondary transaction.
343+
i2c_ll_slave_enable_auto_start(hal->dev, true);
344+
i2c_ll_start_trans(hal->dev);
345+
i2c_ll_slave_enable_auto_start(hal->dev, false);
346+
#endif
339347
TickType_t wait_ticks = (xfer_timeout_ms == -1) ? portMAX_DELAY : pdMS_TO_TICKS(xfer_timeout_ms);
340348

341349
ESP_RETURN_ON_FALSE(xSemaphoreTake(i2c_slave->slv_tx_mux, wait_ticks) == pdTRUE, ESP_ERR_TIMEOUT, TAG, "transmit timeout");
@@ -358,6 +366,14 @@ esp_err_t i2c_slave_receive(i2c_slave_dev_handle_t i2c_slave, uint8_t *data, siz
358366
ESP_RETURN_ON_FALSE(esp_ptr_internal(data), ESP_ERR_INVALID_ARG, TAG, "buffer must locate in internal RAM if IRAM_SAFE is enabled");
359367
#endif
360368
i2c_hal_context_t *hal = &i2c_slave->base->hal;
369+
#if CONFIG_IDF_TARGET_ESP32C5
370+
// Workaround for c5 digital bug. Please note that following code has no
371+
// functionality. It's just use for workaround the potential issue for avoiding
372+
// secondary transaction.
373+
i2c_ll_slave_enable_auto_start(hal->dev, true);
374+
i2c_ll_start_trans(hal->dev);
375+
i2c_ll_slave_enable_auto_start(hal->dev, false);
376+
#endif
361377

362378
xSemaphoreTake(i2c_slave->slv_rx_mux, portMAX_DELAY);
363379
i2c_slave_receive_t *t = &i2c_slave->receive_desc;

components/esp_driver_i2c/i2c_slave_v2.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ IRAM_ATTR static void i2c_slave_isr_handler(void *arg)
188188
}
189189
#endif
190190
}
191+
#if CONFIG_IDF_TARGET_ESP32C5
192+
// Workaround for c5 digital bug. Please note that following code has no
193+
// functionality. It's just use for workaround the potential issue for avoiding
194+
// secondary transaction.
195+
i2c_ll_slave_enable_auto_start(hal->dev, true);
196+
i2c_ll_start_trans(hal->dev);
197+
i2c_ll_slave_enable_auto_start(hal->dev, false);
198+
#endif
191199
}
192200

193201
#if SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE

components/esp_driver_i2c/test_apps/i2c_test_apps/main/test_board.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ extern "C" {
2929
#if CONFIG_IDF_TARGET_ESP32P4
3030
#define LP_I2C_SCL_IO 4
3131
#define LP_I2C_SDA_IO 5
32+
#elif CONFIG_IDF_TARGET_ESP32C5
33+
#define LP_I2C_SCL_IO 3
34+
#define LP_I2C_SDA_IO 2
3235
#else
3336
#define LP_I2C_SCL_IO 7
3437
#define LP_I2C_SDA_IO 6

0 commit comments

Comments
 (0)