mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-18 23:54:39 +00:00
refactor(rtc): move soc/rtc.h from soc to esp_hw_support component
Deprecated rtc_xtal_freq_t, replaced with soc_xtal_freq_t defined in clk_tree_defs.h in soc component.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <stdint.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "hal/regi2c_ctrl.h"
|
||||
@@ -32,6 +31,10 @@ extern "C" {
|
||||
|
||||
#define CLK_LL_AHB_MAX_FREQ_MHZ CLK_LL_PLL_80M_FREQ_MHZ
|
||||
|
||||
/* RC_FAST clock enable/disable wait time */
|
||||
#define CLK_LL_RC_FAST_WAIT_DEFAULT 20
|
||||
#define CLK_LL_RC_FAST_ENABLE_WAIT_DEFAULT 5
|
||||
|
||||
#define CLK_LL_XTAL32K_CONFIG_DEFAULT() { \
|
||||
.dac = 3, \
|
||||
.dres = 3, \
|
||||
@@ -131,7 +134,7 @@ static inline __attribute__((always_inline)) bool clk_ll_xtal32k_is_enabled(void
|
||||
static inline __attribute__((always_inline)) void clk_ll_rc_fast_enable(void)
|
||||
{
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_ENB_CK8M);
|
||||
REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CK8M_ENABLE_WAIT_DEFAULT);
|
||||
REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, CLK_LL_RC_FAST_ENABLE_WAIT_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +143,7 @@ static inline __attribute__((always_inline)) void clk_ll_rc_fast_enable(void)
|
||||
static inline __attribute__((always_inline)) void clk_ll_rc_fast_disable(void)
|
||||
{
|
||||
SET_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_ENB_CK8M);
|
||||
REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CNTL_CK8M_WAIT_DEFAULT);
|
||||
REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, CLK_LL_RC_FAST_WAIT_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,7 +314,7 @@ static inline __attribute__((always_inline)) void clk_ll_bbpll_set_config(uint32
|
||||
if (pll_freq_mhz == CLK_LL_PLL_480M_FREQ_MHZ) {
|
||||
/* Configure 480M PLL */
|
||||
switch (xtal_freq_mhz) {
|
||||
case RTC_XTAL_FREQ_40M:
|
||||
case SOC_XTAL_FREQ_40M:
|
||||
div_ref = 0;
|
||||
div7_0 = 8;
|
||||
dr1 = 0;
|
||||
@@ -320,7 +323,7 @@ static inline __attribute__((always_inline)) void clk_ll_bbpll_set_config(uint32
|
||||
dcur = 3;
|
||||
dbias = 2;
|
||||
break;
|
||||
case RTC_XTAL_FREQ_32M:
|
||||
case SOC_XTAL_FREQ_32M:
|
||||
div_ref = 1;
|
||||
div7_0 = 26;
|
||||
dr1 = 1;
|
||||
@@ -343,7 +346,7 @@ static inline __attribute__((always_inline)) void clk_ll_bbpll_set_config(uint32
|
||||
} else {
|
||||
/* Configure 320M PLL */
|
||||
switch (xtal_freq_mhz) {
|
||||
case RTC_XTAL_FREQ_40M:
|
||||
case SOC_XTAL_FREQ_40M:
|
||||
div_ref = 0;
|
||||
div7_0 = 4;
|
||||
dr1 = 0;
|
||||
@@ -352,7 +355,7 @@ static inline __attribute__((always_inline)) void clk_ll_bbpll_set_config(uint32
|
||||
dcur = 3;
|
||||
dbias = 2;
|
||||
break;
|
||||
case RTC_XTAL_FREQ_32M:
|
||||
case SOC_XTAL_FREQ_32M:
|
||||
div_ref = 1;
|
||||
div7_0 = 6;
|
||||
dr1 = 0;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -7,7 +7,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "esp_attr.h"
|
||||
@@ -80,12 +79,6 @@ FORCE_INLINE_ATTR uint64_t rtc_cntl_ll_get_rtc_time(void)
|
||||
return t;
|
||||
}
|
||||
|
||||
FORCE_INLINE_ATTR uint64_t rtc_cntl_ll_time_to_count(uint64_t time_in_us)
|
||||
{
|
||||
uint32_t slow_clk_value = REG_READ(RTC_CNTL_STORE1_REG);
|
||||
return ((time_in_us * (1 << RTC_CLK_CAL_FRACT)) / slow_clk_value);
|
||||
}
|
||||
|
||||
FORCE_INLINE_ATTR uint32_t rtc_cntl_ll_get_wakeup_cause(void)
|
||||
{
|
||||
return REG_GET_FIELD(RTC_CNTL_SLP_WAKEUP_CAUSE_REG, RTC_CNTL_WAKEUP_CAUSE);
|
||||
|
Reference in New Issue
Block a user