2022-08-29 20:14:23 +08:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-11-26 16:06:21 +11:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "soc/soc.h"
|
|
|
|
#include "soc/rtc.h"
|
|
|
|
#include "soc/rtc_cntl_reg.h"
|
2021-09-16 20:57:57 +08:00
|
|
|
#include "soc/syscon_reg.h"
|
2020-11-26 16:06:21 +11:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void rtc_cntl_ll_set_wakeup_timer(uint64_t t)
|
|
|
|
{
|
2020-12-04 11:09:21 +08:00
|
|
|
WRITE_PERI_REG(RTC_CNTL_SLP_TIMER0_REG, t & UINT32_MAX);
|
|
|
|
WRITE_PERI_REG(RTC_CNTL_SLP_TIMER1_REG, t >> 32);
|
|
|
|
|
|
|
|
SET_PERI_REG_MASK(RTC_CNTL_INT_CLR_REG, RTC_CNTL_MAIN_TIMER_INT_CLR_M);
|
|
|
|
SET_PERI_REG_MASK(RTC_CNTL_SLP_TIMER1_REG, RTC_CNTL_MAIN_TIMER_ALARM_EN_M);
|
2020-11-26 16:06:21 +11:00
|
|
|
}
|
|
|
|
|
2022-10-27 15:09:34 +08:00
|
|
|
static inline uint32_t rtc_cntl_ll_gpio_get_wakeup_status(void)
|
2020-11-26 16:06:21 +11:00
|
|
|
{
|
2021-02-05 17:10:44 +08:00
|
|
|
return GET_PERI_REG_MASK(RTC_CNTL_GPIO_WAKEUP_REG, RTC_CNTL_GPIO_WAKEUP_STATUS);
|
2020-11-26 16:06:21 +11:00
|
|
|
}
|
|
|
|
|
2022-10-27 15:09:34 +08:00
|
|
|
static inline void rtc_cntl_ll_gpio_clear_wakeup_status(void)
|
2020-11-26 16:06:21 +11:00
|
|
|
{
|
|
|
|
REG_SET_BIT(RTC_CNTL_GPIO_WAKEUP_REG, RTC_CNTL_GPIO_WAKEUP_STATUS_CLR);
|
2022-10-27 15:09:34 +08:00
|
|
|
REG_CLR_BIT(RTC_CNTL_GPIO_WAKEUP_REG, RTC_CNTL_GPIO_WAKEUP_STATUS_CLR);
|
2020-11-26 16:06:21 +11:00
|
|
|
}
|
|
|
|
|
2021-06-18 17:25:04 +08:00
|
|
|
static inline void rtc_cntl_ll_set_cpu_retention_link_addr(uint32_t addr)
|
2020-12-24 21:02:32 +08:00
|
|
|
{
|
2021-09-16 20:57:57 +08:00
|
|
|
REG_SET_FIELD(SYSCON_RETENTION_CTRL_REG, SYSCON_RETENTION_LINK_ADDR, (uint32_t)addr);
|
2021-06-18 17:25:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rtc_cntl_ll_enable_cpu_retention_clock(void)
|
|
|
|
{
|
2020-12-24 21:02:32 +08:00
|
|
|
REG_SET_BIT(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_EN);
|
2021-06-18 17:25:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rtc_cntl_ll_enable_cpu_retention(void)
|
|
|
|
{
|
2020-12-24 21:02:32 +08:00
|
|
|
/* Enable retention when cpu sleep enable */
|
|
|
|
REG_SET_BIT(RTC_CNTL_RETENTION_CTRL_REG, RTC_CNTL_RETENTION_EN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rtc_cntl_ll_disable_cpu_retention(void)
|
|
|
|
{
|
|
|
|
REG_CLR_BIT(RTC_CNTL_RETENTION_CTRL_REG, RTC_CNTL_RETENTION_EN);
|
|
|
|
}
|
|
|
|
|
2022-08-29 20:14:23 +08:00
|
|
|
static inline void rtc_cntl_ll_reset_system(void)
|
|
|
|
{
|
|
|
|
REG_WRITE(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void rtc_cntl_ll_reset_cpu(int cpu_no)
|
|
|
|
{
|
|
|
|
REG_WRITE(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_PROCPU_RST);
|
|
|
|
}
|
|
|
|
|
2020-11-26 16:06:21 +11:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|