4G_module/include/cmiot/cm_pm.h

156 lines
3.5 KiB
C
Raw Permalink Normal View History

2024-09-02 17:54:29 +08:00
/**
* @file cm_pm.h
* @brief PM接口
* @copyright Copyright © 2021 China Mobile IOT. All rights reserved.
* @author By zyf
* @date 2021/04/18
*
* @defgroup pm pm
* @ingroup PM
* @{
*/
#ifndef __CM_PM_H__
#define __CM_PM_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
typedef enum
{
CM_POWERKEY_EVENT_RELEASE = 0, /*!<按键被释放*/
CM_POWERKEY_EVENT_PRESS = 1, /*!<按键被按下*/
} cm_powerkey_event_e;
typedef void (*cm_pm_event_cb_t)(void);
typedef void (*cm_pm_powerkey_cb_t)(cm_powerkey_event_e event);
/** 上电原因 */
typedef enum
{
CM_PM_UNKNOWN = 0, /*!<未知原因*/
CM_PM_CHARG_POW_OFF, /*!<Charging in powering off,USB等充电方式供电时产生的重启*/
CM_PM_RD_PRO_MODE , /*!<Rd production mode,产线工具下发导致的重启*/
CM_PM_RTC_ALARM, /*!<rtc Alarm定时闹钟开机*/
CM_PM_POWER_ON, /*!<Normal power on,正常重启*/
CM_PM_ERROR_RESET, /*!<Error reset (WDT),看门狗超时导致的重启*/
}cm_pm_power_on_reason_e;
/** 配置 */
typedef struct{
cm_pm_event_cb_t cb_enter; /*!< 进入低功耗回调函数*/
cm_pm_event_cb_t cb_exit; /*!< 退出低功耗回调函数*/
} cm_pm_cfg_t;
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/**
* @brief
*
* @return
*
* @details More details
*/
void cm_pm_poweroff(void);
/**
* @brief
*
* @return
* >= 0 - \n
* < 0 - ,
*
* @details More details
*/
int cm_pm_get_power_on_reason(void);
/**
* @brief
*
* @param [in] void
*
* @return void
*
* @details More details
*/
void cm_pm_reboot(void);
/**
* @brief pm初始化
*
* @param [in] pm_cfg:
*
* @return void
*
* @details More details
*/
void cm_pm_init(cm_pm_cfg_t pm_cfg);
/**
* @brief
*
* @return
*
* @details
*/
void cm_pm_work_lock(void);
/**
* @brief
*
* @return
*
* @details
*/
void cm_pm_work_unlock(void);
/**
* @brief powerkey按键回调函数注册
*
* @param [in] callback回调函数指针
* @return
* = 0 - \n
* < 0 - ,
*
* @details \n
*/
int32_t cm_pm_powerkey_regist_callback(cm_pm_powerkey_cb_t callback);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __CM_PM_H__ */
/** @}*/