From 25147f2560e9ff99a42cf131decb3745604ec1ac Mon Sep 17 00:00:00 2001 From: Sachin Parekh Date: Tue, 22 Dec 2020 00:47:30 +0530 Subject: [PATCH] i2c: Acquire PM lock after acquiring mutex --- components/driver/i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/driver/i2c.c b/components/driver/i2c.c index 23cdb1242f..a9a93687db 100644 --- a/components/driver/i2c.c +++ b/components/driver/i2c.c @@ -1284,12 +1284,12 @@ esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, i2c_obj_t* p_i2c = p_i2c_obj[i2c_num]; portTickType ticks_start = xTaskGetTickCount(); portBASE_TYPE res = xSemaphoreTake(p_i2c->cmd_mux, ticks_to_wait); -#ifdef CONFIG_PM_ENABLE - esp_pm_lock_acquire(p_i2c->pm_lock); -#endif if (res == pdFALSE) { return ESP_ERR_TIMEOUT; } +#ifdef CONFIG_PM_ENABLE + esp_pm_lock_acquire(p_i2c->pm_lock); +#endif xQueueReset(p_i2c->cmd_evt_queue); if (p_i2c->status == I2C_STATUS_TIMEOUT || I2C[i2c_num]->status_reg.bus_busy == 1) {