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 23 /** 24 * @brief 25 */ 26 typedef enum { 27 PM_SLEEP_DISABLE = 0, 28 PM_SLEEP_LEG_ADV = BIT(0), 29 PM_SLEEP_LEG_SCAN = BIT(1), 30 PM_SLEEP_ACL_SLAVE = BIT(2), 31 PM_SLEEP_ACL_MASTER = BIT(3), 32 }sleep_mask_t; 33 34 35 36 /** 37 * @brief 38 */ 39 /* DeepSleepRetention_Enable */ 40 typedef enum { 41 PM_DeepRetn_Disable = 0x00, 42 PM_DeepRetn_Enable = 0x01, 43 } deep_retn_en_t; 44 45 46 /** 47 * @brief for user to initialize low power mode 48 * @param none 49 * @return none 50 */ 51 void blc_ll_initPowerManagement_module(void); 52 53 54 /** 55 * @brief LinkLayer initialization after deepSleep retention wake_up 56 * @param none 57 * @return none 58 */ 59 void blc_ll_recoverDeepRetention(void); 60 61 62 /** 63 * @brief for user to set low power mode mask 64 * @param mask - low power mode mask 65 * @return none 66 */ 67 void blc_pm_setSleepMask (sleep_mask_t mask); 68 69 /** 70 * @brief for user to enable or disable deepSleep retention function 71 * @param en - deepSleep retention enable, 1: enable; 0: disable 72 * @return none 73 */ 74 void blc_pm_setDeepsleepRetentionEnable (deep_retn_en_t en); 75 76 /** 77 * @brief for user to set low power mode wake up source 78 * @param wakeup_src - low power mode wake_up source 79 * @return none 80 */ 81 void blc_pm_setWakeupSource (SleepMode_TypeDef wakeup_src); 82 83 84 /** 85 * @brief for user to get low power mode wake up time 86 * @param none 87 * @return bltPm.current_wakeup_tick 88 */ 89 u32 blc_pm_getWakeupSystemTick(void); 90 91 /** 92 * @brief for user to set the threshold of sleep tick for entering deep retention mode 93 * @param thres_ms - the threshold of time for suspend or deepsleep retention 94 * @return none. 95 */ 96 void blc_pm_setDeepsleepRetentionThreshold(u32 thres_ms); 97 98 /** 99 * @brief for user to set early wake up tick for deep retention mode 100 * @param earlyWakeup_us - early wake up tick for deep retention mode 101 * @return none. 102 */ 103 void blc_pm_setDeepsleepRetentionEarlyWakeupTiming(u32 earlyWakeup_us); 104 105 /** 106 * @brief for user to set the type of deep retention mode 107 * @param sleep_type - the type of deep retention mode 108 * @return none. 109 */ 110 void blc_pm_setDeepsleepRetentionType(SleepMode_TypeDef sleep_type); 111 112 113 114 /** 115 * @brief application wake up low power mode process callback function 116 */ 117 typedef void (*pm_appWakeupLowPower_callback_t)(int); 118 119 /** 120 * @brief for user to set application wake up low power mode 121 * @param wakeup_tick - low power mode wake up time 122 * @param enable - low power mode application wake up enable 123 * @return none 124 */ 125 void blc_pm_setAppWakeupLowPower(u32 wakeup_tick, u8 enable); 126 127 /** 128 * @brief for user to register the callback for application wake up low power mode process 129 * @param cb - the pointer of callback function 130 * @return none. 131 */ 132 void blc_pm_registerAppWakeupLowPowerCb(pm_appWakeupLowPower_callback_t cb); 133 134 135 136 #endif /* LL_PM_H_ */ 137