/** * @file hi_lowpower.h * * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @defgroup iot_lp Power consumption management * @ingroup system */ #ifndef __HI_LOWPOWER_H__ #define __HI_LOWPOWER_H__ #include #include /** * @ingroup iot_lp * UDP wakes up source enumeration. */ typedef enum { HI_UDS_GPIO3 = 1 << 0, /**< ultra sleep wakeup source GPIO3.CNcomment:超深睡唤醒源GPIO3 CNend */ HI_UDS_GPIO5 = 1 << 1, /**< ultra sleep wakeup source GPIO5.CNcomment:超深睡唤醒源GPIO5 CNend */ HI_UDS_GPIO7 = 1 << 2, /**< ultra sleep wakeup source GPIO7.CNcomment:超深睡唤醒源GPIO7 CNend */ HI_UDS_GPIO14 = 1 << 3, /**< ultra sleep wakeup source GPIO14.CNcomment:超深睡唤醒源GPIO14 CNend */ } hi_udsleep_src; /** * @ingroup iot_lp * Sleep level enumeration. */ typedef enum { HI_NO_SLEEP, /**< no sleep type.CNcomment:不睡模式 CNend */ HI_LIGHT_SLEEP, /**< light sleep type.CNcomment:浅睡模式 CNend */ HI_DEEP_SLEEP, /**< deep sleep type.CNcomment:深睡模式 CNend */ } hi_lpc_type; /** * @ingroup hct_lp * * 睡眠模块ID 枚举,每个id占用1个bit,继续扩展时要注意最大为(1 << 31)。 */ typedef enum { HI_LPC_ID_DIAG = 1 << 0, /**< diag uart Id.CNcomment:diag模块 Id */ HI_LPC_ID_SHELL = 1 << 1, /**< shell Id.CNcomment:shell模块 Id CNend */ HI_LPC_ID_RSV = 1 << 15, /**< 之前均为内部预留id.CNcomment:内部预留 Id CNend */ HI_LPC_ID_DEMO = 1 << 16, /**< demo Id.CNcomment:低功耗管理id样例,之后为客户预留Id CNend */ }hi_lpc_id; /** * @ingroup iot_lp * Low power management structure. */ typedef struct { hi_u32 wakeup_times; /**< wakeup times.CNcomment:唤醒次数统计 CNend */ hi_u32 sleep_threshold_refuse_times; /**< sleep threshold refuse times.CNcomment: 可睡时间小于设定门限次数统计 CNend */ hi_u32 sleep_check_refuse_times; /**< sleep check refuse times.CNcomment: 入睡投票睡眠失败次数统计 CNend */ hi_u32 sleep_times; /**< sleep times.CNcomment:入睡次数统计 CNend */ hi_u32 sleep_threshold; /**< sleep threshold, unit is ms, only when the system' Remaining idle time is bigger than the threshold, system can enter deep sleep state.CNcomment:深睡眠门限,单位 为ms,当系统剩余空闲时间大于该门限时,方可进入深睡 CNend */ hi_u32 dsleep_fail_times; /**< the times of power off fail during deepsleep.CNcomment:深睡下电失败次数统计 CNend */ hi_u8 type; /**< hi_lpc_type type, enable low power management. CNcomment:hi_lp_type类型,低功耗类型 CNend */ hi_u8 evt_sts; /**< wakeup event state, bit0:gpio wkup, bit1:rtc wkup, bit2:sdio wkup, bit4: sta0 wkup, bit5:sta1 wkup, bit6:ap0 wkup.CNcomment:唤醒事件状态,bit0:gpio 唤醒, bit1:rtc 唤醒,bit2:sdio 唤醒,bit4:sta0 唤醒, bit5:sta1 唤醒, bit6:ap0 唤醒。 CNend */ hi_u8 int_sts; /**< wakeup interrupt state, bit0:gpio wkup, bit1:rtc wkup, bit2:sdio wkup, bit4: sta0 wkup, bit5:sta1 wkup, bit6:ap0 wkup.CNcomment:唤醒中断状态,bit0:gpio 唤醒, bit1:rtc 唤醒,bit2:sdio 唤醒,bit4:sta0 唤醒, bit5:sta1 唤醒, bit6:ap0 唤醒 CNend */ hi_u8 last_time_vote_state; /**< last time vote state, 0:no sleep, 1: light sleep, 2: deep sleep. CNcomment:最近一次睡眠状态,0:没有入睡,1:浅睡,2:深睡。 CNend */ hi_u32 timer_ticks; /**< the time ticks is about to expire, unit is 10 ms, if the value is 0xffffffff, there is no timer that is about to expire. CNcomment:定时器即将到期的时间,单位为10ms;如果是0xffffffff,表示没有即将到期的 定时器 CNend */ hi_u32 timer_handle; /**< the callback function address of the timer that is about to expire. if the value is 0xffffffff, it means that there is no timer that is about to expire. CNcomment:即将到期定时器回调函数的地址,如果是0xffffffff,表示没有即将到期的定时器 CNend */ hi_u32 timer_handle_arg; /**< the parameter of the timer callback function, if the value is 0xffffffff, it means there is no timer to expire.CNcomment:定时器回调函数的参数,如果是0xffffffff, 表示没有即将到期的定时器 CNend */ hi_u32 task_ticks; /**< the task ticks is about to expire, unit is 10 ms.CNcomment:任务即将到期的时间, 单位为10ms。CNend */ hi_u32 task_id; /**< the task id that is about to expire.CNcomment:即将到期任务的ID。CNend */ hi_u32 sleep_ticks; /**< last sleep time ticks, unit is 10 ms.CNcomment:最近一次睡眠的tick时间, 单位为10ms。CNend */ hi_u32 veto_info; /**< veto_info.CNcomment:投票否决睡眠信息,详见hi_lpc_id。CNend */ hi_u16 dsleep_wk_gpio; /**< wakeup gpio for deep sleep.CNcomment:唤醒的GPIO,该值(1<