diff --git a/components/esp_driver_ana_cmpr/ana_cmpr.c b/components/esp_driver_ana_cmpr/ana_cmpr.c index 92ebf93984..9a7cdeefee 100644 --- a/components/esp_driver_ana_cmpr/ana_cmpr.c +++ b/components/esp_driver_ana_cmpr/ana_cmpr.c @@ -42,11 +42,11 @@ do { \ } \ } while(0) -#define ANA_CMPR_UNIT_CHECK(unit) ESP_RETURN_ON_FALSE((unit) >= 0 && (unit) < SOC_ANA_CMPR_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid unit number") +#define ANA_CMPR_UNIT_CHECK(unit) ESP_RETURN_ON_FALSE((unit) >= 0 && (unit) < ANALOG_CMPR_LL_GET(INST_NUM), ESP_ERR_INVALID_ARG, TAG, "invalid unit number") /* Global static object of the Analog Comparator unit */ -static ana_cmpr_handle_t s_ana_cmpr[SOC_ANA_CMPR_NUM] = { - [0 ...(SOC_ANA_CMPR_NUM - 1)] = NULL, +static ana_cmpr_handle_t s_ana_cmpr[ANALOG_CMPR_LL_GET(INST_NUM)] = { + [0 ...(ANALOG_CMPR_LL_GET(INST_NUM) - 1)] = NULL, }; /* Global spin lock */ @@ -64,13 +64,13 @@ void ana_cmpr_default_intr_handler(void *usr_data) /* Call the user callback function if it is specified and the corresponding event triggers*/ if (cmpr_handle->cbs.on_cross && (status & cmpr_handle->intr_mask)) { // some chip can distinguish the edge of the cross event -#if SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE +#if ANALOG_CMPR_LL_SUPPORT(EDGE_TYPE) if (status & ANALOG_CMPR_LL_POS_CROSS_MASK(cmpr_handle->unit)) { evt_data.cross_type = ANA_CMPR_CROSS_POS; } else if (status & ANALOG_CMPR_LL_NEG_CROSS_MASK(cmpr_handle->unit)) { evt_data.cross_type = ANA_CMPR_CROSS_NEG; } -#endif // SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE +#endif // ANALOG_CMPR_LL_SUPPORT(EDGE_TYPE) need_yield = cmpr_handle->cbs.on_cross(cmpr_handle, &evt_data, cmpr_handle->user_data); } if (need_yield) { @@ -140,10 +140,10 @@ esp_err_t ana_cmpr_new_unit(const ana_cmpr_config_t *config, ana_cmpr_handle_t * /* Configure the register */ analog_cmpr_ll_set_ref_source(ana_cmpr_hdl->dev, config->ref_src); ana_cmpr_hdl->ref_src = config->ref_src; -#if !SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE +#if !ANALOG_CMPR_LL_SUPPORT(EDGE_TYPE) // set which cross type can trigger the interrupt analog_cmpr_ll_set_intr_cross_type(ana_cmpr_hdl->dev, config->cross_type); -#endif // SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE +#endif // !ANALOG_CMPR_LL_SUPPORT(EDGE_TYPE) // record the interrupt mask, the interrupt will be lazy installed when register user callbacks // different cross type means different interrupt mask ana_cmpr_hdl->intr_mask = analog_cmpr_ll_get_intr_mask_by_type(ana_cmpr_hdl->dev, config->cross_type); @@ -182,7 +182,7 @@ esp_err_t ana_cmpr_del_unit(ana_cmpr_handle_t cmpr) ANA_CMPR_NULL_POINTER_CHECK(cmpr); /* Search the global object array to check if the input handle is valid */ int unit = -1; - for (int i = 0; i < SOC_ANA_CMPR_NUM; i++) { + for (int i = 0; i < ANALOG_CMPR_LL_GET(INST_NUM); i++) { if (s_ana_cmpr[i] == cmpr) { unit = i; break; @@ -233,7 +233,7 @@ esp_err_t ana_cmpr_set_debounce(ana_cmpr_handle_t cmpr, const ana_cmpr_debounce_ esp_err_t ana_cmpr_set_cross_type(ana_cmpr_handle_t cmpr, ana_cmpr_cross_type_t cross_type) { -#if SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE +#if ANALOG_CMPR_LL_SUPPORT(EDGE_TYPE) /* Not support to set the cross type after initialized, because it relies on the interrupt types to distinguish the edge, * i.e. have to re-allocate the interrupt to change the cross type */ (void)cmpr; diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/README.md b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/README.md index fcf05f5c01..592e3228eb 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/README.md +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32-C5 | ESP32-C61 | ESP32-H2 | ESP32-P4 | -| ----------------- | -------- | --------- | -------- | -------- | +| Supported Targets | ESP32-C5 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-P4 | +| ----------------- | -------- | --------- | -------- | --------- | -------- | diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c index 3d6f7b7d00..93726ae05d 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c @@ -10,7 +10,7 @@ TEST_CASE("ana_cmpr unit install/uninstall", "[ana_cmpr]") { ana_cmpr_handle_t cmpr = NULL; ana_cmpr_config_t config = { - .unit = SOC_ANA_CMPR_NUM, // Set a wrong unit + .unit = 100, // Set a wrong unit .clk_src = ANA_CMPR_CLK_SRC_DEFAULT, .ref_src = ANA_CMPR_REF_SRC_INTERNAL, .cross_type = ANA_CMPR_CROSS_ANY, diff --git a/components/esp_driver_gpio/src/gpio.c b/components/esp_driver_gpio/src/gpio.c index 6b7e863ff4..11eca7aee0 100644 --- a/components/esp_driver_gpio/src/gpio.c +++ b/components/esp_driver_gpio/src/gpio.c @@ -20,6 +20,7 @@ #include "esp_log.h" #include "esp_check.h" #include "hal/gpio_hal.h" +#include "hal/gpio_caps.h" #include "esp_private/esp_gpio_reserve.h" #include "esp_private/io_mux.h" #include "esp_private/periph_ctrl.h" @@ -651,7 +652,7 @@ esp_err_t gpio_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, gpio_isr_alloc_t p; p.source = GPIO_LL_INTR_SOURCE0; p.intr_alloc_flags = intr_alloc_flags; -#if SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO +#if GPIO_CAPS_GET(INTR_SHARED) p.intr_alloc_flags |= ESP_INTR_FLAG_SHARED; #endif p.fn = fn; diff --git a/components/esp_hal_ana_cmpr/esp32c5/ana_cmpr_periph.c b/components/esp_hal_ana_cmpr/esp32c5/ana_cmpr_periph.c index 74aaf40158..d482ac8966 100644 --- a/components/esp_hal_ana_cmpr/esp32c5/ana_cmpr_periph.c +++ b/components/esp_hal_ana_cmpr/esp32c5/ana_cmpr_periph.c @@ -7,7 +7,7 @@ #include "hal/ana_cmpr_periph.h" #include "soc/ana_cmpr_struct.h" -const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { +const ana_cmpr_periph_t ana_cmpr_periph[1] = { [0] = { .src_gpio = ANA_CMPR0_SRC_GPIO, .ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO, @@ -16,7 +16,7 @@ const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { }, }; -analog_cmpr_dev_t ANALOG_CMPR[SOC_ANA_CMPR_NUM] = { +analog_cmpr_dev_t ANALOG_CMPR[1] = { [0] = { .pad_comp_config = &GPIO_EXT.pad_comp_config_0, .pad_comp_filter = &GPIO_EXT.pad_comp_filter_0, diff --git a/components/esp_hal_ana_cmpr/esp32c5/include/hal/ana_cmpr_ll.h b/components/esp_hal_ana_cmpr/esp32c5/include/hal/ana_cmpr_ll.h index 946ad41041..d579480455 100644 --- a/components/esp_hal_ana_cmpr/esp32c5/include/hal/ana_cmpr_ll.h +++ b/components/esp_hal_ana_cmpr/esp32c5/include/hal/ana_cmpr_ll.h @@ -17,6 +17,15 @@ extern "C" { #endif +#define ANALOG_CMPR_LL_GET(_attr) ANALOG_CMPR_LL_ ## _attr +#define ANALOG_CMPR_LL_SUPPORT(_feat) ANALOG_CMPR_LL_SUPPORT_ ## _feat + +// Number of Analog Comparator instances +#define ANALOG_CMPR_LL_INST_NUM 1 + +// Can detect positive/negative/any cross type +#define ANALOG_CMPR_LL_SUPPORT_EDGE_TYPE 1 + #define ANALOG_CMPR_LL_GET_HW(unit) (&ANALOG_CMPR[unit]) #define ANALOG_CMPR_LL_GET_UNIT(hw) (0) diff --git a/components/esp_hal_ana_cmpr/esp32c61/ana_cmpr_periph.c b/components/esp_hal_ana_cmpr/esp32c61/ana_cmpr_periph.c index f71d8ae4e5..ed87543ad8 100644 --- a/components/esp_hal_ana_cmpr/esp32c61/ana_cmpr_periph.c +++ b/components/esp_hal_ana_cmpr/esp32c61/ana_cmpr_periph.c @@ -7,7 +7,7 @@ #include "hal/ana_cmpr_periph.h" #include "soc/ana_cmpr_struct.h" -const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { +const ana_cmpr_periph_t ana_cmpr_periph[1] = { [0] = { .src_gpio = ANA_CMPR0_SRC_GPIO, .ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO, @@ -16,7 +16,7 @@ const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { }, }; -analog_cmpr_dev_t ANALOG_CMPR[SOC_ANA_CMPR_NUM] = { +analog_cmpr_dev_t ANALOG_CMPR[1] = { [0] = { .pad_comp_config = &GPIO_EXT.pad_comp_config_0, .pad_comp_filter = &GPIO_EXT.pad_comp_filter_0, diff --git a/components/esp_hal_ana_cmpr/esp32c61/include/hal/ana_cmpr_ll.h b/components/esp_hal_ana_cmpr/esp32c61/include/hal/ana_cmpr_ll.h index 946ad41041..d579480455 100644 --- a/components/esp_hal_ana_cmpr/esp32c61/include/hal/ana_cmpr_ll.h +++ b/components/esp_hal_ana_cmpr/esp32c61/include/hal/ana_cmpr_ll.h @@ -17,6 +17,15 @@ extern "C" { #endif +#define ANALOG_CMPR_LL_GET(_attr) ANALOG_CMPR_LL_ ## _attr +#define ANALOG_CMPR_LL_SUPPORT(_feat) ANALOG_CMPR_LL_SUPPORT_ ## _feat + +// Number of Analog Comparator instances +#define ANALOG_CMPR_LL_INST_NUM 1 + +// Can detect positive/negative/any cross type +#define ANALOG_CMPR_LL_SUPPORT_EDGE_TYPE 1 + #define ANALOG_CMPR_LL_GET_HW(unit) (&ANALOG_CMPR[unit]) #define ANALOG_CMPR_LL_GET_UNIT(hw) (0) diff --git a/components/esp_hal_ana_cmpr/esp32h2/ana_cmpr_periph.c b/components/esp_hal_ana_cmpr/esp32h2/ana_cmpr_periph.c index 5d568ee3f0..ef7df956fe 100644 --- a/components/esp_hal_ana_cmpr/esp32h2/ana_cmpr_periph.c +++ b/components/esp_hal_ana_cmpr/esp32h2/ana_cmpr_periph.c @@ -7,7 +7,7 @@ #include "hal/ana_cmpr_periph.h" #include "soc/ana_cmpr_struct.h" -const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { +const ana_cmpr_periph_t ana_cmpr_periph[1] = { [0] = { .src_gpio = ANA_CMPR0_SRC_GPIO, .ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO, @@ -16,7 +16,7 @@ const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { }, }; -analog_cmpr_dev_t ANALOG_CMPR[SOC_ANA_CMPR_NUM] = { +analog_cmpr_dev_t ANALOG_CMPR[1] = { [0] = { .pad_comp_config = &GPIO_EXT.pad_comp_config, .pad_comp_filter = &GPIO_EXT.pad_comp_filter, diff --git a/components/esp_hal_ana_cmpr/esp32h2/include/hal/ana_cmpr_ll.h b/components/esp_hal_ana_cmpr/esp32h2/include/hal/ana_cmpr_ll.h index 5cbe849925..b07d400812 100644 --- a/components/esp_hal_ana_cmpr/esp32h2/include/hal/ana_cmpr_ll.h +++ b/components/esp_hal_ana_cmpr/esp32h2/include/hal/ana_cmpr_ll.h @@ -12,6 +12,12 @@ #include "hal/ana_cmpr_types.h" #include "soc/ana_cmpr_struct.h" +#define ANALOG_CMPR_LL_GET(_attr) ANALOG_CMPR_LL_ ## _attr +#define ANALOG_CMPR_LL_SUPPORT(_feat) ANALOG_CMPR_LL_SUPPORT_ ## _feat + +// Number of Analog Comparator instances +#define ANALOG_CMPR_LL_INST_NUM 1 + #define ANALOG_CMPR_LL_GET_HW(unit) (&ANALOG_CMPR[unit]) #define ANALOG_CMPR_LL_EVENT_CROSS (1 << 0) diff --git a/components/esp_hal_ana_cmpr/esp32h21/ana_cmpr_periph.c b/components/esp_hal_ana_cmpr/esp32h21/ana_cmpr_periph.c new file mode 100644 index 0000000000..7b52a6cbe5 --- /dev/null +++ b/components/esp_hal_ana_cmpr/esp32h21/ana_cmpr_periph.c @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "hal/ana_cmpr_periph.h" +#include "soc/ana_cmpr_struct.h" + +const ana_cmpr_periph_t ana_cmpr_periph[1] = { + [0] = { + .src_gpio = ANA_CMPR0_SRC_GPIO, + .ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO, + .intr_src = ETS_GPIO_INTERRUPT_PRO_SOURCE, + .module_name = "ANA_CMPR_U0", + }, +}; + +analog_cmpr_dev_t ANALOG_CMPR[1] = { + [0] = { + .pad_comp_config = &GPIO_EXT.pad_comp_config, + .pad_comp_filter = &GPIO_EXT.pad_comp_filter, + .int_st = &GPIO_EXT.int_st, + .int_ena = &GPIO_EXT.int_ena, + .int_clr = &GPIO_EXT.int_clr, + }, +}; diff --git a/components/esp_hal_ana_cmpr/esp32h21/include/hal/ana_cmpr_ll.h b/components/esp_hal_ana_cmpr/esp32h21/include/hal/ana_cmpr_ll.h index 9b400af192..3762b39da5 100644 --- a/components/esp_hal_ana_cmpr/esp32h21/include/hal/ana_cmpr_ll.h +++ b/components/esp_hal_ana_cmpr/esp32h21/include/hal/ana_cmpr_ll.h @@ -16,6 +16,15 @@ extern "C" { #endif +#define ANALOG_CMPR_LL_GET(_attr) ANALOG_CMPR_LL_ ## _attr +#define ANALOG_CMPR_LL_SUPPORT(_feat) ANALOG_CMPR_LL_SUPPORT_ ## _feat + +// Number of Analog Comparator instances +#define ANALOG_CMPR_LL_INST_NUM 1 + +// Can detect positive/negative/any cross type +#define ANALOG_CMPR_LL_SUPPORT_EDGE_TYPE 1 + #define ANALOG_CMPR_LL_GET_HW(unit) (&ANALOG_CMPR[unit]) #define ANALOG_CMPR_LL_GET_UNIT(hw) (0) diff --git a/components/esp_hal_ana_cmpr/esp32p4/ana_cmpr_periph.c b/components/esp_hal_ana_cmpr/esp32p4/ana_cmpr_periph.c index 976bca4933..a71385eaed 100644 --- a/components/esp_hal_ana_cmpr/esp32p4/ana_cmpr_periph.c +++ b/components/esp_hal_ana_cmpr/esp32p4/ana_cmpr_periph.c @@ -7,7 +7,7 @@ #include "hal/ana_cmpr_periph.h" #include "soc/ana_cmpr_struct.h" -const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { +const ana_cmpr_periph_t ana_cmpr_periph[2] = { [0] = { .src_gpio = ANA_CMPR0_SRC_GPIO, .ext_ref_gpio = ANA_CMPR0_EXT_REF_GPIO, @@ -22,7 +22,7 @@ const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM] = { }, }; -analog_cmpr_dev_t ANALOG_CMPR[SOC_ANA_CMPR_NUM] = { +analog_cmpr_dev_t ANALOG_CMPR[2] = { [0] = { .pad_comp_config = &LP_SYS.pad_comp[0], .pad_comp_filter = &GPIO.zero_det_filter_cnt[0], diff --git a/components/esp_hal_ana_cmpr/esp32p4/include/hal/ana_cmpr_ll.h b/components/esp_hal_ana_cmpr/esp32p4/include/hal/ana_cmpr_ll.h index 922a802f50..a3c210503c 100644 --- a/components/esp_hal_ana_cmpr/esp32p4/include/hal/ana_cmpr_ll.h +++ b/components/esp_hal_ana_cmpr/esp32p4/include/hal/ana_cmpr_ll.h @@ -17,6 +17,15 @@ extern "C" { #endif +#define ANALOG_CMPR_LL_GET(_attr) ANALOG_CMPR_LL_ ## _attr +#define ANALOG_CMPR_LL_SUPPORT(_feat) ANALOG_CMPR_LL_SUPPORT_ ## _feat + +// Number of Analog Comparator instances +#define ANALOG_CMPR_LL_INST_NUM 2 + +// Can detect positive/negative/any cross type +#define ANALOG_CMPR_LL_SUPPORT_EDGE_TYPE 1 + #define ANALOG_CMPR_LL_GET_HW(unit) (&ANALOG_CMPR[unit]) #define ANALOG_CMPR_LL_GET_UNIT(hw) ((hw) == (&ANALOG_CMPR[0]) ? 0 : 1) diff --git a/components/esp_hal_ana_cmpr/include/hal/ana_cmpr_periph.h b/components/esp_hal_ana_cmpr/include/hal/ana_cmpr_periph.h index 3be9e7e444..d99d0518ff 100644 --- a/components/esp_hal_ana_cmpr/include/hal/ana_cmpr_periph.h +++ b/components/esp_hal_ana_cmpr/include/hal/ana_cmpr_periph.h @@ -11,6 +11,7 @@ #include "soc/interrupts.h" #if SOC_ANA_CMPR_SUPPORTED #include "soc/ana_cmpr_pins.h" +#include "hal/ana_cmpr_ll.h" #endif #ifdef __cplusplus @@ -25,7 +26,7 @@ typedef struct { const char *module_name; } ana_cmpr_periph_t; -extern const ana_cmpr_periph_t ana_cmpr_periph[SOC_ANA_CMPR_NUM]; +extern const ana_cmpr_periph_t ana_cmpr_periph[ANALOG_CMPR_LL_GET(INST_NUM)]; #endif #ifdef __cplusplus diff --git a/components/esp_hal_gpio/esp32h2/include/hal/gpio_caps.h b/components/esp_hal_gpio/esp32h2/include/hal/gpio_caps.h index a8b9168c75..ac0e1dcc6b 100644 --- a/components/esp_hal_gpio/esp32h2/include/hal/gpio_caps.h +++ b/components/esp_hal_gpio/esp32h2/include/hal/gpio_caps.h @@ -10,3 +10,6 @@ #define _GPIO_ETM_EVENT_CHANNELS_PER_GROUP 8 #define _GPIO_ETM_TASK_CHANNELS_PER_GROUP 8 + +// The GPIO interrupt is shared with the Analog Comparator unit +#define _GPIO_INTR_SHARED 1 diff --git a/components/esp_hal_gpio/esp32h21/include/hal/gpio_caps.h b/components/esp_hal_gpio/esp32h21/include/hal/gpio_caps.h index a8b9168c75..ac0e1dcc6b 100644 --- a/components/esp_hal_gpio/esp32h21/include/hal/gpio_caps.h +++ b/components/esp_hal_gpio/esp32h21/include/hal/gpio_caps.h @@ -10,3 +10,6 @@ #define _GPIO_ETM_EVENT_CHANNELS_PER_GROUP 8 #define _GPIO_ETM_TASK_CHANNELS_PER_GROUP 8 + +// The GPIO interrupt is shared with the Analog Comparator unit +#define _GPIO_INTR_SHARED 1 diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index f24c5132fb..5e93bf615c 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -639,14 +639,6 @@ config SOC_ETM_SUPPORT_SLEEP_RETENTION bool default y -config SOC_ANA_CMPR_NUM - int - default 1 - -config SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE - bool - default y - config SOC_ANA_CMPR_SUPPORT_ETM bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 3295356faf..0d7799e786 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -266,8 +266,6 @@ #define SOC_ETM_SUPPORT_SLEEP_RETENTION 1 /*------------------------- Analog Comparator CAPS ---------------------------*/ -#define SOC_ANA_CMPR_NUM (1U) -#define SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE (1) // Support positive/negative/any cross interrupt #define SOC_ANA_CMPR_SUPPORT_ETM (1) /*-------------------------- I2C CAPS ----------------------------------------*/ diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index bd61007d34..12ddc4a8a1 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -503,14 +503,6 @@ config SOC_RTCIO_WAKE_SUPPORTED bool default y -config SOC_ANA_CMPR_NUM - int - default 1 - -config SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE - bool - default y - config SOC_ANA_CMPR_SUPPORT_ETM bool default y diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index a5f9120d99..46f5e8f91b 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -216,8 +216,6 @@ #define SOC_RTCIO_WAKE_SUPPORTED 1 /*------------------------- Analog Comparator CAPS ---------------------------*/ -#define SOC_ANA_CMPR_NUM (1U) -#define SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE (1) // Support positive/negative/any cross interrupt #define SOC_ANA_CMPR_SUPPORT_ETM (1) /*-------------------------- I2C CAPS ----------------------------------------*/ diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 01eedbdd21..936d1e437d 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -563,14 +563,6 @@ config SOC_ETM_SUPPORT_SLEEP_RETENTION bool default y -config SOC_ANA_CMPR_NUM - int - default 1 - -config SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO - bool - default y - config SOC_I2C_NUM int default 2 diff --git a/components/soc/esp32h2/include/soc/clk_tree_defs.h b/components/soc/esp32h2/include/soc/clk_tree_defs.h index f7dccfaa97..166de69297 100644 --- a/components/soc/esp32h2/include/soc/clk_tree_defs.h +++ b/components/soc/esp32h2/include/soc/clk_tree_defs.h @@ -382,7 +382,7 @@ typedef enum { #define SOC_ANA_CMPR_CLKS {SOC_MOD_CLK_PLL_F48M, SOC_MOD_CLK_XTAL} /** - * @brief Sigma Delta Modulator clock source + * @brief Analog Comparator clock source */ typedef enum { ANA_CMPR_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL, /*!< Select XTAL clock as the source clock */ diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 1b9b9056a7..11a9fbc6f8 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -258,10 +258,6 @@ /*-------------------------- ETM CAPS -----------------------------------*/ #define SOC_ETM_SUPPORT_SLEEP_RETENTION 1 -/*------------------------- Analog Comparator CAPS ---------------------------*/ -#define SOC_ANA_CMPR_NUM (1U) -#define SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO (1) - /*-------------------------- I2C CAPS ----------------------------------------*/ #define SOC_I2C_NUM (2U) #define SOC_HP_I2C_NUM (2U) diff --git a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in index 24f52c1cab..1e57246b0d 100644 --- a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in @@ -3,6 +3,10 @@ # using gen_soc_caps_kconfig.py, do not edit manually ##################################################### +config SOC_ANA_CMPR_SUPPORTED + bool + default y + config SOC_DEDICATED_GPIO_SUPPORTED bool default y @@ -443,14 +447,6 @@ config SOC_RTCIO_HOLD_SUPPORTED bool default y -config SOC_ANA_CMPR_NUM - int - default 1 - -config SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO - bool - default y - config SOC_I2C_NUM int default 2 diff --git a/components/soc/esp32h21/include/soc/ana_cmpr_pins.h b/components/soc/esp32h21/include/soc/ana_cmpr_pins.h new file mode 100644 index 0000000000..84bc12cba7 --- /dev/null +++ b/components/soc/esp32h21/include/soc/ana_cmpr_pins.h @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + */ + +#pragma once + +#define ANA_CMPR0_EXT_REF_GPIO 6 /*!< The GPIO that can be used as external reference voltage */ +#define ANA_CMPR0_SRC_GPIO 7 /*!< The GPIO that used for inputting the source signal to compare */ diff --git a/components/soc/esp32h21/include/soc/clk_tree_defs.h b/components/soc/esp32h21/include/soc/clk_tree_defs.h index cdd7fb5352..ca0acdbd2d 100644 --- a/components/soc/esp32h21/include/soc/clk_tree_defs.h +++ b/components/soc/esp32h21/include/soc/clk_tree_defs.h @@ -204,6 +204,22 @@ typedef enum { SDM_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F48M, /*!< Select PLL_F48M as the default clock choice */ } soc_periph_sdm_clk_src_t; +///////////////////////////////////////////////////Analog Comparator//////////////////////////////////////////////////// + +/** + * @brief Array initializer for all supported clock sources of Analog Comparator + */ +#define SOC_ANA_CMPR_CLKS {SOC_MOD_CLK_PLL_F48M, SOC_MOD_CLK_XTAL} + +/** + * @brief Analog Comparator clock source + */ +typedef enum { + ANA_CMPR_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL, /*!< Select XTAL clock as the source clock */ + ANA_CMPR_CLK_SRC_PLL_F48M = SOC_MOD_CLK_PLL_F48M, /*!< Select PLL_F48M clock as the source clock */ + ANA_CMPR_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F48M, /*!< Select PLL_F48M as the default clock choice */ +} soc_periph_ana_cmpr_clk_src_t; + //////////////////////////////////////////////////GPIO Glitch Filter//////////////////////////////////////////////////// /** diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index 8d94bd9bb4..a251947d5a 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -24,7 +24,7 @@ /*-------------------------- COMMON CAPS ---------------------------------------*/ // #define SOC_ADC_SUPPORTED 1 //TODO: [ESP32H21] IDF-11589, IDF-11592 -// #define SOC_ANA_CMPR_SUPPORTED 1 +#define SOC_ANA_CMPR_SUPPORTED 1 #define SOC_DEDICATED_GPIO_SUPPORTED 1 #define SOC_UART_SUPPORTED 1 #define SOC_GDMA_SUPPORTED 1 @@ -237,10 +237,6 @@ #define SOC_RTCIO_PIN_COUNT (7U) #define SOC_RTCIO_HOLD_SUPPORTED (1) -/*------------------------- Analog Comparator CAPS ---------------------------*/ -#define SOC_ANA_CMPR_NUM (1U) -#define SOC_ANA_CMPR_INTR_SHARE_WITH_GPIO (1) - /*-------------------------- I2C CAPS ----------------------------------------*/ #define SOC_I2C_NUM (2U) #define SOC_HP_I2C_NUM (2U) diff --git a/components/soc/esp32h21/register/soc/gpio_ext_struct.h b/components/soc/esp32h21/register/soc/gpio_ext_struct.h index 5f3f2f5e01..e1567e8fe5 100644 --- a/components/soc/esp32h21/register/soc/gpio_ext_struct.h +++ b/components/soc/esp32h21/register/soc/gpio_ext_struct.h @@ -575,20 +575,20 @@ typedef struct { uint32_t reserved_000; volatile gpio_sd_dev_t sigma_delta; uint32_t reserved_018[16]; - volatile gpio_ext_pad_comp_config_0_reg_t ext_pad_comp_config_0; - volatile gpio_ext_pad_comp_filter_0_reg_t ext_pad_comp_filter_0; + volatile gpio_ext_pad_comp_config_0_reg_t pad_comp_config; + volatile gpio_ext_pad_comp_filter_0_reg_t pad_comp_filter; uint32_t reserved_060[30]; volatile gpio_glitch_filter_dev_t glitch_filter; uint32_t reserved_0f8[8]; volatile gpio_etm_dev_t etm; uint32_t reserved_170[24]; - volatile gpio_ext_int_raw_reg_t ext_int_raw; - volatile gpio_ext_int_st_reg_t ext_int_st; - volatile gpio_ext_int_ena_reg_t ext_int_ena; - volatile gpio_ext_int_clr_reg_t ext_int_clr; - volatile gpio_ext_pin_ctrl_reg_t ext_pin_ctrl; + volatile gpio_ext_int_raw_reg_t int_raw; + volatile gpio_ext_int_st_reg_t int_st; + volatile gpio_ext_int_ena_reg_t int_ena; + volatile gpio_ext_int_clr_reg_t int_clr; + volatile gpio_ext_pin_ctrl_reg_t pin_ctrl; uint32_t reserved_1e4[6]; - volatile gpio_ext_version_reg_t ext_version; + volatile gpio_ext_version_reg_t version; } gpio_ext_dev_t; extern gpio_sd_dev_t SDM; diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 956fc93192..c30ff9a349 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -771,14 +771,6 @@ config SOC_ETM_SUPPORT_SLEEP_RETENTION bool default y -config SOC_ANA_CMPR_NUM - int - default 2 - -config SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE - bool - default y - config SOC_ANA_CMPR_SUPPORT_ETM bool default y diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 4e3fe0d844..8a150fe99c 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -303,8 +303,6 @@ #define SOC_ETM_SUPPORT_SLEEP_RETENTION 1 /*------------------------- Analog Comparator CAPS ---------------------------*/ -#define SOC_ANA_CMPR_NUM (2) -#define SOC_ANA_CMPR_CAN_DISTINGUISH_EDGE (1) // Support positive/negative/any cross interrupt #define SOC_ANA_CMPR_SUPPORT_ETM (1) /*-------------------------- I2C CAPS ----------------------------------------*/ diff --git a/docs/conf_common.py b/docs/conf_common.py index e5a48125f5..fdac8e0565 100644 --- a/docs/conf_common.py +++ b/docs/conf_common.py @@ -200,6 +200,14 @@ I3C_DOCS = [ 'api-reference/peripherals/i3c_master.rst', ] +LEDC_DOCS = [ + 'api-reference/peripherals/ledc.rst', +] + +GPTIMER_DOCS = [ + 'api-reference/peripherals/gptimer.rst', +] + CORDIC_DOCS = ['api-reference/peripherals/cordic.rst'] SPI_DOCS = [ @@ -376,6 +384,8 @@ conditional_include_dict = { 'SOC_TWAI_SUPPORTED': TWAI_DOCS, 'SOC_I2C_SUPPORTED': I2C_DOCS, 'SOC_I3C_MASTER_SUPPORTED': I3C_DOCS, + 'SOC_LEDC_SUPPORTED': LEDC_DOCS, + 'SOC_GPTIMER_SUPPORTED': GPTIMER_DOCS, 'SOC_GPSPI_SUPPORTED': SPI_DOCS, 'SOC_I2S_SUPPORTED': I2S_DOCS, 'SOC_LP_I2S_SUPPORTED': LP_I2S_DOCS, diff --git a/docs/docs_not_updated/esp32h21.txt b/docs/docs_not_updated/esp32h21.txt index 884fe94591..0b43959951 100644 --- a/docs/docs_not_updated/esp32h21.txt +++ b/docs/docs_not_updated/esp32h21.txt @@ -102,20 +102,16 @@ api-reference/bluetooth/classic_bt.rst api-reference/bluetooth/esp_a2dp.rst api-reference/bluetooth/esp_hf_defs.rst api-reference/peripherals/cap_touch_sens.rst -api-reference/peripherals/index.rst api-reference/peripherals/sdio_slave.rst api-reference/peripherals/temp_sensor.rst api-reference/peripherals/camera_driver.rst api-reference/peripherals/adc_oneshot.rst api-reference/peripherals/sdspi_share.rst -api-reference/peripherals/ana_cmpr.rst api-reference/peripherals/adc_continuous.rst api-reference/peripherals/sdspi_host.rst api-reference/peripherals/vad.rst -api-reference/peripherals/isp.rst api-reference/peripherals/parlio.rst api-reference/peripherals/adc_calibration.rst -api-reference/peripherals/lp_i2s.rst api-reference/peripherals/spi_flash/index.rst api-reference/peripherals/spi_flash/spi_flash_concurrency.rst api-reference/peripherals/spi_flash/spi_flash_override_driver.rst diff --git a/docs/en/api-reference/peripherals/ana_cmpr.rst b/docs/en/api-reference/peripherals/ana_cmpr.rst index a67a2cb289..13a1db9c35 100644 --- a/docs/en/api-reference/peripherals/ana_cmpr.rst +++ b/docs/en/api-reference/peripherals/ana_cmpr.rst @@ -3,8 +3,9 @@ Analog Comparator :link_to_translation:`zh_CN:[中文]` -{IDF_TARGET_ANA_CMPR_SRC_CHAN0: default="NOT UPDATED", esp32h2="GPIO11", esp32p4="GPIO52", esp32c5="GPIO9", esp32c61="GPIO9"} -{IDF_TARGET_ANA_CMPR_EXT_REF_CHAN0: default="NOT UPDATED", esp32h2="GPIO10", esp32p4="GPIO51", esp32c5="GPIO8", esp32c61="GPIO8"} +{IDF_TARGET_ANA_CMPR_UNITS: default="1", esp32p4="2"} +{IDF_TARGET_ANA_CMPR_SRC_CHAN0: default="NOT UPDATED", esp32h2="GPIO11", esp32p4="GPIO52", esp32c5="GPIO9", esp32c61="GPIO9", esp32h21="GPIO7"} +{IDF_TARGET_ANA_CMPR_EXT_REF_CHAN0: default="NOT UPDATED", esp32h2="GPIO10", esp32p4="GPIO51", esp32c5="GPIO8", esp32c61="GPIO8", esp32h21="GPIO6"} {IDF_TARGET_ANA_CMPR_SRC_CHAN1: default="NOT UPDATED", esp32p4="GPIO54"} {IDF_TARGET_ANA_CMPR_EXT_REF_CHAN1: default="NOT UPDATED", esp32p4="GPIO53"} @@ -15,7 +16,7 @@ Analog comparator is a peripheral that can be used to compare a source signal wi Under the scenario of comparing the analog signals, the integrated analog comparator is a cost effective scheme to replace an operational amplifier. But unlike the continuous comparing of the operational amplifier, ESP analog comparator is driven by a source clock, which decides the sampling frequency. -Analog comparator on {IDF_TARGET_NAME} has {IDF_TARGET_SOC_ANA_CMPR_NUM} unit(s), the channels in the unit(s) are: +Analog comparator on {IDF_TARGET_NAME} has {IDF_TARGET_ANA_CMPR_UNITS} unit(s), the channels in the unit(s) are: **UNIT0** diff --git a/docs/en/api-reference/peripherals/index.rst b/docs/en/api-reference/peripherals/index.rst index 727d3ba135..3dcd868476 100644 --- a/docs/en/api-reference/peripherals/index.rst +++ b/docs/en/api-reference/peripherals/index.rst @@ -18,7 +18,7 @@ Peripherals API :SOC_ECDSA_SUPPORTED: ecdsa :SOC_ETM_SUPPORTED: etm gpio - gptimer + :SOC_GPTIMER_SUPPORTED: gptimer :SOC_DEDICATED_GPIO_SUPPORTED: dedic_gpio :SOC_HMAC_SUPPORTED: hmac :SOC_DIG_SIGN_SUPPORTED: ds @@ -30,7 +30,7 @@ Peripherals API :SOC_KEY_MANAGER_SUPPORTED: key_manager lcd/index :SOC_GP_LDO_SUPPORTED: ldo_regulator - ledc + :SOC_LEDC_SUPPORTED: ledc :SOC_MCPWM_SUPPORTED: mcpwm :SOC_PARLIO_SUPPORTED: parlio/index :SOC_PCNT_SUPPORTED: pcnt @@ -50,7 +50,7 @@ Peripherals API :SOC_TEMP_SENSOR_SUPPORTED: temp_sensor :SOC_TOUCH_SENSOR_SUPPORTED: cap_touch_sens :SOC_TWAI_SUPPORTED: twai - uart + :SOC_UART_SUPPORTED: uart :SOC_USB_OTG_SUPPORTED: USB Device Stack :SOC_USB_OTG_SUPPORTED: USB Host diff --git a/docs/zh_CN/api-reference/peripherals/ana_cmpr.rst b/docs/zh_CN/api-reference/peripherals/ana_cmpr.rst index 4316149f0d..8378e403d6 100644 --- a/docs/zh_CN/api-reference/peripherals/ana_cmpr.rst +++ b/docs/zh_CN/api-reference/peripherals/ana_cmpr.rst @@ -3,10 +3,11 @@ :link_to_translation:`en:[English]` -{IDF_TARGET_ANA_CMPR_SRC_CHAN0: default="未更新", esp32h2="GPIO11", esp32p4="GPIO52", esp32c5="GPIO9", esp32c61="GPIO9"} -{IDF_TARGET_ANA_CMPR_EXT_REF_CHAN0: default="未更新", esp32h2="GPIO10", esp32p4="GPIO51", esp32c5="GPIO8", esp32c61="GPIO8"} -{IDF_TARGET_ANA_CMPR_SRC_CHAN1: default="未更新", esp32p4="GPIO54"} -{IDF_TARGET_ANA_CMPR_EXT_REF_CHAN1: default="未更新", esp32p4="GPIO53"} +{IDF_TARGET_ANA_CMPR_UNITS: default="1", esp32p4="2"} +{IDF_TARGET_ANA_CMPR_SRC_CHAN0: default="NOT UPDATED", esp32h2="GPIO11", esp32p4="GPIO52", esp32c5="GPIO9", esp32c61="GPIO9", esp32h21="GPIO7"} +{IDF_TARGET_ANA_CMPR_EXT_REF_CHAN0: default="NOT UPDATED", esp32h2="GPIO10", esp32p4="GPIO51", esp32c5="GPIO8", esp32c61="GPIO8", esp32h21="GPIO6"} +{IDF_TARGET_ANA_CMPR_SRC_CHAN1: default="NOT UPDATED", esp32p4="GPIO54"} +{IDF_TARGET_ANA_CMPR_EXT_REF_CHAN1: default="NOT UPDATED", esp32p4="GPIO53"} 简介 ---- @@ -15,7 +16,7 @@ 当用于比较模拟信号时,集成模拟比较器可以低成本替代运算放大器。不同于运算放大器的连续比较,ESP 模拟比较器由时钟源驱动,其采样频率取决于时钟的频率。 -{IDF_TARGET_NAME} 上的模拟比较器有 {IDF_TARGET_SOC_ANA_CMPR_NUM} 个单元,单元中的通道如下: +{IDF_TARGET_NAME} 上的模拟比较器有 {IDF_TARGET_ANA_CMPR_UNITS} 个单元,单元中的通道如下: **UNIT0** diff --git a/docs/zh_CN/api-reference/peripherals/index.rst b/docs/zh_CN/api-reference/peripherals/index.rst index 36af5db596..ba506840ee 100644 --- a/docs/zh_CN/api-reference/peripherals/index.rst +++ b/docs/zh_CN/api-reference/peripherals/index.rst @@ -18,7 +18,7 @@ :SOC_ECDSA_SUPPORTED: ecdsa :SOC_ETM_SUPPORTED: etm gpio - gptimer + :SOC_GPTIMER_SUPPORTED: gptimer :SOC_DEDICATED_GPIO_SUPPORTED: dedic_gpio :SOC_HMAC_SUPPORTED: hmac :SOC_DIG_SIGN_SUPPORTED: ds @@ -30,7 +30,7 @@ :SOC_KEY_MANAGER_SUPPORTED: key_manager lcd/index :SOC_GP_LDO_SUPPORTED: ldo_regulator - ledc + :SOC_LEDC_SUPPORTED: ledc :SOC_MCPWM_SUPPORTED: mcpwm :SOC_PARLIO_SUPPORTED: parlio/index :SOC_PCNT_SUPPORTED: pcnt @@ -50,7 +50,7 @@ :SOC_TEMP_SENSOR_SUPPORTED: temp_sensor :SOC_TOUCH_SENSOR_SUPPORTED: cap_touch_sens :SOC_TWAI_SUPPORTED: twai - uart + :SOC_UART_SUPPORTED: uart :SOC_USB_OTG_SUPPORTED: USB 设备栈 :SOC_USB_OTG_SUPPORTED: USB 主机 diff --git a/examples/peripherals/analog_comparator/README.md b/examples/peripherals/analog_comparator/README.md index c0f5fb6a77..946bab1075 100644 --- a/examples/peripherals/analog_comparator/README.md +++ b/examples/peripherals/analog_comparator/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32-C5 | ESP32-C61 | ESP32-H2 | ESP32-P4 | -| ----------------- | -------- | --------- | -------- | -------- | +| Supported Targets | ESP32-C5 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-P4 | +| ----------------- | -------- | --------- | -------- | --------- | -------- | # Analog Comparator Example @@ -19,7 +19,7 @@ This example is going to show how to use the Analog Comparator. The example togg * A development board with any supported Espressif SOC chip (see `Supported Targets` table above) * A USB cable for power supply and programming -* A device to generate the source signal. For example, you can use a ESP SoC that support DAC peripheral (like ESP32 or ESP32S2) to generate source signal, or just use a signal generator. +* A signal generator for generating the source signal #### Required Additionally for External Reference @@ -27,30 +27,26 @@ This example is going to show how to use the Analog Comparator. The example togg ### Example Connection -Let's take ESP32-H2 and ESP32 for example, and we use the DAC on ESP32 as the signal generator (you can use a real signal generator instead if you have one). - #### Internal Reference -Download this example into ESP32-H2 and any DAC examples in `examples/peripherals/dac` directory into ESP32. - ``` - ┌──────────────┐ ┌──────────────┐ - │ ESP32-H2 │ │ ESP32 │ - │ │ source signal │ │ -┌────┤GPIO0 GPIO11│◄────┬──────────┤GPIO25 │ -│ │ │ │ │ │ -│ │ GND├─────┼────┬─────┤GND │ -│ │ │ │ │ │ │ -│ └──────────────┘ │ │ └──────────────┘ -│ │ │ -│ ┌──────────────┐ │ │ -│ │ Oscilloscope │ │ │ -│ │ │ │ │ -└───►│Probe1 Probe2│◄────┘ │ - │ │ │ - │ GND├──────────┘ - │ │ - └──────────────┘ + +--------------+ +--------------+ + | ESP Board | | Signal Gen | + | | source signal | | ++----+GPIO Src In|<----+----------+OUT | +| | | | | | +| | GND+-----+----+-----+GND | +| | | | | | | +| +--------------+ | | +--------------+ +| | | +| +--------------+ | | +| | Oscilloscope | | | +| | | | | ++--->|Probe1 Probe2|<----+ | + | | | + | GND+----------+ + | | + +--------------+ ``` #### External Reference @@ -58,55 +54,29 @@ Download this example into ESP32-H2 and any DAC examples in `examples/peripheral For the static external reference, we can use resistor divider to get the static voltage. ``` - ┌──────────────┐ ┌──────────────┐ - │ ESP32-H2 │ │ ESP32 │ - │ │ source signal │ │ -┌────┤GPIO0 GPIO11│◄────┬──────────┤GPIO25 │ -│ │ │ ref│signal │ │ -│ │ GPIO10│◄────┼──────┐ ┌─┤GND │ -│ │ │ │ │ │ │ │ -│ │ GND├─────┼─┬────┼─┘ └──────────────┘ -│ │ │ │ │ │ VDD -│ └──────────────┘ │ │ │ ─┬─ -│ │ │ │ │ -│ │ │ │ ├┐ -│ ┌──────────────┐ │ │ │ ││R1 -│ │ Oscilloscope │ │ │ │ ├┘ -│ │ │ │ │ └──────────┤ -└───►│Probe1 Probe2│◄────┘ │ │ - │ │ │ ├┐ - │ GND├───────┤ ││R2 - │ │ │ ├┘ - └──────────────┘ │ │ - └───────────────┤ - │ - ─┴─ - GND -``` - -Also, we can generate a different signal on another DAC channel on ESP32, you can customize your DAC wave using `examples/peripherals/dac/dac_continuous/signal_generator` example. - -``` - ┌──────────────┐ ┌──────────────┐ - │ ESP32-H2 │ │ ESP32 │ - │ │ source signal │ │ -┌────┤GPIO0 GPIO11│◄────┬──────────┤GPIO25 │ -│ │ │ ref│signal │ │ -│ │ GPIO10│◄────┼──────────┤GPIO26 │ -│ │ │ │ │ │ -│ │ GND├─────┼───┬──────┤GND │ -│ │ │ │ │ │ │ -│ └──────────────┘ │ │ └──────────────┘ -│ │ │ -│ │ │ -│ ┌──────────────┐ │ │ -│ │ Oscilloscope │ │ │ -│ │ │ │ │ -└───►│Probe1 Probe2│◄────┘ │ - │ │ │ - │ GND├─────────┘ - │ │ - └──────────────┘ + +--------------+ +--------------+ + | ESP Board | | Signal Gen | + | | source signal | | ++----+GPIO Src In|<----+----------+OUT | +| | | ref|signal | | +| | Ref In|<----+------+ +-+GND | +| | | | | | | | +| | GND+-----+-+----+-+ +--------------+ +| | | | | | VDD +| +--------------+ | | | -+- +| | | | | +| | | | ++ +| +--------------+ | | | ||R1 +| | Oscilloscope | | | | ++ +| | | | | +----------+ ++--->|Probe1 Probe2|<----+ | | + | | | ++ + | GND+-------+ ||R2 + | | | ++ + +--------------+ | | + +---------------+ + | + -+- ``` ### Configure the Project diff --git a/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h b/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h index 35e6ebff20..ad2c3b685d 100644 --- a/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h +++ b/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h @@ -34,7 +34,8 @@ void example_init_monitor_gpio(void); * CPU won't be involved by using Event Task Matrix, so it can achieve relatively higher interrupt frequency */ void example_analog_comparator_etm_app(void); -#endif + +#else /** * @brief Set or clear the monitor GPIO in the cross interrupt callback. @@ -43,6 +44,7 @@ void example_analog_comparator_etm_app(void); * But as the operations are done in callback, CPU is involved, so it can only achieve a low interrupt frequency */ void example_analog_comparator_intr_app(void); +#endif #ifdef __cplusplus }