gpio_hal.c 1.3 KB

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