mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 12:53:29 +00:00
fix(i2c): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled
This commit is contained in:
@@ -211,9 +211,11 @@ esp_err_t i2c_release_bus_handle(i2c_bus_handle_t i2c_bus)
|
||||
if (i2c_bus->intr_handle) {
|
||||
ESP_RETURN_ON_ERROR(esp_intr_free(i2c_bus->intr_handle), TAG, "delete interrupt service failed");
|
||||
}
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (i2c_bus->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_delete(i2c_bus->pm_lock), TAG, "delete pm_lock failed");
|
||||
}
|
||||
#endif
|
||||
// Disable I2C module
|
||||
if (!i2c_bus->is_lp_i2c) {
|
||||
I2C_RCC_ATOMIC() {
|
||||
@@ -306,8 +308,7 @@ esp_err_t i2c_select_periph_clock(i2c_bus_handle_t handle, soc_module_clk_t clk_
|
||||
}
|
||||
|
||||
if (need_pm_lock) {
|
||||
sprintf(handle->pm_lock_name, "I2C_%d", handle->port_num); // e.g. PORT_0
|
||||
ret = esp_pm_lock_create(pm_lock_type, 0, handle->pm_lock_name, &handle->pm_lock);
|
||||
ret = esp_pm_lock_create(pm_lock_type, 0, i2c_periph_signal[handle->port_num].module_name, &handle->pm_lock);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "create pm lock failed");
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
@@ -617,9 +617,11 @@ static esp_err_t s_i2c_transaction_start(i2c_master_dev_handle_t i2c_dev, int xf
|
||||
ESP_RETURN_ON_ERROR(s_i2c_hw_fsm_reset(i2c_master, true), TAG, "reset hardware failed");
|
||||
}
|
||||
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (i2c_master->base->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_acquire(i2c_master->base->pm_lock), TAG, "acquire pm_lock failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
portENTER_CRITICAL(&i2c_master->base->spinlock);
|
||||
atomic_init(&i2c_master->trans_idx, 0);
|
||||
@@ -655,9 +657,11 @@ static esp_err_t s_i2c_transaction_start(i2c_master_dev_handle_t i2c_dev, int xf
|
||||
i2c_ll_disable_intr_mask(hal->dev, I2C_LL_MASTER_EVENT_INTR);
|
||||
}
|
||||
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (i2c_master->base->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_release(i2c_master->base->pm_lock), TAG, "release pm_lock failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -66,7 +66,6 @@ extern "C" {
|
||||
|
||||
#define I2C_ALLOW_INTR_PRIORITY_MASK ESP_INTR_FLAG_LOWMED
|
||||
|
||||
#define I2C_PM_LOCK_NAME_LEN_MAX 16
|
||||
#define I2C_STATIC_OPERATION_ARRAY_MAX SOC_I2C_CMD_REG_NUM
|
||||
|
||||
#define I2C_TRANS_READ_COMMAND(ack_value) {.ack_val = (ack_value), .op_code = I2C_LL_CMD_READ}
|
||||
@@ -116,9 +115,8 @@ struct i2c_bus_t {
|
||||
int scl_num; // SCL pin number
|
||||
bool pull_up_enable; // Enable pull-ups
|
||||
intr_handle_t intr_handle; // I2C interrupt handle
|
||||
esp_pm_lock_handle_t pm_lock; // power manage lock
|
||||
#if CONFIG_PM_ENABLE
|
||||
char pm_lock_name[I2C_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
||||
esp_pm_lock_handle_t pm_lock; // power manage lock
|
||||
#endif
|
||||
i2c_bus_mode_t bus_mode; // I2C bus mode
|
||||
#if SOC_I2C_SUPPORT_SLEEP_RETENTION
|
||||
|
Reference in New Issue
Block a user