Skip to content

arch/risc-v/espressif: Add Analog Comparator for esp32[-h2|-p4]#18926

Merged
linguini1 merged 3 commits into
apache:masterfrom
eren-terzioglu:feature/esp_analog_comp
May 21, 2026
Merged

arch/risc-v/espressif: Add Analog Comparator for esp32[-h2|-p4]#18926
linguini1 merged 3 commits into
apache:masterfrom
eren-terzioglu:feature/esp_analog_comp

Conversation

@eren-terzioglu
Copy link
Copy Markdown
Contributor

Summary

  • Docs/platforms/risc-v: Add Analog Comparator docs for esp32[-h2|-p4]

Add Analog Comparator docs for esp32h2 and esp32p4

  • boards/risc-v/espressif: Add Analog Comparator board support for esp32[-h2|-p4]

Add Analog Comparator board support for esp32p4 and esp32h2

  • arch/risc-v/espressif: Add Analog Comparator for esp32[-h2|-p4]

Add analog comparator support for esp32p4 and esp32h2

Impact

Impact on user: Yes, analog comparator support added

Impact on build: No

Impact on hardware: Yes, analog comparator support added

Impact on documentation: Yes, related docs added

Impact on security: No

Impact on compatibility: No

Testing

Config used:

esp32p4-function-ev-board:analog_cmpr
esp32h2-devkit:analog_cmpr

With these options:

CONFIG_DEBUG_ANALOG
CONFIG_DEBUG_ANALOG_ERROR
CONFIG_DEBUG_ANALOG_INFO
CONFIG_DEBUG_ANALOG_WARN
CONFIG_DEBUG_FEATURES

Building

Command to build:

make -j distclean && ./tools/configure.sh esp32p4-function-ev-board:analog_cmpr && kconfig-tweak -e CONFIG_DEBUG_ANALOG && kconfig-tweak -e CONFIG_DEBUG_ANALOG_ERROR && kconfig-tweak -e CONFIG_DEBUG_ANALOG_INFO && kconfig-tweak -e CONFIG_DEBUG_ANALOG_WARN && kconfig-tweak -e CONFIG_DEBUG_FEATURES && make olddefconfig && make ESPTOOL_BINDIR=./ -s -j

Running

SRC pin of comparator (GPIO52->P4 GPIO11->H2) connected to GND at first, after that pin connected to 3v3

Snippet used to test is looking like this:

#include <nuttx/config.h>
#include <nuttx/analog/comp.h>
#include <inttypes.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <driver/gpio.h>


int main(int argc, FAR char *argv[])
{
  int fd;
  int ret;
  int res;

  fd = open("/dev/anacmpr0", O_RDONLY);

  while(1)
    {
      ret = read(fd, &res, sizeof(res));
      if (ret != 0)
        {
           printf("Result: %ld\n", res);
        }
    }
  ret = read(fd, &res, sizeof(res));

  return OK;
}

Results

Output:

Result: 0
esp_ana_cmpr_callback: Comparator unit0: Positive cross event triggered
Result: 1
esp_ana_cmpr_callback: Comparator unit0: Negative cross event triggered
Result: 0

Add analog comparator support for esp32p4 and esp32h2

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
…2[-h2|-p4]

Add Analog Comparator board support for esp32p4 and esp32h2

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
Add Analog Comparator docs for esp32h2 and esp32p4

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
@eren-terzioglu eren-terzioglu changed the title Feature/esp analog comp arch/risc-v/espressif: Add Analog Comparator for esp32[-h2|-p4] May 21, 2026
@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: L The size of the change in this PR is large Board: risc-v labels May 21, 2026
@linguini1 linguini1 merged commit 50352c5 into apache:master May 21, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Area: Documentation Improvements or additions to documentation Board: risc-v Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants