esp_clock_output.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * SPDX-FileCopyrightText: 2023 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 "soc/soc_caps.h"
  10. #include "soc/clk_tree_defs.h"
  11. #include "driver/gpio.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #if SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX || SOC_GPIO_CLOCKOUT_BY_IO_MUX
  16. typedef struct esp_clock_output_mapping *esp_clock_output_mapping_handle_t;
  17. /**
  18. * @brief Start output specified clock signal to specified GPIO, will also
  19. * initialize the clkout_mapping_ret_hdl.
  20. *
  21. * @param[in] clk_src The clock signal source to be mapped to GPIOs
  22. * @param[in] gpio_num GPIO number to be mapped soc_root_clk signal source
  23. * @param[out] clkout_mapping_ret_hdl Clock output controll handler
  24. * @return
  25. * - ESP_OK: Output specified clock signal to specified GPIO successfully
  26. * - ESP_ERR_INVALID_ARG: Specified GPIO not supported to output internal clock
  27. * or specified GPIO is already mapped to other internal clock source.
  28. * - ESP_FAIL: There are no clock out signals that can be allocated.
  29. */
  30. esp_err_t esp_clock_output_start(soc_clkout_sig_id_t clk_sig, gpio_num_t gpio_num, esp_clock_output_mapping_handle_t *clkout_mapping_ret_hdl);
  31. /**
  32. * @brief Stop clock signal to GPIO outputting
  33. * @param[in] clkout_mapping_hdl Clock output mapping controll handle
  34. * @return
  35. * - ESP_OK: Disable the clock output on GPIO successfully
  36. * - ESP_ERR_INVALID_STATE The clock in handle is already in the disabled state
  37. */
  38. esp_err_t esp_clock_output_stop(esp_clock_output_mapping_handle_t clkout_mapping_hdl);
  39. #endif // SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX || SOC_GPIO_CLOCKOUT_BY_IO_MUX
  40. #ifdef __cplusplus
  41. }
  42. #endif