rtc_hal.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include "soc/soc_caps.h"
  9. #include "hal/gpio_types.h"
  10. #include "hal/rtc_cntl_ll.h"
  11. #if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32C2
  12. #include "hal/rtc_io_ll.h"
  13. #endif
  14. typedef struct rtc_cntl_sleep_retent {
  15. #if SOC_PM_SUPPORT_CPU_PD
  16. void *cpu_pd_mem; /* Internal ram address for cpu retention */
  17. #endif // SOC_PM_SUPPORT_CPU_PD
  18. #if SOC_PM_SUPPORT_TAGMEM_PD
  19. struct {
  20. void *link_addr; /* Internal ram address for tagmem retention */
  21. struct {
  22. uint32_t start_point: 8, /* the row of start for i-cache tag memory */
  23. vld_size: 8, /* valid size of i-cache tag memory, unit: 4 i-cache tagmem blocks */
  24. size: 8, /* i-cache tag memory size, unit: 4 i-cache tagmem blocks */
  25. enable: 1; /* enable or disable i-cache tagmem retention */
  26. } icache;
  27. struct {
  28. uint32_t start_point: 9, /* the row of start for d-cache tag memory */
  29. vld_size: 9, /* valid size of d-cache tag memory, unit: 4 d-cache tagmem blocks */
  30. size: 9, /* d-cache tag memory size, unit: 4 d-cache tagmem blocks */
  31. enable: 1; /* enable or disable d-cache tagmem retention */
  32. } dcache;
  33. } tagmem;
  34. #endif // SOC_PM_SUPPORT_TAGMEM_PD
  35. } rtc_cntl_sleep_retent_t;
  36. #define RTC_HAL_DMA_LINK_NODE_SIZE (16)
  37. #if SOC_PM_SUPPORT_EXT_WAKEUP
  38. #define rtc_hal_ext1_get_wakeup_pins() rtc_cntl_ll_ext1_get_wakeup_pins()
  39. #define rtc_hal_ext1_set_wakeup_pins(mask, mode) rtc_cntl_ll_ext1_set_wakeup_pins(mask, mode)
  40. #define rtc_hal_ext1_clear_wakeup_pins() rtc_cntl_ll_ext1_clear_wakeup_pins()
  41. #endif
  42. #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
  43. #define rtc_hal_gpio_get_wakeup_pins() rtc_cntl_ll_gpio_get_wakeup_pins()
  44. #define rtc_hal_gpio_clear_wakeup_pins() rtc_cntl_ll_gpio_clear_wakeup_pins()
  45. #define rtc_hal_gpio_set_wakeup_pins() rtc_cntl_ll_gpio_set_wakeup_pins()
  46. #endif
  47. #define rtc_hal_set_wakeup_timer(ticks) rtc_cntl_ll_set_wakeup_timer(ticks)
  48. void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next);
  49. #if SOC_PM_SUPPORT_CPU_PD
  50. void rtc_cntl_hal_enable_cpu_retention(void *addr);
  51. void rtc_cntl_hal_disable_cpu_retention(void *addr);
  52. #endif
  53. #if SOC_PM_SUPPORT_TAGMEM_PD
  54. void rtc_cntl_hal_enable_tagmem_retention(void *addr);
  55. void rtc_cntl_hal_disable_tagmem_retention(void *addr);
  56. #endif
  57. /*
  58. * Enable wakeup from ULP coprocessor.
  59. */
  60. #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable()
  61. #define rtc_hal_ulp_int_clear() rtc_cntl_ll_ulp_int_clear()