2023-09-04 05:20:36 -04:00
|
|
|
/*
|
2024-04-12 04:50:26 -04:00
|
|
|
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
2023-09-04 05:20:36 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2023-10-26 06:01:30 -04:00
|
|
|
#include "esp_err.h"
|
2023-09-04 05:20:36 -04:00
|
|
|
#include "soc/soc_caps.h"
|
|
|
|
#include "soc/clk_tree_defs.h"
|
|
|
|
#include "driver/gpio.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX || SOC_GPIO_CLOCKOUT_BY_IO_MUX
|
2023-10-19 10:21:53 -04:00
|
|
|
typedef struct esp_clock_output_mapping *esp_clock_output_mapping_handle_t;
|
2023-09-04 05:20:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Start output specified clock signal to specified GPIO, will also
|
2023-10-19 10:21:53 -04:00
|
|
|
* initialize the clkout_mapping_ret_hdl.
|
2023-09-04 05:20:36 -04:00
|
|
|
*
|
|
|
|
* @param[in] clk_src The clock signal source to be mapped to GPIOs
|
|
|
|
* @param[in] gpio_num GPIO number to be mapped soc_root_clk signal source
|
2024-04-12 04:50:26 -04:00
|
|
|
* @param[out] clkout_mapping_ret_hdl Clock output control handler
|
2023-09-04 05:20:36 -04:00
|
|
|
* @return
|
|
|
|
* - ESP_OK: Output specified clock signal to specified GPIO successfully
|
|
|
|
* - ESP_ERR_INVALID_ARG: Specified GPIO not supported to output internal clock
|
|
|
|
* or specified GPIO is already mapped to other internal clock source.
|
|
|
|
* - ESP_FAIL: There are no clock out signals that can be allocated.
|
|
|
|
*/
|
2023-10-19 10:21:53 -04:00
|
|
|
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);
|
2023-09-04 05:20:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Stop clock signal to GPIO outputting
|
2024-04-12 04:50:26 -04:00
|
|
|
* @param[in] clkout_mapping_hdl Clock output mapping control handle
|
2023-09-04 05:20:36 -04:00
|
|
|
* @return
|
|
|
|
* - ESP_OK: Disable the clock output on GPIO successfully
|
2024-04-12 04:50:26 -04:00
|
|
|
* - ESP_ERR_INVALID_ARG The clock mapping handle is not initialized yet
|
|
|
|
* - ESP_ERR_INVALID_STATE The clock mapping handle is already in the disabled state
|
2023-09-04 05:20:36 -04:00
|
|
|
*/
|
2023-10-19 10:21:53 -04:00
|
|
|
esp_err_t esp_clock_output_stop(esp_clock_output_mapping_handle_t clkout_mapping_hdl);
|
2024-04-12 04:50:26 -04:00
|
|
|
|
|
|
|
#if SOC_CLOCKOUT_SUPPORT_CHANNEL_DIVIDER
|
|
|
|
/**
|
|
|
|
* @brief Output the mapped clock after frequency division
|
|
|
|
* @param clkout_mapping_hdl clkout_mapping_hdl Clock output mapping control handle
|
|
|
|
* @param div_num clock frequency division value, should be in the range of 1 ~ 256
|
|
|
|
* @return
|
|
|
|
* - ESP_OK: Disable the clock output on GPIO successfully
|
|
|
|
* - ESP_ERR_INVALID_ARG The clock mapping handle is not initialized yet or the div_num is in bad range
|
|
|
|
*/
|
|
|
|
esp_err_t esp_clock_output_set_divider(esp_clock_output_mapping_handle_t clkout_mapping_hdl, uint32_t div_num);
|
|
|
|
#endif
|
|
|
|
|
2023-10-26 06:01:30 -04:00
|
|
|
#endif // SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX || SOC_GPIO_CLOCKOUT_BY_IO_MUX
|
2023-09-04 05:20:36 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|