/* * Copyright (c) 2022 OpenLuat & AirM2M * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef LUAT_PM_H #define LUAT_PM_H #include "luat_base.h" /** * @defgroup luatos_pm 电源管理接口 * @{ */ /* ------------------------------------------------ sleep begin----------------------------------------------- */ #define LUAT_PM_SLEEP_MODE_NONE 0 ///< 系统处于活跃状态,未采取任何的降低功耗状态 #define LUAT_PM_SLEEP_MODE_IDLE 1 ///< 空闲模式,该模式在系统空闲时停止 CPU 和部分时钟,任意事件或中断均可以唤醒 #define LUAT_PM_SLEEP_MODE_LIGHT 2 ///< 轻度睡眠模式,CPU 停止,多数时钟和外设停止 #define LUAT_PM_SLEEP_MODE_DEEP 3 ///< 深度睡眠模式,CPU 停止,仅少数低功耗外设工作,可被特殊中断唤醒 #define LUAT_PM_SLEEP_MODE_STANDBY 4 ///< 待机模式,CPU 停止,设备上下文丢失(可保存至特殊外设),唤醒后通常复位 //#define LUAT_PM_SLEEP_MODE_SHUTDOWN 5 ///<关断模式,比 Standby 模式功耗更低, 上下文通常不可恢复, 唤醒后复位 /** * @brief 设置最深休眠模式标记 * * @param mode 最深休眠模式 * @param vote_tag 休眠标记 * @return int =0成功,其他失败 */ int luat_pm_set_sleep_mode(int mode, const char *vote_tag); /** * @brief 获取休眠标记对应的休眠模式 * * @param vote_tag 休眠标记 * @return int = -1 失败,其他成功 */ int luat_pm_get_sleep_mode(const char *vote_tag); typedef void (*luat_pm_sleep_callback_t)(int mode); /** * @brief 注册休眠前回调函数 * * @param callback_fun 休眠前用户回调 * @return int =0成功,其他失败 */ int luat_pm_sleep_register_pre_handler(luat_pm_sleep_callback_t callback_fun); /** * @brief 解注册休眠前回调函数 * * @return int =0成功,其他失败 */ int luat_pm_sleep_deregister_pre_handler(void); /** * @brief 注册唤醒后回调函数 * * @param callback_fun 唤醒后用户回调 * @return int =0成功,其他失败 */ int luat_pm_sleep_register_post_handler(luat_pm_sleep_callback_t callback_fun); /** * @brief 解注册唤醒后回调函数 * * @param callback_fun 唤醒后用户回调 * @return int =0成功,其他失败 */ int luat_pm_sleep_deregister_post_handler(void); /*------------------------------------------------ sleep end----------------------------------------------- */ /* ----------------------------------------------- wkaeup begin---------------------------------------------- */ /** * @brief wakeupPad */ typedef enum LUAT_PM_WAKEUP_PAD { LUAT_PM_WAKEUP_PAD_0 = 0, /**