mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(i2c_master): Fix bug on esp32 that read one byte data fails
This commit is contained in:
@@ -251,6 +251,15 @@ static bool s_i2c_read_command(i2c_master_bus_handle_t i2c_master, i2c_operation
|
||||
}
|
||||
#else
|
||||
portENTER_CRITICAL_SAFE(&handle->spinlock);
|
||||
// If the read command work with ack_val, but no bytes to read, we skip
|
||||
// this command, and run next command directly.
|
||||
if (hw_cmd.ack_val == ACK_VAL) {
|
||||
if (i2c_operation->total_bytes == 0) {
|
||||
i2c_master->trans_idx++;
|
||||
hw_cmd = i2c_master->i2c_trans.ops[i2c_master->trans_idx].hw_cmd;
|
||||
i2c_master->i2c_trans.cmd_count--;
|
||||
}
|
||||
}
|
||||
i2c_ll_master_write_cmd_reg(hal->dev, hw_cmd, i2c_master->cmd_idx);
|
||||
i2c_ll_master_write_cmd_reg(hal->dev, hw_end_cmd, i2c_master->cmd_idx + 1);
|
||||
portEXIT_CRITICAL_SAFE(&handle->spinlock);
|
||||
|
||||
Reference in New Issue
Block a user