fix(i2c): Use hardware fsm reset on esp32c6/h2/p4

This commit is contained in:
Cao Sen Miao 2024-01-03 16:49:12 +08:00
parent 90afc33cd8
commit 2291ded9a1
7 changed files with 20 additions and 3 deletions

View File

@ -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) 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; i2c_hal_context_t *hal = &i2c_master->base->hal;
#if !SOC_I2C_SUPPORT_HW_FSM_RST
i2c_hal_timing_config_t timing_config; i2c_hal_timing_config_t timing_config;
uint8_t filter_cfg; 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_ll_clear_intr_mask(hal->dev, I2C_LL_INTR_MASK);
i2c_hal_set_timing_config(hal, &timing_config); i2c_hal_set_timing_config(hal, &timing_config);
i2c_ll_master_set_filter(hal->dev, filter_cfg); 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; return ESP_OK;
} }

View File

@ -531,6 +531,10 @@ config SOC_I2C_SUPPORT_SLAVE
bool bool
default y default y
config SOC_I2C_SUPPORT_HW_FSM_RST
bool
default y
config SOC_I2C_SUPPORT_HW_CLR_BUS config SOC_I2C_SUPPORT_HW_CLR_BUS
bool bool
default y default y

View File

@ -237,7 +237,7 @@
#define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */ #define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */
#define SOC_I2C_SUPPORT_SLAVE (1) #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_HW_CLR_BUS (1)
#define SOC_I2C_SUPPORT_XTAL (1) #define SOC_I2C_SUPPORT_XTAL (1)

View File

@ -535,6 +535,10 @@ config SOC_I2C_SUPPORT_SLAVE
bool bool
default y default y
config SOC_I2C_SUPPORT_HW_FSM_RST
bool
default y
config SOC_I2C_SUPPORT_HW_CLR_BUS config SOC_I2C_SUPPORT_HW_CLR_BUS
bool bool
default y default y

View File

@ -241,7 +241,7 @@
#define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */ #define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */
#define SOC_I2C_SUPPORT_SLAVE (1) #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_HW_CLR_BUS (1)
#define SOC_I2C_SUPPORT_XTAL (1) #define SOC_I2C_SUPPORT_XTAL (1)

View File

@ -479,6 +479,10 @@ config SOC_I2C_SUPPORT_SLAVE
bool bool
default y default y
config SOC_I2C_SUPPORT_HW_FSM_RST
bool
default y
config SOC_I2C_SUPPORT_HW_CLR_BUS config SOC_I2C_SUPPORT_HW_CLR_BUS
bool bool
default y default y

View File

@ -246,7 +246,7 @@
#define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */ #define SOC_I2C_CMD_REG_NUM (8) /*!< Number of I2C command registers */
#define SOC_I2C_SUPPORT_SLAVE (1) #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_HW_CLR_BUS (1)
#define SOC_I2C_SUPPORT_XTAL (1) #define SOC_I2C_SUPPORT_XTAL (1)