Merge branch 'bugfix/i2c_master_stretch_to' into 'master'

fix(i2c_master): Fix an I2C issue that slave streth happen but master timeout seems not work

Closes IDFGH-13191 and IDFGH-13508

See merge request espressif/esp-idf!33014
This commit is contained in:
C.S.M
2024-08-29 17:29:30 +08:00
9 changed files with 62 additions and 51 deletions

View File

@@ -967,7 +967,8 @@ static inline bool i2c_ll_master_is_cmd_done(i2c_dev_t *hw, int cmd_idx)
static inline uint32_t i2c_ll_calculate_timeout_us_to_reg_val(uint32_t src_clk_hz, uint32_t timeout_us)
{
uint32_t clk_cycle_num_per_us = src_clk_hz / (1 * 1000 * 1000);
return 31 - __builtin_clz(clk_cycle_num_per_us * timeout_us);
// round up to an integer
return 32 - __builtin_clz(clk_cycle_num_per_us * timeout_us);
}
//////////////////////////////////////////Deprecated Functions//////////////////////////////////////////////////////////