/**************************************************************************** Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT be copied by any method or incorporated into another program without the express written consent of Aerospace C.Power. This Information or any portion thereof remains the property of Aerospace C.Power. The Information contained herein is believed to be accurate and Aerospace C.Power assumes no responsibility or liability for its use in any way and conveys no license or title under any patent or copyright and makes no representation or warranty that this Information is free from patent or copyright infringement. ****************************************************************************/ #ifndef IOT_PLC_PM_API_H #define IOT_PLC_PM_API_H #include "os_types_api.h" #include "iot_config_api.h" #ifdef __cplusplus extern "C" { #endif /* define the message send to callback */ /* all power collapsed */ #define IOT_PLC_PM_MSG_POWER_COLLAPSED 1 /* phase power collapsed */ #define IOT_PLC_PM_MSG_PHASE_COLLAPSED 2 /* module pulled out */ #define IOT_PLC_PM_MSG_MODULE_PULL_OUT 3 /* all power supply returns to normal after collapsed */ #define IOT_PLC_PM_MSG_POWER_RECOVERED 4 /* @brief the power listener callback function format * @param message: power message to be sent to the callback, * see IOT_PLC_PM_MSG_XXX. * @param data: data of each message. different message may have different * meaning. * IOT_PLC_PM_MSG_POWER_COLLAPSED - not used. * IOT_PLC_PM_MSG_PHASE_COLLAPSED - bit 0 mark if phase A power * collapsed. bit 1 mark if phase B power collapsed. bit 2 mark * if phase C power collapsed. */ typedef void (*iot_plc_pm_listener_func_t)(uint32_t message, uint32_t data); /* @brief register power listener callback function * @param exe_func: the callback function for power message listening * @return * ERR_FAIL -- operation failed. * ERR_INVAL -- operation invalid. * ERR_OK -- operation successful. */ uint32_t iot_plc_pm_register_listener(iot_plc_pm_listener_func_t exe_func); /** * @brief check power management sub system. * @retval: ERR_OK -- power management sub system support. * @retval: otherwise -- not supported, see ERR_XXX. */ uint32_t iot_plc_pm_power_check(void); /** * @brief trigger trigger power off process */ void iot_plc_pm_trig_power_off(void); /* @brief set power recover policy * @param policy: 1 - not restart, 0 - restart. */ void iot_plc_pm_set_power_recover_policy(uint32_t policy); #ifdef __cplusplus } #endif #endif /* IOT_PLC_PM_API_H */