diff --git a/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_types.h b/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_types.h index 1974743363..497ba310a9 100644 --- a/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_types.h +++ b/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include #include "soc/soc_caps.h" #include "soc/clk_tree_defs.h" +#include "hal/ana_cmpr_types.h" #ifdef __cplusplus extern "C" { @@ -40,32 +41,6 @@ typedef enum { ANA_CMPR_EXT_REF_CHAN, /*!< Analog Comparator external reference channel, which is used as the reference signal */ } ana_cmpr_channel_type_t; -/** - * @brief Analog comparator interrupt type - * - */ -typedef enum { - ANA_CMPR_CROSS_DISABLE, /*!< Disable the cross event interrupt */ - ANA_CMPR_CROSS_POS, /*!< Positive cross can trigger event interrupt */ - ANA_CMPR_CROSS_NEG, /*!< Negative cross can trigger event interrupt */ - ANA_CMPR_CROSS_ANY, /*!< Any cross can trigger event interrupt */ -} ana_cmpr_cross_type_t; - -/** - * @brief Analog comparator internal reference voltage - * - */ -typedef enum { - ANA_CMPR_REF_VOLT_0_PCT_VDD, /*!< Internal reference voltage equals to 0% VDD */ - ANA_CMPR_REF_VOLT_10_PCT_VDD, /*!< Internal reference voltage equals to 10% VDD */ - ANA_CMPR_REF_VOLT_20_PCT_VDD, /*!< Internal reference voltage equals to 20% VDD */ - ANA_CMPR_REF_VOLT_30_PCT_VDD, /*!< Internal reference voltage equals to 30% VDD */ - ANA_CMPR_REF_VOLT_40_PCT_VDD, /*!< Internal reference voltage equals to 40% VDD */ - ANA_CMPR_REF_VOLT_50_PCT_VDD, /*!< Internal reference voltage equals to 50% VDD */ - ANA_CMPR_REF_VOLT_60_PCT_VDD, /*!< Internal reference voltage equals to 60% VDD */ - ANA_CMPR_REF_VOLT_70_PCT_VDD, /*!< Internal reference voltage equals to 70% VDD */ -} ana_cmpr_ref_voltage_t; - /** * @brief Analog comparator unit handle * diff --git a/components/hal/esp32c5/include/hal/ana_cmpr_ll.h b/components/hal/esp32c5/include/hal/ana_cmpr_ll.h index 73e99c5671..24326ebb85 100644 --- a/components/hal/esp32c5/include/hal/ana_cmpr_ll.h +++ b/components/hal/esp32c5/include/hal/ana_cmpr_ll.h @@ -9,6 +9,7 @@ #include #include "hal/misc.h" #include "hal/assert.h" +#include "hal/ana_cmpr_types.h" #include "soc/ana_cmpr_struct.h" #include "soc/soc_etm_source.h" @@ -68,7 +69,7 @@ static inline float analog_cmpr_ll_get_internal_ref_voltage(analog_cmpr_dev_t *h * @param hw Analog comparator register base address * @param ref_src reference source, 0 for internal, 1 for external GPIO pad (GPIO10) */ -static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t ref_src) +static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, ana_cmpr_ref_voltage_t ref_src) { hw->pad_comp_config->mode_comp_0 = ref_src; } @@ -85,7 +86,7 @@ static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t * @return interrupt mask */ __attribute__((always_inline)) -static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, uint8_t type) +static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, ana_cmpr_cross_type_t type) { uint32_t unit = ANALOG_CMPR_LL_GET_UNIT(hw); uint32_t mask = 0; diff --git a/components/hal/esp32c61/include/hal/ana_cmpr_ll.h b/components/hal/esp32c61/include/hal/ana_cmpr_ll.h index 73e99c5671..24326ebb85 100644 --- a/components/hal/esp32c61/include/hal/ana_cmpr_ll.h +++ b/components/hal/esp32c61/include/hal/ana_cmpr_ll.h @@ -9,6 +9,7 @@ #include #include "hal/misc.h" #include "hal/assert.h" +#include "hal/ana_cmpr_types.h" #include "soc/ana_cmpr_struct.h" #include "soc/soc_etm_source.h" @@ -68,7 +69,7 @@ static inline float analog_cmpr_ll_get_internal_ref_voltage(analog_cmpr_dev_t *h * @param hw Analog comparator register base address * @param ref_src reference source, 0 for internal, 1 for external GPIO pad (GPIO10) */ -static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t ref_src) +static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, ana_cmpr_ref_voltage_t ref_src) { hw->pad_comp_config->mode_comp_0 = ref_src; } @@ -85,7 +86,7 @@ static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t * @return interrupt mask */ __attribute__((always_inline)) -static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, uint8_t type) +static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, ana_cmpr_cross_type_t type) { uint32_t unit = ANALOG_CMPR_LL_GET_UNIT(hw); uint32_t mask = 0; diff --git a/components/hal/esp32h2/include/hal/ana_cmpr_ll.h b/components/hal/esp32h2/include/hal/ana_cmpr_ll.h index c75fc5ddc5..3ac8787c1f 100644 --- a/components/hal/esp32h2/include/hal/ana_cmpr_ll.h +++ b/components/hal/esp32h2/include/hal/ana_cmpr_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include #include "hal/misc.h" #include "hal/assert.h" +#include "hal/ana_cmpr_types.h" #include "soc/ana_cmpr_struct.h" #define ANALOG_CMPR_LL_GET_HW(unit) (&ANALOG_CMPR[unit]) @@ -60,7 +61,7 @@ static inline uint32_t analog_cmpr_ll_get_internal_ref_voltage(analog_cmpr_dev_t * @param hw Analog comparator register base address * @param ref_src reference source, 0 for internal, 1 for external GPIO pad (GPIO10) */ -static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t ref_src) +static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, ana_cmpr_ref_voltage_t ref_src) { hw->pad_comp_config->mode_comp = ref_src; } @@ -91,7 +92,7 @@ static inline void analog_cmpr_ll_set_cross_type(analog_cmpr_dev_t *hw, uint8_t * @return interrupt mask */ __attribute__((always_inline)) -static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, uint8_t type) +static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, ana_cmpr_cross_type_t type) { (void)type; return ANALOG_CMPR_LL_EVENT_CROSS; diff --git a/components/hal/esp32p4/include/hal/ana_cmpr_ll.h b/components/hal/esp32p4/include/hal/ana_cmpr_ll.h index b0ada6928e..32a5835b5a 100644 --- a/components/hal/esp32p4/include/hal/ana_cmpr_ll.h +++ b/components/hal/esp32p4/include/hal/ana_cmpr_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include #include "hal/misc.h" #include "hal/assert.h" +#include "hal/ana_cmpr_types.h" #include "soc/ana_cmpr_struct.h" #include "soc/soc_etm_source.h" @@ -68,7 +69,7 @@ static inline float analog_cmpr_ll_get_internal_ref_voltage(analog_cmpr_dev_t *h * @param hw Analog comparator register base address * @param ref_src reference source, 0 for internal, 1 for external GPIO pad (GPIO10) */ -static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t ref_src) +static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, ana_cmpr_ref_voltage_t ref_src) { hw->pad_comp_config->mode_comp = ref_src; } @@ -85,7 +86,7 @@ static inline void analog_cmpr_ll_set_ref_source(analog_cmpr_dev_t *hw, uint32_t * @return interrupt mask */ __attribute__((always_inline)) -static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, uint8_t type) +static inline uint32_t analog_cmpr_ll_get_intr_mask_by_type(analog_cmpr_dev_t *hw, ana_cmpr_cross_type_t type) { uint32_t unit = ANALOG_CMPR_LL_GET_UNIT(hw); uint32_t mask = 0; diff --git a/components/hal/include/hal/ana_cmpr_types.h b/components/hal/include/hal/ana_cmpr_types.h new file mode 100644 index 0000000000..e37764a3e1 --- /dev/null +++ b/components/hal/include/hal/ana_cmpr_types.h @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Analog comparator interrupt type + * + */ +typedef enum { + ANA_CMPR_CROSS_DISABLE, /*!< Disable the cross event interrupt */ + ANA_CMPR_CROSS_POS, /*!< Positive cross can trigger event interrupt */ + ANA_CMPR_CROSS_NEG, /*!< Negative cross can trigger event interrupt */ + ANA_CMPR_CROSS_ANY, /*!< Any cross can trigger event interrupt */ +} ana_cmpr_cross_type_t; + +/** + * @brief Analog comparator internal reference voltage + * + */ +typedef enum { + ANA_CMPR_REF_VOLT_0_PCT_VDD, /*!< Internal reference voltage equals to 0% VDD */ + ANA_CMPR_REF_VOLT_10_PCT_VDD, /*!< Internal reference voltage equals to 10% VDD */ + ANA_CMPR_REF_VOLT_20_PCT_VDD, /*!< Internal reference voltage equals to 20% VDD */ + ANA_CMPR_REF_VOLT_30_PCT_VDD, /*!< Internal reference voltage equals to 30% VDD */ + ANA_CMPR_REF_VOLT_40_PCT_VDD, /*!< Internal reference voltage equals to 40% VDD */ + ANA_CMPR_REF_VOLT_50_PCT_VDD, /*!< Internal reference voltage equals to 50% VDD */ + ANA_CMPR_REF_VOLT_60_PCT_VDD, /*!< Internal reference voltage equals to 60% VDD */ + ANA_CMPR_REF_VOLT_70_PCT_VDD, /*!< Internal reference voltage equals to 70% VDD */ +} ana_cmpr_ref_voltage_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/soc/esp32c5/ana_cmpr_periph.c b/components/soc/esp32c5/ana_cmpr_periph.c index eac077a33f..9ff18e4329 100644 --- a/components/soc/esp32c5/ana_cmpr_periph.c +++ b/components/soc/esp32c5/ana_cmpr_periph.c @@ -11,7 +11,7 @@ const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { [0] = { .src_gpio = ANA_CMPR0_SRC_GPIO, .ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO, - .intr_src = ETS_GPIO_NMI_SOURCE, + .intr_src = ETS_GPIO_EXT_SOURCE, }, }; diff --git a/components/soc/esp32c5/include/soc/interrupts.h b/components/soc/esp32c5/include/soc/interrupts.h index 5eb272ae64..860800c016 100644 --- a/components/soc/esp32c5/include/soc/interrupts.h +++ b/components/soc/esp32c5/include/soc/interrupts.h @@ -47,7 +47,7 @@ typedef enum { ETS_CACHE_INTR_SOURCE, ETS_CPU_PERI_TIMEOUT_INTR_SOURCE, ETS_GPIO_INTR_SOURCE, /**< interrupt of GPIO, level*/ - ETS_GPIO_NMI_SOURCE, /**< interrupt of GPIO, NMI*/ + ETS_GPIO_EXT_SOURCE, /**< interrupt of GPIO, EXT (analog comparator)*/ ETS_PAU_INTR_SOURCE, ETS_HP_PERI_TIMEOUT_INTR_SOURCE, ETS_MODEM_PERI_TIMEOUT_INTR_SOURCE, diff --git a/components/soc/esp32c5/interrupts.c b/components/soc/esp32c5/interrupts.c index 23421b6627..6b2682b303 100644 --- a/components/soc/esp32c5/interrupts.c +++ b/components/soc/esp32c5/interrupts.c @@ -39,7 +39,7 @@ const char *const esp_isr_names[] = { [ETS_CACHE_INTR_SOURCE] = "CACHE", [ETS_CPU_PERI_TIMEOUT_INTR_SOURCE] = "CPU_PERI_TIMEOUT", [ETS_GPIO_INTR_SOURCE] = "GPIO_INTR", - [ETS_GPIO_NMI_SOURCE] = "GPIO_NMI", + [ETS_GPIO_EXT_SOURCE] = "GPIO_EXT", [ETS_PAU_INTR_SOURCE] = "PAU", [ETS_HP_PERI_TIMEOUT_INTR_SOURCE] = "HP_PERI_TIMEOUT", [ETS_MODEM_PERI_TIMEOUT_INTR_SOURCE] = "MODEM_PERI_TIMEOUT",