• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************/
18 #ifndef LL_PM_H_
19 #define LL_PM_H_
20 
21 /**
22  *  @brief
23  */
24 typedef enum {
25     PM_SLEEP_DISABLE = 0,
26     PM_SLEEP_LEG_ADV = BIT(0),
27     PM_SLEEP_LEG_SCAN = BIT(1),
28     PM_SLEEP_ACL_SLAVE = BIT(2),
29     PM_SLEEP_ACL_MASTER = BIT(3),
30 } sleep_mask_t;
31 
32 /**
33  *  @brief
34  */
35 /* DeepSleepRetention_Enable */
36 typedef enum {
37     PM_DeepRetn_Disable = 0x00,
38     PM_DeepRetn_Enable = 0x01,
39 } deep_retn_en_t;
40 
41 /**
42  * @brief	for user to initialize low power mode
43  * @param	none
44  * @return	none
45  */
46 void blc_ll_initPowerManagement_module(void);
47 
48 /**
49  * @brief   LinkLayer initialization after deepSleep retention wake_up
50  * @param	none
51  * @return	none
52  */
53 void blc_ll_recoverDeepRetention(void);
54 
55 /**
56  * @brief	for user to set low power mode mask
57  * @param	mask - low power mode mask
58  * @return	none
59  */
60 void blc_pm_setSleepMask(sleep_mask_t mask);
61 
62 /**
63  * @brief	for user to enable or disable deepSleep retention function
64  * @param	en -  deepSleep retention enable, 1: enable; 0: disable
65  * @return	none
66  */
67 void blc_pm_setDeepsleepRetentionEnable(deep_retn_en_t en);
68 
69 /**
70  * @brief	for user to set low power mode wake up source
71  * @param	wakeup_src - low power mode wake_up source
72  * @return	none
73  */
74 void blc_pm_setWakeupSource(SleepMode_TypeDef wakeup_src);
75 
76 /**
77  * @brief	for user to get low power mode wake up time
78  * @param	none
79  * @return	bltPm.current_wakeup_tick
80  */
81 u32 blc_pm_getWakeupSystemTick(void);
82 
83 /**
84  * @brief	for user to set the threshold of sleep tick for entering deep retention mode
85  * @param	thres_ms - the threshold of time for suspend or deepsleep retention
86  * @return  none.
87  */
88 void blc_pm_setDeepsleepRetentionThreshold(u32 thres_ms);
89 
90 /**
91  * @brief	for user to set early wake up tick for deep retention mode
92  * @param	earlyWakeup_us - early wake up tick for deep retention mode
93  * @return  none.
94  */
95 void blc_pm_setDeepsleepRetentionEarlyWakeupTiming(u32 earlyWakeup_us);
96 
97 /**
98  * @brief	for user to set the type of deep retention mode
99  * @param	sleep_type - the type of deep retention mode
100  * @return  none.
101  */
102 void blc_pm_setDeepsleepRetentionType(SleepMode_TypeDef sleep_type);
103 
104 /**
105  * @brief	application wake up low power mode process callback function
106  */
107 typedef void (*pm_appWakeupLowPower_callback_t)(int);
108 
109 /**
110  * @brief	for user to set application wake up low power mode
111  * @param	wakeup_tick - low power mode wake up time
112  * @param	enable - low power mode application wake up enable
113  * @return	none
114  */
115 void blc_pm_setAppWakeupLowPower(u32 wakeup_tick, u8 enable);
116 
117 /**
118  * @brief	for user to register the callback for application wake up low power mode process
119  * @param	cb - the pointer of callback function
120  * @return  none.
121  */
122 void blc_pm_registerAppWakeupLowPowerCb(pm_appWakeupLowPower_callback_t cb);
123 
124 #endif /* LL_PM_H_ */
125