luat_soc_sdk_2024 V1.0
luat_pm.h
浏览该文件的文档.
1
2#ifndef LUAT_PM_H
3#define LUAT_PM_H
4#include "luat_base.h"
9#define LUAT_PM_SLEEP_MODE_NONE 0 //系统处于活跃状态,未采取任何的降低功耗状态
10#define LUAT_PM_SLEEP_MODE_IDLE 1 //空闲模式,该模式在系统空闲时停止 CPU 和部分时钟,任意事件或中断均可以唤醒
11#define LUAT_PM_SLEEP_MODE_LIGHT 2 //轻度睡眠模式,CPU 停止,多数时钟和外设停止
12#define LUAT_PM_SLEEP_MODE_DEEP 3 //深度睡眠模式,CPU 停止,仅少数低功耗外设工作,可被特殊中断唤醒
13#define LUAT_PM_SLEEP_MODE_STANDBY 4 //待机模式,CPU 停止,设备上下文丢失(可保存至特殊外设),唤醒后通常复位
14//#define LUAT_PM_SLEEP_MODE_SHUTDOWN 5 //关断模式,比 Standby 模式功耗更低, 上下文通常不可恢复, 唤醒后复位
15#define LUAT_PM_POWER_MODE_NORMAL (0)
16#define LUAT_PM_POWER_MODE_HIGH_PERFORMANCE (1)
17#define LUAT_PM_POWER_MODE_BALANCED (2)
18#define LUAT_PM_POWER_MODE_POWER_SAVER (3)
19
20
38
39// 开关类
40enum
41{
50};
51
52// 电平类
53enum
54{
65 LUAT_PM_LDO_TYPE_VSIM1, //不一定起作用,尽量不要用
67};
68
74int luat_pm_request(int mode);
80int luat_pm_release(int mode);
81
88int luat_pm_dtimer_start(int id, size_t timeout);
89
96
103
104// void luat_pm_cb(int event, int arg, void* args);
105
112int luat_pm_last_state(int *lastState, int *rtcOrPad);
113
119int luat_pm_force(int mode);
120
132int luat_pm_dtimer_list(size_t* count, size_t* list);
133
140
146
152
159int luat_pm_power_ctrl(int id, uint8_t val);
160
166
173int luat_pm_iovolt_ctrl(int id, int val);
174
181int luat_pm_wakeup_pin(int pin, int val);
189int luat_pm_set_power_mode(uint8_t mode, uint8_t sub_mode);
195uint32_t luat_pm_dtimer_remain(int id);
197#endif
int luat_pm_dtimer_list(size_t *count, size_t *list)
获取所有深度休眠定时器的剩余时间,单位ms
int luat_pm_request(int mode)
请求进入指定的休眠模式
int luat_pm_set_power_mode(uint8_t mode, uint8_t sub_mode)
设置联网低功耗模式,等同于AT+POWERMODE
int luat_pm_reset(void)
重启
LUAT_PM_POWERON_REASON
开机原因
int luat_pm_release(int mode)
退出休眠模式
int luat_pm_dtimer_stop(int id)
停止底层定时器
uint32_t luat_pm_dtimer_remain(int id)
深度休眠定时器剩余时间,单位ms
enum LUAT_PM_POWERON_REASON LUAT_PM_POWERON_REASON_E
开机原因
int luat_pm_dtimer_wakeup_id(int *id)
获取唤醒定时器id
int luat_pm_dtimer_start(int id, size_t timeout)
启动底层定时器,在休眠模式下依然生效. 只触发一次
int luat_pm_dtimer_check(int id)
检查底层定时器运行状态
int luat_pm_get_poweron_reason(void)
开机原因
int luat_pm_check(void)
检查休眠状态
int luat_pm_force(int mode)
强制进入指定的休眠模式,忽略某些外设的影响,比如USB
int luat_pm_last_state(int *lastState, int *rtcOrPad)
唤醒原因,用于判断是从开机是否是由休眠状态下开机/唤醒
int luat_pm_wakeup_pin(int pin, int val)
配置唤醒引脚,只针对esp系列
int luat_pm_poweroff(void)
关机
int luat_pm_iovolt_ctrl(int id, int val)
设置IO电压域的电平
int luat_pm_power_ctrl(int id, uint8_t val)
开启内部的电源控制,注意不是所有的平台都支持,可能部分平台支持部分选项,看硬件
@ LUAT_PM_POWER_CAMERA
@ LUAT_PM_POWER_LDO_CTL_PIN
@ LUAT_PM_POWER_GPS
@ LUAT_PM_POWER_WORK_MODE
@ LUAT_PM_POWER_DAC_EN_PIN
@ LUAT_PM_POWER_USB
@ LUAT_PM_POWER_GPS_ANT
@ LUAT_PM_POWER_POWERKEY_MODE
@ LUAT_PM_POWERON_REASON_EXTERNAL
@ LUAT_PM_POWERON_REASON_UNKNOWN
@ LUAT_PM_POWERON_REASON_FOTA
@ LUAT_PM_POWERON_REASON_TOOL
@ LUAT_PM_POWERON_REASON_SWRESET
@ LUAT_PM_POWERON_REASON_EXCEPTION
@ LUAT_PM_POWERON_REASON_NORMAL
@ LUAT_PM_POWERON_REASON_HWRESET
@ LUAT_PM_POWERON_REASON_WDT
@ LUAT_PM_POWERON_REASON_ALARM
@ LUAT_PM_POWERON_REASON_CHARGING
@ LUAT_PM_LDO_TYPE_VIBR
@ LUAT_PM_LDO_TYPE_QTY
@ LUAT_PM_ALL_GPIO
@ LUAT_PM_LDO_TYPE_VSIM1
@ LUAT_PM_LDO_TYPE_VLP18
@ LUAT_PM_LDO_TYPE_VLP33
@ LUAT_PM_LDO_TYPE_VMMC
@ LUAT_PM_LDO_TYPE_KEYLED
@ LUAT_PM_LDO_TYPE_CAMA
@ LUAT_PM_LDO_TYPE_VIO18
@ LUAT_PM_LDO_TYPE_VLCD
@ LUAT_PM_LDO_TYPE_CAMD