forked from espressif/esp-idf
fix(i2c): Use hardware fsm reset on esp32c6/h2/p4
This commit is contained in:
@@ -42,7 +42,7 @@ static const char *TAG = "i2c.master";
|
||||
|
||||
static esp_err_t s_i2c_master_clear_bus(i2c_bus_handle_t handle)
|
||||
{
|
||||
#if !SOC_I2C_SUPPORT_HW_FSM_RST
|
||||
#if !SOC_I2C_SUPPORT_HW_CLR_BUS
|
||||
const int scl_half_period = 5; // use standard 100kHz data rate
|
||||
int i = 0;
|
||||
gpio_set_direction(handle->scl_num, GPIO_MODE_OUTPUT_OD);
|
||||
@@ -83,6 +83,7 @@ static esp_err_t s_i2c_master_clear_bus(i2c_bus_handle_t handle)
|
||||
static esp_err_t s_i2c_hw_fsm_reset(i2c_master_bus_handle_t i2c_master)
|
||||
{
|
||||
i2c_hal_context_t *hal = &i2c_master->base->hal;
|
||||
#if !SOC_I2C_SUPPORT_HW_FSM_RST
|
||||
i2c_hal_timing_config_t timing_config;
|
||||
uint8_t filter_cfg;
|
||||
|
||||
@@ -99,6 +100,10 @@ static esp_err_t s_i2c_hw_fsm_reset(i2c_master_bus_handle_t i2c_master)
|
||||
i2c_ll_clear_intr_mask(hal->dev, I2C_LL_INTR_MASK);
|
||||
i2c_hal_set_timing_config(hal, &timing_config);
|
||||
i2c_ll_master_set_filter(hal->dev, filter_cfg);
|
||||
#else
|
||||
i2c_ll_master_fsm_rst(hal->dev);
|
||||
s_i2c_master_clear_bus(i2c_master->base);
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
@@ -535,6 +535,10 @@ config SOC_I2C_SUPPORT_SLAVE
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_I2C_SUPPORT_HW_FSM_RST
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_I2C_SUPPORT_HW_CLR_BUS
|
||||
bool
|
||||
default y
|
||||
|
@@ -230,7 +230,7 @@
|
||||
#define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */
|
||||
#define SOC_I2C_SUPPORT_SLAVE (1)
|
||||
|
||||
// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined.
|
||||
#define SOC_I2C_SUPPORT_HW_FSM_RST (1)
|
||||
#define SOC_I2C_SUPPORT_HW_CLR_BUS (1)
|
||||
|
||||
#define SOC_I2C_SUPPORT_XTAL (1)
|
||||
|
@@ -535,6 +535,10 @@ config SOC_I2C_SUPPORT_SLAVE
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_I2C_SUPPORT_HW_FSM_RST
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_I2C_SUPPORT_HW_CLR_BUS
|
||||
bool
|
||||
default y
|
||||
|
@@ -234,7 +234,7 @@
|
||||
#define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */
|
||||
#define SOC_I2C_SUPPORT_SLAVE (1)
|
||||
|
||||
// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined.
|
||||
#define SOC_I2C_SUPPORT_HW_FSM_RST (1)
|
||||
#define SOC_I2C_SUPPORT_HW_CLR_BUS (1)
|
||||
|
||||
#define SOC_I2C_SUPPORT_XTAL (1)
|
||||
|
@@ -519,6 +519,10 @@ config SOC_I2C_SUPPORT_SLAVE
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_I2C_SUPPORT_HW_FSM_RST
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_I2C_SUPPORT_HW_CLR_BUS
|
||||
bool
|
||||
default y
|
||||
|
@@ -244,7 +244,7 @@
|
||||
#define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */
|
||||
#define SOC_I2C_SUPPORT_SLAVE (1)
|
||||
|
||||
// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined.
|
||||
#define SOC_I2C_SUPPORT_HW_FSM_RST (1)
|
||||
#define SOC_I2C_SUPPORT_HW_CLR_BUS (1)
|
||||
|
||||
#define SOC_I2C_SUPPORT_XTAL (1)
|
||||
|
Reference in New Issue
Block a user