Skip to content

Commit

Permalink
fix(lp_i2c): Fixed a bug where LP I2C write got stuck
Browse files Browse the repository at this point in the history
This commit fixes a bug where an I2C write got stuck when using the
lp_core_i2c_master_write_read_device() API. This was because the LP I2C
HW was not programmed with an END condition and therefore did not know
the end of a transaction.

Closes: espressif#11958
  • Loading branch information
sudeep-mohanty authored and espressif-bot committed Aug 8, 2023
1 parent 4464599 commit 5b46ef3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions components/ulp/lp_core/lp_core/lp_core_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,9 @@ esp_err_t lp_core_i2c_master_write_read_device(i2c_port_t lp_i2c_num, uint16_t d
i2c_ll_write_txfifo(dev, &data_wr[data_idx], fifo_size);
lp_core_i2c_format_cmd(cmd_idx++, I2C_LL_CMD_WRITE, 0, LP_I2C_ACK, s_ack_check_en, fifo_size);

if (remaining_bytes) {
/* This means we have to send more than what can fit in the Tx FIFO. Insert an End command. */
lp_core_i2c_format_cmd(cmd_idx++, I2C_LL_CMD_END, 0, 0, 0, 0);
cmd_idx = 0;
}
/* Insert an End command to signal the end of the write transaction to the HW */
lp_core_i2c_format_cmd(cmd_idx++, I2C_LL_CMD_END, 0, 0, 0, 0);
cmd_idx = 0;

/* Initiate I2C transfer */
i2c_ll_update(dev);
Expand Down

0 comments on commit 5b46ef3

Please sign in to comment.