rtc_hal.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "soc/soc_caps.h"
  16. #include "hal/gpio_types.h"
  17. #include "hal/rtc_cntl_ll.h"
  18. #if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
  19. #include "hal/rtc_io_ll.h"
  20. #endif
  21. typedef struct rtc_cntl_sleep_retent {
  22. #if SOC_PM_SUPPORT_CPU_PD
  23. void *cpu_pd_mem; /* Internal ram address for cpu retention */
  24. #endif // SOC_PM_SUPPORT_CPU_PD
  25. #if SOC_PM_SUPPORT_TAGMEM_PD
  26. struct {
  27. void *link_addr; /* Internal ram address for tagmem retention */
  28. struct {
  29. uint32_t start_point: 8, /* the row of start for i-cache tag memory */
  30. vld_size: 8, /* valid size of i-cache tag memory, unit: 4 i-cache tagmem blocks */
  31. size: 8, /* i-cache tag memory size, unit: 4 i-cache tagmem blocks */
  32. enable: 1; /* enable or disable i-cache tagmem retention */
  33. } icache;
  34. struct {
  35. uint32_t start_point: 9, /* the row of start for d-cache tag memory */
  36. vld_size: 9, /* valid size of d-cache tag memory, unit: 4 d-cache tagmem blocks */
  37. size: 9, /* d-cache tag memory size, unit: 4 d-cache tagmem blocks */
  38. enable: 1; /* enable or disable d-cache tagmem retention */
  39. } dcache;
  40. } tagmem;
  41. #endif // SOC_PM_SUPPORT_TAGMEM_PD
  42. } rtc_cntl_sleep_retent_t;
  43. #define RTC_HAL_DMA_LINK_NODE_SIZE (16)
  44. #if SOC_PM_SUPPORT_EXT_WAKEUP
  45. #define rtc_hal_ext1_get_wakeup_pins() rtc_cntl_ll_ext1_get_wakeup_pins()
  46. #define rtc_hal_ext1_set_wakeup_pins(mask, mode) rtc_cntl_ll_ext1_set_wakeup_pins(mask, mode)
  47. #define rtc_hal_ext1_clear_wakeup_pins() rtc_cntl_ll_ext1_clear_wakeup_pins()
  48. #endif
  49. #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
  50. #define rtc_hal_gpio_get_wakeup_pins() rtc_cntl_ll_gpio_get_wakeup_pins()
  51. #define rtc_hal_gpio_clear_wakeup_pins() rtc_cntl_ll_gpio_clear_wakeup_pins()
  52. #define rtc_hal_gpio_set_wakeup_pins() rtc_cntl_ll_gpio_set_wakeup_pins()
  53. #endif
  54. #define rtc_hal_set_wakeup_timer(ticks) rtc_cntl_ll_set_wakeup_timer(ticks)
  55. void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next);
  56. #if SOC_PM_SUPPORT_CPU_PD
  57. void rtc_cntl_hal_enable_cpu_retention(void *addr);
  58. void rtc_cntl_hal_disable_cpu_retention(void *addr);
  59. #endif
  60. #if SOC_PM_SUPPORT_TAGMEM_PD
  61. void rtc_cntl_hal_enable_tagmem_retention(void *addr);
  62. void rtc_cntl_hal_disable_tagmem_retention(void *addr);
  63. #endif
  64. /*
  65. * Enable wakeup from ULP coprocessor.
  66. */
  67. #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable()