rtc_ctrl.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include "esp_err.h"
  9. #include "esp_intr_alloc.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #define RTC_INTR_FLAG_IRAM (BIT(0)) /*< Some rtc interrupts can be called with cache disabled */
  14. /**
  15. * @brief Register a handler for specific RTC_CNTL interrupts
  16. *
  17. * Multiple handlers can be registered using this function. Whenever an
  18. * RTC interrupt happens, all handlers with matching rtc_intr_mask values
  19. * will be called.
  20. *
  21. * @param handler handler function to call
  22. * @param handler_arg argument to be passed to the handler
  23. * @param rtc_intr_mask combination of RTC_CNTL_*_INT_ENA bits indicating the
  24. * sources to call the handler for
  25. * @param flags An ORred mask of the RTC_INTR_FLAG_* defines. You can pass different
  26. * flags to it to realize different purpose. If 0, the interrupt will
  27. * not handle anything special. If you pass `RTC_INTR_FLAG_IRAM`, means
  28. * the interrupt can be triggered with cache disabled.
  29. * @return
  30. * - ESP_OK on success
  31. * - ESP_ERR_NO_MEM not enough memory to allocate handler structure
  32. * - other errors returned by esp_intr_alloc
  33. */
  34. esp_err_t rtc_isr_register(intr_handler_t handler, void* handler_arg,
  35. uint32_t rtc_intr_mask, uint32_t flags);
  36. /**
  37. * @brief Deregister the handler previously registered using rtc_isr_register
  38. * @param handler handler function to call (as passed to rtc_isr_register)
  39. * @param handler_arg argument of the handler (as passed to rtc_isr_register)
  40. * @return
  41. * - ESP_OK on success
  42. * - ESP_ERR_INVALID_STATE if a handler matching both handler and
  43. * handler_arg isn't registered
  44. */
  45. esp_err_t rtc_isr_deregister(intr_handler_t handler, void* handler_arg);
  46. /**
  47. * @brief Disable the RTC interrupt that is allowed to be executed when cache is disabled.
  48. * cache disabled. Internal interrupt handle function will call this function in interrupt
  49. * handler function. Disable bits when `esp_intr_noniram_disable` is called.
  50. *
  51. * @param cpu CPU number.
  52. */
  53. void rtc_isr_noniram_disable(uint32_t cpu);
  54. /**
  55. * @brief Enable the RTC interrupt that is allowed to be executed when cache is disabled.
  56. * cache disabled. Internal interrupt handle function will call this function in interrupt
  57. * handler function. Enable bits when `esp_intr_noniram_enable` is called.
  58. *
  59. * @param cpu CPU number.
  60. */
  61. void rtc_isr_noniram_enable(uint32_t cpu);
  62. #ifdef __cplusplus
  63. }
  64. #endif