mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
fix(glithc_filter): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -28,8 +28,8 @@ struct gpio_flex_glitch_filter_t {
|
|||||||
gpio_glitch_filter_t base;
|
gpio_glitch_filter_t base;
|
||||||
gpio_flex_glitch_filter_group_t *group;
|
gpio_flex_glitch_filter_group_t *group;
|
||||||
uint32_t filter_id;
|
uint32_t filter_id;
|
||||||
esp_pm_lock_handle_t pm_lock;
|
|
||||||
#if CONFIG_PM_ENABLE
|
#if CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_handle_t pm_lock;
|
||||||
char pm_lock_name[GLITCH_FILTER_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
char pm_lock_name[GLITCH_FILTER_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -72,9 +72,11 @@ static esp_err_t gpio_filter_destroy(gpio_flex_glitch_filter_t *filter)
|
|||||||
portEXIT_CRITICAL(&group->spinlock);
|
portEXIT_CRITICAL(&group->spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
if (filter->pm_lock) {
|
if (filter->pm_lock) {
|
||||||
esp_pm_lock_delete(filter->pm_lock);
|
esp_pm_lock_delete(filter->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
free(filter);
|
free(filter);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@@ -92,10 +94,12 @@ static esp_err_t gpio_flex_glitch_filter_enable(gpio_glitch_filter_t *filter)
|
|||||||
ESP_RETURN_ON_FALSE(filter->fsm == GLITCH_FILTER_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "filter not in init state");
|
ESP_RETURN_ON_FALSE(filter->fsm == GLITCH_FILTER_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "filter not in init state");
|
||||||
gpio_flex_glitch_filter_t *flex_filter = __containerof(filter, gpio_flex_glitch_filter_t, base);
|
gpio_flex_glitch_filter_t *flex_filter = __containerof(filter, gpio_flex_glitch_filter_t, base);
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// acquire pm lock
|
// acquire pm lock
|
||||||
if (flex_filter->pm_lock) {
|
if (flex_filter->pm_lock) {
|
||||||
esp_pm_lock_acquire(flex_filter->pm_lock);
|
esp_pm_lock_acquire(flex_filter->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int filter_id = flex_filter->filter_id;
|
int filter_id = flex_filter->filter_id;
|
||||||
gpio_ll_glitch_filter_enable(s_gpio_glitch_filter_group.hw, filter_id, true);
|
gpio_ll_glitch_filter_enable(s_gpio_glitch_filter_group.hw, filter_id, true);
|
||||||
@@ -111,10 +115,12 @@ static esp_err_t gpio_flex_glitch_filter_disable(gpio_glitch_filter_t *filter)
|
|||||||
int filter_id = flex_filter->filter_id;
|
int filter_id = flex_filter->filter_id;
|
||||||
gpio_ll_glitch_filter_enable(s_gpio_glitch_filter_group.hw, filter_id, false);
|
gpio_ll_glitch_filter_enable(s_gpio_glitch_filter_group.hw, filter_id, false);
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// release pm lock
|
// release pm lock
|
||||||
if (flex_filter->pm_lock) {
|
if (flex_filter->pm_lock) {
|
||||||
esp_pm_lock_release(flex_filter->pm_lock);
|
esp_pm_lock_release(flex_filter->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
filter->fsm = GLITCH_FILTER_FSM_INIT;
|
filter->fsm = GLITCH_FILTER_FSM_INIT;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -20,17 +20,19 @@ static const char *TAG = "gpio-filter";
|
|||||||
*/
|
*/
|
||||||
typedef struct gpio_pin_glitch_filter_t {
|
typedef struct gpio_pin_glitch_filter_t {
|
||||||
gpio_glitch_filter_t base;
|
gpio_glitch_filter_t base;
|
||||||
esp_pm_lock_handle_t pm_lock;
|
|
||||||
#if CONFIG_PM_ENABLE
|
#if CONFIG_PM_ENABLE
|
||||||
|
esp_pm_lock_handle_t pm_lock;
|
||||||
char pm_lock_name[GLITCH_FILTER_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
char pm_lock_name[GLITCH_FILTER_PM_LOCK_NAME_LEN_MAX]; // pm lock name
|
||||||
#endif
|
#endif
|
||||||
} gpio_pin_glitch_filter_t;
|
} gpio_pin_glitch_filter_t;
|
||||||
|
|
||||||
static esp_err_t gpio_filter_destroy(gpio_pin_glitch_filter_t *filter)
|
static esp_err_t gpio_filter_destroy(gpio_pin_glitch_filter_t *filter)
|
||||||
{
|
{
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
if (filter->pm_lock) {
|
if (filter->pm_lock) {
|
||||||
esp_pm_lock_delete(filter->pm_lock);
|
esp_pm_lock_delete(filter->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
free(filter);
|
free(filter);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@@ -46,12 +48,14 @@ static esp_err_t gpio_pin_glitch_filter_del(gpio_glitch_filter_t *filter)
|
|||||||
static esp_err_t gpio_pin_glitch_filter_enable(gpio_glitch_filter_t *filter)
|
static esp_err_t gpio_pin_glitch_filter_enable(gpio_glitch_filter_t *filter)
|
||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(filter->fsm == GLITCH_FILTER_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "filter not in init state");
|
ESP_RETURN_ON_FALSE(filter->fsm == GLITCH_FILTER_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "filter not in init state");
|
||||||
gpio_pin_glitch_filter_t *pin_filter = __containerof(filter, gpio_pin_glitch_filter_t, base);
|
[[maybe_unused]] gpio_pin_glitch_filter_t *pin_filter = __containerof(filter, gpio_pin_glitch_filter_t, base);
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// acquire pm lock
|
// acquire pm lock
|
||||||
if (pin_filter->pm_lock) {
|
if (pin_filter->pm_lock) {
|
||||||
esp_pm_lock_acquire(pin_filter->pm_lock);
|
esp_pm_lock_acquire(pin_filter->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gpio_ll_pin_filter_enable(NULL, filter->gpio_num);
|
gpio_ll_pin_filter_enable(NULL, filter->gpio_num);
|
||||||
filter->fsm = GLITCH_FILTER_FSM_ENABLE;
|
filter->fsm = GLITCH_FILTER_FSM_ENABLE;
|
||||||
@@ -61,14 +65,16 @@ static esp_err_t gpio_pin_glitch_filter_enable(gpio_glitch_filter_t *filter)
|
|||||||
static esp_err_t gpio_pin_glitch_filter_disable(gpio_glitch_filter_t *filter)
|
static esp_err_t gpio_pin_glitch_filter_disable(gpio_glitch_filter_t *filter)
|
||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(filter->fsm == GLITCH_FILTER_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "filter not in enable state");
|
ESP_RETURN_ON_FALSE(filter->fsm == GLITCH_FILTER_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "filter not in enable state");
|
||||||
gpio_pin_glitch_filter_t *pin_filter = __containerof(filter, gpio_pin_glitch_filter_t, base);
|
[[maybe_unused]] gpio_pin_glitch_filter_t *pin_filter = __containerof(filter, gpio_pin_glitch_filter_t, base);
|
||||||
|
|
||||||
gpio_ll_pin_filter_disable(NULL, filter->gpio_num);
|
gpio_ll_pin_filter_disable(NULL, filter->gpio_num);
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
// release pm lock
|
// release pm lock
|
||||||
if (pin_filter->pm_lock) {
|
if (pin_filter->pm_lock) {
|
||||||
esp_pm_lock_release(pin_filter->pm_lock);
|
esp_pm_lock_release(pin_filter->pm_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
filter->fsm = GLITCH_FILTER_FSM_INIT;
|
filter->fsm = GLITCH_FILTER_FSM_INIT;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
Reference in New Issue
Block a user