esp_clk_tree.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_err.h"
  8. #include "soc/clk_tree_defs.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /**
  13. * @brief Degree of precision of frequency value to be returned by esp_clk_tree_src_get_freq_hz()
  14. */
  15. typedef enum {
  16. ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, /*< Get value from the data cached by the driver; If the data is 0, then a calibration will be performed */
  17. ESP_CLK_TREE_SRC_FREQ_PRECISION_APPROX, /*< Get its approxiamte frequency value */
  18. ESP_CLK_TREE_SRC_FREQ_PRECISION_EXACT, /*< Always perform a calibration */
  19. ESP_CLK_TREE_SRC_FREQ_PRECISION_INVALID, /*< Invalid degree of precision */
  20. } esp_clk_tree_src_freq_precision_t;
  21. /**
  22. * @brief Get frequency of module clock source
  23. *
  24. * @param[in] clk_src Clock source available to modules, in soc_module_clk_t
  25. * @param[in] precision Degree of precision, one of esp_clk_tree_src_freq_precision_t values
  26. * This arg only applies to the clock sources that their frequencies can vary:
  27. * SOC_MOD_CLK_RTC_FAST, SOC_MOD_CLK_RTC_SLOW, SOC_MOD_CLK_RC_FAST, SOC_MOD_CLK_RC_FAST_D256,
  28. * SOC_MOD_CLK_XTAL32K
  29. * For other clock sources, this field is ignored.
  30. * @param[out] freq_value Frequency of the clock source, in Hz
  31. *
  32. * @return
  33. * - ESP_OK Success
  34. * - ESP_ERR_INVALID_ARG Parameter error
  35. * - ESP_FAIL Calibration failed
  36. */
  37. esp_err_t esp_clk_tree_src_get_freq_hz(soc_module_clk_t clk_src, esp_clk_tree_src_freq_precision_t precision,
  38. uint32_t *freq_value);
  39. #ifdef __cplusplus
  40. }
  41. #endif