-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/esp32p4_clock_prework_support' into 'master'
feat(clk): Add support to get xtaL freq for ESP32P4 See merge request espressif/esp-idf!24927
- Loading branch information
Showing
3 changed files
with
76 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include "esp_clk_tree.h" | ||
#include "esp_err.h" | ||
#include "esp_check.h" | ||
#include "soc/rtc.h" | ||
|
||
static const char *TAG = "esp_clk_tree"; | ||
|
||
// TODO: IDF-7526 | ||
esp_err_t esp_clk_tree_src_get_freq_hz(soc_module_clk_t clk_src, esp_clk_tree_src_freq_precision_t precision, | ||
uint32_t *freq_value) | ||
{ | ||
ESP_RETURN_ON_FALSE(clk_src > 0 && clk_src < SOC_MOD_CLK_INVALID, ESP_ERR_INVALID_ARG, TAG, "unknown clk src"); | ||
ESP_RETURN_ON_FALSE(precision < ESP_CLK_TREE_SRC_FREQ_PRECISION_INVALID, ESP_ERR_INVALID_ARG, TAG, "unknown precision"); | ||
ESP_RETURN_ON_FALSE(freq_value, ESP_ERR_INVALID_ARG, TAG, "null pointer"); | ||
|
||
uint32_t clk_src_freq = 0; | ||
switch (clk_src) { | ||
case SOC_MOD_CLK_XTAL: | ||
clk_src_freq = 40 * MHZ; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
ESP_RETURN_ON_FALSE(clk_src_freq, ESP_FAIL, TAG, | ||
"freq shouldn't be 0, calibration failed"); | ||
*freq_value = clk_src_freq; | ||
return ESP_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters