KT24-1110_65E-HA-651B/include_lib/system/power_manage.h

104 lines
2.7 KiB
C
Raw Permalink Normal View History

2024-11-10 10:44:17 +00:00
#ifndef __POWER_MANAGE_H_
#define __POWER_MANAGE_H_
#include "generic/typedef.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
DEVICE_EVENT_POWER_SHUTDOWN = 0x10,
DEVICE_EVENT_POWER_STARTUP,
DEVICE_EVENT_POWER_PERCENT,
DEVICE_EVENT_POWER_CHARGER_IN,
DEVICE_EVENT_POWER_CHARGER_OUT
};
#define PWR_SCAN_TIMES 3
#define PWR_DELAY_INFINITE 0xffffffff
#define PWR_WKUP_PORT "wkup_port"
#define PWR_WKUP_ALARM "wkup_alarm"
#define PWR_WKUP_PWR_ON "wkup_pwr_on"
#define PWR_WKUP_ABNORMAL "wkup_abnormal"
#define PWR_WKUP_SHORT_KEY "wkup_short_key"
struct sys_power_hal_ops {
void (*init)(void);
void (*poweroff)(void *arg);
int (*wakeup_check)(char *reason, int max_len);
int (*port_wakeup_config)(const char *port, int enable);
int (*alarm_wakeup_config)(u32 sec, int enable);
int (*get_battery_voltage)(void);
int (*get_battery_percent)(void);
int (*charger_online)(void);
};
extern const struct sys_power_hal_ops sys_power_hal_ops_begin[];
extern const struct sys_power_hal_ops sys_power_hal_ops_end[];
#define REGISTER_SYS_POWER_HAL_OPS(ops) \
static const struct sys_power_hal_ops ops sec(.sys_power_hal_ops)
void sys_power_early_init();
/*
* @brief
*/
void sys_power_poweroff(void *arg);
/*
* @brief DEVICE_EVENT_POWER_SHUTDOWN事件app捕获事件释放资源再调用sys_power_poweroff()
*/
void sys_power_shutdown();
int sys_power_set_port_wakeup(const char *port, int enable);
int sys_power_set_alarm_wakeup(u32 sec, int enable);
const char *sys_power_get_wakeup_reason();
void sys_power_clr_wakeup_reason(const char *str);
int sys_power_get_battery_voltage();
int sys_power_get_battery_persent();
int sys_power_is_charging();
int sys_power_charger_online(void);
/*
* @brief
* @parm dly_secs 0
* @return none
*/
void sys_power_auto_shutdown_start(u32 dly_secs);
void sys_power_auto_shutdown_pause();
void sys_power_auto_shutdown_resume();
void sys_power_auto_shutdown_clear();
void sys_power_auto_shutdown_stop();
int sys_power_low_voltage(u32 voltage);
/*
* @brief
* @parm p_low_percent
* @parm dly_secs 0PWR_DELAY_INFINITE为永不关机
* @return none
*/
void sys_power_low_voltage_shutdown(u32 voltage, u32 dly_secs);
/*
* @brief
* @parm dly_secs 0PWR_DELAY_INFINITE为永不关机
* @return none
*/
void sys_power_charger_off_shutdown(u32 dly_secs);
#ifdef __cplusplus
}
#endif
#endif