From 122d122c64737bca18545562daea1d95ca22a0d4 Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 27 Mar 2025 16:51:39 +0800 Subject: [PATCH] refactor(gpio): reuse gpio_int_type_t in the rtc io driver --- components/hal/esp32/include/hal/rtc_io_ll.h | 13 ++++------ .../hal/esp32c5/include/hal/rtc_io_ll.h | 24 ++++--------------- .../hal/esp32c6/include/hal/rtc_io_ll.h | 24 ++++--------------- .../hal/esp32c61/include/hal/rtc_io_ll.h | 24 ++++--------------- .../hal/esp32p4/include/hal/rtc_io_ll.h | 24 ++++--------------- .../hal/esp32s2/include/hal/rtc_io_ll.h | 13 ++++------ .../hal/esp32s3/include/hal/rtc_io_ll.h | 13 ++++------ .../lp_core/include/ulp_lp_core_gpio.h | 20 +++++++++------- .../gpio_intr_pulse_counter/main/ulp/main.c | 2 +- 9 files changed, 47 insertions(+), 110 deletions(-) diff --git a/components/hal/esp32/include/hal/rtc_io_ll.h b/components/hal/esp32/include/hal/rtc_io_ll.h index b1cb5c65ac..f9ab38f61d 100644 --- a/components/hal/esp32/include/hal/rtc_io_ll.h +++ b/components/hal/esp32/include/hal/rtc_io_ll.h @@ -14,6 +14,8 @@ #include #include +#include "hal/gpio_types.h" +#include "hal/assert.h" #include "soc/rtc_io_struct.h" #include "soc/rtc_io_reg.h" #include "soc/rtc_periph.h" @@ -29,12 +31,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -309,8 +305,9 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { + HAL_ASSERT(type == GPIO_INTR_LOW_LEVEL || type == GPIO_INTR_HIGH_LEVEL); RTCIO.pin[rtcio_num].wakeup_enable = 1; RTCIO.pin[rtcio_num].int_type = type; } @@ -323,7 +320,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { RTCIO.pin[rtcio_num].wakeup_enable = 0; - RTCIO.pin[rtcio_num].int_type = RTCIO_LL_WAKEUP_DISABLE; + RTCIO.pin[rtcio_num].int_type = 0; } /** diff --git a/components/hal/esp32c5/include/hal/rtc_io_ll.h b/components/hal/esp32c5/include/hal/rtc_io_ll.h index 7c6703ebd9..0a1104d7d5 100644 --- a/components/hal/esp32c5/include/hal/rtc_io_ll.h +++ b/components/hal/esp32c5/include/hal/rtc_io_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ #include "soc/lp_gpio_struct.h" #include "soc/lpperi_struct.h" #include "soc/pmu_struct.h" +#include "hal/gpio_types.h" #include "hal/misc.h" #include "hal/assert.h" @@ -35,21 +36,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - -typedef enum { - RTCIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ - RTCIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ - RTCIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ - RTCIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_intr_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -328,7 +314,7 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { LP_GPIO.pinn[rtcio_num].pinn_wakeup_enable = 1; LP_GPIO.pinn[rtcio_num].pinn_int_type = type; @@ -342,7 +328,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { LP_GPIO.pinn[rtcio_num].pinn_wakeup_enable = 0; - LP_GPIO.pinn[rtcio_num].pinn_int_type = RTCIO_LL_WAKEUP_DISABLE; + LP_GPIO.pinn[rtcio_num].pinn_int_type = 0; } /** @@ -352,7 +338,7 @@ static inline void rtcio_ll_wakeup_disable(int rtcio_num) * @param type Interrupt type on high level or low level. */ -static inline void rtcio_ll_intr_enable(int rtcio_num, rtcio_ll_intr_type_t type) +static inline void rtcio_ll_intr_enable(int rtcio_num, gpio_int_type_t type) { LP_GPIO.pinn[rtcio_num].pinn_int_type = type; diff --git a/components/hal/esp32c6/include/hal/rtc_io_ll.h b/components/hal/esp32c6/include/hal/rtc_io_ll.h index 33e8856457..708e53108a 100644 --- a/components/hal/esp32c6/include/hal/rtc_io_ll.h +++ b/components/hal/esp32c6/include/hal/rtc_io_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,6 +20,7 @@ #include "soc/lp_aon_struct.h" #include "soc/lpperi_struct.h" #include "soc/pmu_struct.h" +#include "hal/gpio_types.h" #include "hal/misc.h" #include "hal/assert.h" @@ -34,21 +35,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - -typedef enum { - RTCIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ - RTCIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ - RTCIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ - RTCIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_intr_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -327,7 +313,7 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { LP_IO.pin[rtcio_num].wakeup_enable = 1; LP_IO.pin[rtcio_num].int_type = type; @@ -349,7 +335,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { LP_IO.pin[rtcio_num].wakeup_enable = 0; - LP_IO.pin[rtcio_num].int_type = RTCIO_LL_WAKEUP_DISABLE; + LP_IO.pin[rtcio_num].int_type = 0; } /** @@ -359,7 +345,7 @@ static inline void rtcio_ll_wakeup_disable(int rtcio_num) * @param type Interrupt type on high level or low level. */ -static inline void rtcio_ll_intr_enable(int rtcio_num, rtcio_ll_intr_type_t type) +static inline void rtcio_ll_intr_enable(int rtcio_num, gpio_int_type_t type) { LP_IO.pin[rtcio_num].int_type = type; diff --git a/components/hal/esp32c61/include/hal/rtc_io_ll.h b/components/hal/esp32c61/include/hal/rtc_io_ll.h index 442614024b..d5b6001513 100644 --- a/components/hal/esp32c61/include/hal/rtc_io_ll.h +++ b/components/hal/esp32c61/include/hal/rtc_io_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ #include "soc/lp_gpio_struct.h" #include "soc/lpperi_struct.h" #include "soc/pmu_struct.h" +#include "hal/gpio_types.h" #include "hal/misc.h" #include "hal/assert.h" @@ -35,21 +36,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - -typedef enum { - RTCIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ - RTCIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ - RTCIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ - RTCIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_intr_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -328,7 +314,7 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { LP_GPIO.pinn[rtcio_num].pinn_wakeup_enable = 1; LP_GPIO.pinn[rtcio_num].pinn_int_type = type; @@ -342,7 +328,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { LP_GPIO.pinn[rtcio_num].pinn_wakeup_enable = 0; - LP_GPIO.pinn[rtcio_num].pinn_int_type = RTCIO_LL_WAKEUP_DISABLE; + LP_GPIO.pinn[rtcio_num].pinn_int_type = 0; } /** @@ -352,7 +338,7 @@ static inline void rtcio_ll_wakeup_disable(int rtcio_num) * @param type Interrupt type on high level or low level. */ -static inline void rtcio_ll_intr_enable(int rtcio_num, rtcio_ll_intr_type_t type) +static inline void rtcio_ll_intr_enable(int rtcio_num, gpio_int_type_t type) { LP_GPIO.pinn[rtcio_num].pinn_int_type = type; diff --git a/components/hal/esp32p4/include/hal/rtc_io_ll.h b/components/hal/esp32p4/include/hal/rtc_io_ll.h index 20f7f6ea73..e0d56fd658 100644 --- a/components/hal/esp32p4/include/hal/rtc_io_ll.h +++ b/components/hal/esp32p4/include/hal/rtc_io_ll.h @@ -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 */ @@ -19,6 +19,7 @@ #include "soc/lp_iomux_struct.h" #include "soc/lp_gpio_sig_map.h" #include "soc/pmu_struct.h" +#include "hal/gpio_types.h" #include "hal/misc.h" #include "hal/assert.h" @@ -33,21 +34,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - -typedef enum { - RTCIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ - RTCIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ - RTCIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ - RTCIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_intr_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -370,7 +356,7 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { LP_GPIO.pin[rtcio_num].wakeup_enable = 1; LP_GPIO.pin[rtcio_num].int_type = type; @@ -384,7 +370,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { LP_GPIO.pin[rtcio_num].wakeup_enable = 0; - LP_GPIO.pin[rtcio_num].int_type = RTCIO_LL_WAKEUP_DISABLE; + LP_GPIO.pin[rtcio_num].int_type = 0; } /** @@ -393,7 +379,7 @@ static inline void rtcio_ll_wakeup_disable(int rtcio_num) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Interrupt type on high level or low level. */ -static inline void rtcio_ll_intr_enable(int rtcio_num, rtcio_ll_intr_type_t type) +static inline void rtcio_ll_intr_enable(int rtcio_num, gpio_int_type_t type) { LP_GPIO.pin[rtcio_num].int_type = type; } diff --git a/components/hal/esp32s2/include/hal/rtc_io_ll.h b/components/hal/esp32s2/include/hal/rtc_io_ll.h index c515f2951e..2d4ae76de8 100644 --- a/components/hal/esp32s2/include/hal/rtc_io_ll.h +++ b/components/hal/esp32s2/include/hal/rtc_io_ll.h @@ -14,6 +14,8 @@ #include #include +#include "hal/assert.h" +#include "hal/gpio_types.h" #include "soc/rtc_io_struct.h" #include "soc/rtc_io_reg.h" #include "soc/rtc_periph.h" @@ -30,12 +32,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -318,8 +314,9 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { + HAL_ASSERT(type == GPIO_INTR_LOW_LEVEL || type == GPIO_INTR_HIGH_LEVEL); RTCIO.pin[rtcio_num].wakeup_enable = 1; RTCIO.pin[rtcio_num].int_type = type; } @@ -332,7 +329,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { RTCIO.pin[rtcio_num].wakeup_enable = 0; - RTCIO.pin[rtcio_num].int_type = RTCIO_LL_WAKEUP_DISABLE; + RTCIO.pin[rtcio_num].int_type = 0; } /** diff --git a/components/hal/esp32s3/include/hal/rtc_io_ll.h b/components/hal/esp32s3/include/hal/rtc_io_ll.h index ba601c9322..00a9d75ce6 100644 --- a/components/hal/esp32s3/include/hal/rtc_io_ll.h +++ b/components/hal/esp32s3/include/hal/rtc_io_ll.h @@ -14,6 +14,8 @@ #include #include +#include "hal/gpio_types.h" +#include "hal/assert.h" #include "soc/rtc_io_struct.h" #include "soc/rtc_io_reg.h" #include "soc/rtc_periph.h" @@ -33,12 +35,6 @@ typedef enum { RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */ } rtcio_ll_func_t; -typedef enum { - RTCIO_LL_WAKEUP_DISABLE = 0, /*!< Disable GPIO interrupt */ - RTCIO_LL_WAKEUP_LOW_LEVEL = 0x4, /*!< GPIO interrupt type : input low level trigger */ - RTCIO_LL_WAKEUP_HIGH_LEVEL = 0x5, /*!< GPIO interrupt type : input high level trigger */ -} rtcio_ll_wake_type_t; - typedef enum { RTCIO_LL_OUTPUT_NORMAL = 0, /*!< RTCIO output mode is normal. */ RTCIO_LL_OUTPUT_OD = 0x1, /*!< RTCIO output mode is open-drain. */ @@ -345,8 +341,9 @@ static inline void rtcio_ll_force_unhold_all(void) * @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio). * @param type Wakeup on high level or low level. */ -static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t type) +static inline void rtcio_ll_wakeup_enable(int rtcio_num, gpio_int_type_t type) { + HAL_ASSERT(type == GPIO_INTR_LOW_LEVEL || type == GPIO_INTR_HIGH_LEVEL); RTCIO.pin[rtcio_num].wakeup_enable = 1; RTCIO.pin[rtcio_num].int_type = type; } @@ -359,7 +356,7 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty static inline void rtcio_ll_wakeup_disable(int rtcio_num) { RTCIO.pin[rtcio_num].wakeup_enable = 0; - RTCIO.pin[rtcio_num].int_type = RTCIO_LL_WAKEUP_DISABLE; + RTCIO.pin[rtcio_num].int_type = 0; } /** diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h b/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h index 9719a29576..b2db02e262 100644 --- a/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h +++ b/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h @@ -38,14 +38,16 @@ typedef enum { #endif } lp_io_num_t; -typedef enum { - LP_IO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ - LP_IO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ - LP_IO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ - LP_IO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ - LP_IO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ - LP_IO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ -} lp_io_intr_type_t; +/** @cond */ +/// for backward compatible +typedef gpio_int_type_t lp_io_intr_type_t; +#define LP_IO_INTR_DISABLE GPIO_INTR_DISABLE +#define LP_IO_INTR_POSEDGE GPIO_INTR_POSEDGE +#define LP_IO_INTR_NEGEDGE GPIO_INTR_NEGEDGE +#define LP_IO_INTR_ANYEDGE GPIO_INTR_ANYEDGE +#define LP_IO_INTR_LOW_LEVEL GPIO_INTR_LOW_LEVEL +#define LP_IO_INTR_HIGH_LEVEL GPIO_INTR_HIGH_LEVEL +/** @endcond */ /** * @brief Initialize a rtcio pin @@ -184,7 +186,7 @@ static inline void ulp_lp_core_gpio_pulldown_disable(lp_io_num_t lp_io_num) * @param lp_io_num The lp io pin to enable interrupt for * @param intr_type The interrupt type to enable */ -static inline void ulp_lp_core_gpio_intr_enable(lp_io_num_t lp_io_num, lp_io_intr_type_t intr_type) +static inline void ulp_lp_core_gpio_intr_enable(lp_io_num_t lp_io_num, gpio_int_type_t intr_type) { rtcio_ll_intr_enable(lp_io_num, intr_type); } diff --git a/examples/system/ulp/lp_core/gpio_intr_pulse_counter/main/ulp/main.c b/examples/system/ulp/lp_core/gpio_intr_pulse_counter/main/ulp/main.c index 6a45c04cb9..490d9241b9 100644 --- a/examples/system/ulp/lp_core/gpio_intr_pulse_counter/main/ulp/main.c +++ b/examples/system/ulp/lp_core/gpio_intr_pulse_counter/main/ulp/main.c @@ -44,7 +44,7 @@ int main (void) { lp_core_printf("LP Core pulse counter started\n"); ulp_lp_core_intr_enable(); - ulp_lp_core_gpio_intr_enable(CONFIG_EXAMPLE_PULSE_COUNT_PIN, LP_IO_INTR_POSEDGE); + ulp_lp_core_gpio_intr_enable(CONFIG_EXAMPLE_PULSE_COUNT_PIN, GPIO_INTR_POSEDGE); while(1) {