ana_cmpr_example_main.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Unlicense OR CC0-1.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include "sdkconfig.h"
  9. #include "soc/soc_caps.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #define EXAMPLE_ANA_CMPR_UNIT 0 // Analog Comparator unit
  14. #define EXAMPLE_WAIT_TIME_PROP (0.1) // The wait time proportion in one relative signal period
  15. #define EXAMPLE_WAITE_TIME_US(freq_approx) (uint32_t)(1000000 * EXAMPLE_WAIT_TIME_PROP / (freq_approx))
  16. #define EXAMPLE_MONITOR_GPIO_NUM (0) // The gpio to monitor the on cross callback
  17. void example_init_monitor_gpio(void);
  18. #if CONFIG_EXAMPLE_USE_ETM
  19. /**
  20. * @brief Set or clear the monitor GPIO via Event Task Matrix when cross interrupt triggers.
  21. * @note The interrupt of analog comparator is regarded as Event,
  22. * and the the operation of setting/clearing the GPIO is regarded as the corresponding task of the event.
  23. * CPU won't be involved by using Event Task Matrix, so it can achieve relatively higher interrupt frequency
  24. */
  25. void example_analog_comparator_etm_app(void);
  26. #endif
  27. /**
  28. * @brief Set or clear the monitor GPIO in the cross interrupt callback.
  29. * @note The GPIO level is set manually in the callback.
  30. * It's more flexible so that we can realize some operation like hysteresis,
  31. * But as the operations are done in callback, CPU is involved, so it can only achieve a low interrupt frequency
  32. */
  33. void example_analog_comparator_intr_app(void);
  34. #ifdef __cplusplus
  35. }
  36. #endif