rtc_clk.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**
  12. * @brief Switch CPU clock source to XTAL, and let cpu frequency equal to main XTAL frequency.
  13. *
  14. * This function does not disable BBPLL. If BBPLL requires to be disabled to save power, please call
  15. * `rtc_clk_cpu_freq_set_xtal` instead. It does one extra check to see whether can disable the BBPLL after switching the
  16. * CPU clock source to XTAL.
  17. *
  18. * Currently, this function should only be called in `esp_restart_noos` and `esp_restart_noos_dig` to switch the CPU
  19. * clock source back to XTAL (by default) before reset.
  20. */
  21. void rtc_clk_cpu_set_to_default_config(void);
  22. /**
  23. * @brief Notify that the BBPLL has a new in-use consumer
  24. *
  25. * Currently, this function is only used for tracking whether USB Serial/JTAG is using the 48MHz PHY clock
  26. *
  27. * Note: Calling this function only helps to not disable the BBPLL clock in `rtc_clk_cpu_freq_set_config`.
  28. * For light and deep sleep, whether to disable the BBPLL in the interal call to `rtc_clk_cpu_freq_set_xtal`
  29. * varies for targets.
  30. * On ESP32C3/S3, USB CDC device can not function properly during sleep due to the lack of APB clock. Therefore.
  31. * `rtc_clk_cpu_freq_set_xtal` will always disable BBPLL, no matter whether BBPLL has any consumer.
  32. * On ESP32C6/H2, USB CDC device can maintain the minimum connection with the host during sleep, so
  33. * `rtc_clk_cpu_freq_set_xtal` will check for BBPLL consumers, and keep BBPLL if USB Serial/JTAG is in use.
  34. */
  35. void rtc_clk_bbpll_add_consumer(void);
  36. /**
  37. * @brief Notify that the BBPLL has lost a consumer
  38. */
  39. void rtc_clk_bbpll_remove_consumer(void);
  40. #ifdef __cplusplus
  41. }
  42. #endif