1 /*
2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 // The HAL layer for GPIO (common part)
8
9 #include "soc/soc.h"
10 #include "soc/gpio_periph.h"
11 #include "hal/gpio_hal.h"
12
gpio_hal_intr_enable_on_core(gpio_hal_context_t * hal,uint32_t gpio_num,uint32_t core_id)13 void gpio_hal_intr_enable_on_core(gpio_hal_context_t *hal, uint32_t gpio_num, uint32_t core_id)
14 {
15 if (gpio_num < 32) {
16 gpio_ll_clear_intr_status(hal->dev, BIT(gpio_num));
17 } else {
18 gpio_ll_clear_intr_status_high(hal->dev, BIT(gpio_num - 32));
19 }
20 gpio_ll_intr_enable_on_core(hal->dev, core_id, gpio_num);
21 }
22
gpio_hal_intr_disable(gpio_hal_context_t * hal,uint32_t gpio_num)23 void gpio_hal_intr_disable(gpio_hal_context_t *hal, uint32_t gpio_num)
24 {
25 gpio_ll_intr_disable(hal->dev, gpio_num);
26 if (gpio_num < 32) {
27 gpio_ll_clear_intr_status(hal->dev, BIT(gpio_num));
28 } else {
29 gpio_ll_clear_intr_status_high(hal->dev, BIT(gpio_num - 32));
30 }
31 }
32
33 #if SOC_GPIO_SUPPORT_PIN_HYS_FILTER
gpio_hal_hysteresis_soft_enable(gpio_hal_context_t * hal,uint32_t gpio_num,bool enable)34 void gpio_hal_hysteresis_soft_enable(gpio_hal_context_t *hal, uint32_t gpio_num, bool enable)
35 {
36 if (enable) {
37 gpio_ll_pin_input_hysteresis_ctrl_sel_soft(hal->dev, gpio_num);
38 gpio_ll_pin_input_hysteresis_enable(hal->dev, gpio_num);
39 } else {
40 gpio_ll_pin_input_hysteresis_ctrl_sel_soft(hal->dev, gpio_num);
41 gpio_ll_pin_input_hysteresis_disable(hal->dev, gpio_num);
42 }
43 }
44 #endif //SOC_GPIO_SUPPORT_PIN_HYS_FILTER
45