mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
fix(gptimer): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled
This commit is contained in:
@@ -108,9 +108,11 @@ static void gptimer_unregister_from_group(gptimer_t *timer)
|
||||
|
||||
static esp_err_t gptimer_destroy(gptimer_t *timer)
|
||||
{
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (timer->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_delete(timer->pm_lock), TAG, "delete pm_lock failed");
|
||||
}
|
||||
#endif
|
||||
if (timer->intr) {
|
||||
ESP_RETURN_ON_ERROR(esp_intr_free(timer->intr), TAG, "delete interrupt service failed");
|
||||
}
|
||||
@@ -347,10 +349,12 @@ esp_err_t gptimer_enable(gptimer_handle_t timer)
|
||||
ESP_RETURN_ON_FALSE(atomic_compare_exchange_strong(&timer->fsm, &expected_fsm, GPTIMER_FSM_ENABLE),
|
||||
ESP_ERR_INVALID_STATE, TAG, "timer not in init state");
|
||||
|
||||
#if CONFIG_PM_ENABLE
|
||||
// acquire power manager lock
|
||||
if (timer->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_acquire(timer->pm_lock), TAG, "acquire pm_lock failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
// enable interrupt service
|
||||
if (timer->intr) {
|
||||
@@ -373,10 +377,12 @@ esp_err_t gptimer_disable(gptimer_handle_t timer)
|
||||
ESP_RETURN_ON_ERROR(esp_intr_disable(timer->intr), TAG, "disable interrupt service failed");
|
||||
}
|
||||
|
||||
#if CONFIG_PM_ENABLE
|
||||
// release power manager lock
|
||||
if (timer->pm_lock) {
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_release(timer->pm_lock), TAG, "release pm_lock failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -134,8 +134,7 @@ esp_err_t gptimer_select_periph_clock(gptimer_t *timer, gptimer_clock_source_t s
|
||||
#endif // CONFIG_IDF_TARGET_ESP32C2
|
||||
|
||||
if (need_pm_lock) {
|
||||
sprintf(timer->pm_lock_name, "gptimer_%d_%d", group_id, timer_id); // e.g. gptimer_0_0
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_lock_type, 0, timer->pm_lock_name, &timer->pm_lock),
|
||||
ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_lock_type, 0, timer_group_periph_signals.groups[group_id].module_name[timer_id], &timer->pm_lock),
|
||||
TAG, "create pm lock failed");
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
@@ -165,12 +164,14 @@ esp_err_t gptimer_get_intr_handle(gptimer_handle_t timer, intr_handle_t *ret_int
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_err_t gptimer_get_pm_lock(gptimer_handle_t timer, esp_pm_lock_handle_t *ret_pm_lock)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(timer && ret_pm_lock, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
*ret_pm_lock = timer->pm_lock;
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
int gptimer_get_group_id(gptimer_handle_t timer, int *group_id)
|
||||
{
|
||||
|
@@ -51,8 +51,6 @@ extern "C" {
|
||||
|
||||
#define GPTIMER_ALLOW_INTR_PRIORITY_MASK ESP_INTR_FLAG_LOWMED
|
||||
|
||||
#define GPTIMER_PM_LOCK_NAME_LEN_MAX 16
|
||||
|
||||
#define GPTIMER_USE_RETENTION_LINK (SOC_TIMER_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP)
|
||||
|
||||
#if SOC_PERIPH_CLK_CTRL_SHARED
|
||||
@@ -95,9 +93,8 @@ struct gptimer_t {
|
||||
gptimer_alarm_cb_t on_alarm;
|
||||
void *user_ctx;
|
||||
gptimer_clock_source_t clk_src;
|
||||
esp_pm_lock_handle_t pm_lock; // power management lock
|
||||
#if CONFIG_PM_ENABLE
|
||||
char pm_lock_name[GPTIMER_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
||||
esp_pm_lock_handle_t pm_lock; // power management lock
|
||||
#endif
|
||||
struct {
|
||||
uint32_t intr_shared: 1;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -10,6 +10,10 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
[1] = "TIMG0T1",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
@@ -17,6 +21,10 @@ const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
[1] = "TIMG1T1",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -9,6 +9,9 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_INTR_SOURCE,
|
||||
|
@@ -9,12 +9,18 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_INTR_SOURCE,
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,6 +9,10 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
[1] = "TIMG0T1",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_INTR_SOURCE,
|
||||
@@ -16,6 +20,10 @@ const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
[1] = "TIMG1T1",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,6 +9,10 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
[1] = "TIMG0T1",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
@@ -16,6 +20,10 @@ const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
[1] = "TIMG1T1",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,6 +9,10 @@
|
||||
const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
.groups = {
|
||||
[0] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG0T0",
|
||||
[1] = "TIMG0T1",
|
||||
},
|
||||
.module = PERIPH_TIMG0_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG0_T0_LEVEL_INTR_SOURCE,
|
||||
@@ -16,6 +20,10 @@ const timer_group_signal_conn_t timer_group_periph_signals = {
|
||||
}
|
||||
},
|
||||
[1] = {
|
||||
.module_name = {
|
||||
[0] = "TIMG1T0",
|
||||
[1] = "TIMG1T1",
|
||||
},
|
||||
.module = PERIPH_TIMG1_MODULE,
|
||||
.timer_irq_id = {
|
||||
[0] = ETS_TG1_T0_LEVEL_INTR_SOURCE,
|
||||
|
@@ -23,6 +23,7 @@ extern "C" {
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
const char *module_name[SOC_TIMER_GROUP_TIMERS_PER_GROUP];
|
||||
const periph_module_t module; // Peripheral module
|
||||
const int timer_irq_id[SOC_TIMER_GROUP_TIMERS_PER_GROUP]; // interrupt source ID
|
||||
} groups[SOC_TIMER_GROUPS];
|
||||
|
Reference in New Issue
Block a user