1 // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #pragma once
16
17 #include "soc/soc.h"
18 #include "soc/rtc.h"
19
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
rtc_cntl_ll_set_wakeup_timer(uint64_t t)25 static inline void rtc_cntl_ll_set_wakeup_timer(uint64_t t)
26 {
27 WRITE_PERI_REG(RTC_CNTL_SLP_TIMER0_REG, t & UINT32_MAX);
28 WRITE_PERI_REG(RTC_CNTL_SLP_TIMER1_REG, t >> 32);
29 }
30
rtc_cntl_ll_ext1_clear_wakeup_pins(void)31 static inline void rtc_cntl_ll_ext1_clear_wakeup_pins(void)
32 {
33 REG_SET_BIT(RTC_CNTL_EXT_WAKEUP1_REG, RTC_CNTL_EXT_WAKEUP1_STATUS_CLR);
34 }
35
rtc_cntl_ll_ext1_get_wakeup_pins(void)36 static inline uint32_t rtc_cntl_ll_ext1_get_wakeup_pins(void)
37 {
38 return REG_GET_FIELD(RTC_CNTL_EXT_WAKEUP1_STATUS_REG, RTC_CNTL_EXT_WAKEUP1_STATUS);
39 }
40
rtc_cntl_ll_ext1_set_wakeup_pins(uint32_t mask,int mode)41 static inline void rtc_cntl_ll_ext1_set_wakeup_pins(uint32_t mask, int mode)
42 {
43 REG_SET_FIELD(RTC_CNTL_EXT_WAKEUP1_REG, RTC_CNTL_EXT_WAKEUP1_SEL, mask);
44 SET_PERI_REG_BITS(RTC_CNTL_EXT_WAKEUP_CONF_REG, 0x1,
45 mode, RTC_CNTL_EXT_WAKEUP1_LV_S);
46 }
47
rtc_cntl_ll_ulp_wakeup_enable(void)48 static inline void rtc_cntl_ll_ulp_wakeup_enable(void)
49 {
50 SET_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_WAKEUP_FORCE_EN);
51 }
52
53 #ifdef __cplusplus
54 }
55 #endif
56