mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-03 16:41:44 +01:00 
			
		
		
		
	Merge branch 'feature/support_i2c_timeout' into 'master'
feature(i2c_master): Add a parameter for config the scl await value See merge request espressif/esp-idf!29787
This commit is contained in:
		@@ -74,6 +74,7 @@ typedef enum {
 | 
			
		||||
#define I2C_LL_SLAVE_RX_EVENT_INTR  (I2C_TRANS_COMPLETE_INT_ENA_M | I2C_RXFIFO_WM_INT_ENA_M | I2C_SLAVE_STRETCH_INT_ENA_M)
 | 
			
		||||
#define I2C_LL_SLAVE_TX_EVENT_INTR  (I2C_TXFIFO_WM_INT_ENA_M)
 | 
			
		||||
#define I2C_LL_RESET_SLV_SCL_PULSE_NUM_DEFAULT   (9)
 | 
			
		||||
#define I2C_LL_SCL_WAIT_US_VAL_DEFAULT   (2500)  // Approximate value for SCL timeout regs (in us).
 | 
			
		||||
 | 
			
		||||
// I2C sleep retention module
 | 
			
		||||
#define I2C_SLEEP_RETENTION_MODULE(i2c_num) ((i2c_num == 0) ? SLEEP_RETENTION_MODULE_I2C0 : SLEEP_RETENTION_MODULE_I2C1)
 | 
			
		||||
@@ -868,6 +869,19 @@ static inline bool i2c_ll_master_is_cmd_done(i2c_dev_t *hw, int cmd_idx)
 | 
			
		||||
    return hw->command[cmd_idx].command_done;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Calculate SCL timeout us to reg value
 | 
			
		||||
 *
 | 
			
		||||
 * @param timeout_us timeout value in us
 | 
			
		||||
 * @param src_clk_hz source clock frequency
 | 
			
		||||
 * @return uint32_t reg value
 | 
			
		||||
 */
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////Deprecated Functions//////////////////////////////////////////////////////////
 | 
			
		||||
/////////////////////////////The following functions are only used by the legacy driver/////////////////////////////////
 | 
			
		||||
/////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)//////////////////////////////
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user