mirror of
https://gitee.com/moluo-tech/CodeBrick.git
synced 2025-01-16 04:32:51 +08:00
84 lines
2.4 KiB
C
84 lines
2.4 KiB
C
/******************************************************************************
|
||
* @brief <20><><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD>(power manager)
|
||
*
|
||
* Copyright (c) 2021, <morro_luo@163.com>
|
||
*
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*
|
||
* Change Logs:
|
||
* Date Author Notes
|
||
* 2021-03-02 Morro Initial version.
|
||
******************************************************************************/
|
||
#ifndef _PM_H_
|
||
#define _PM_H_
|
||
|
||
#include "comdef.h"
|
||
#include <stdbool.h>
|
||
|
||
#define __pm_item_register(name, idle, suspend, resume)\
|
||
USED ANONY_TYPE(const pm_item_t,__pm_item_##suspend)\
|
||
SECTION("pm.item.1") = {name, idle, suspend, resume}
|
||
|
||
typedef struct {
|
||
/**
|
||
* @brief <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||
*/
|
||
const char *name;
|
||
/**
|
||
* @brief <20><>ǰ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>״̬(ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>pm_item_t<5F><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||
* @note <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NULL,<2C><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
||
* @retval true - <20><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,false - <20><><EFBFBD><EFBFBD>ģʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
bool (*idle)(void);
|
||
/**
|
||
* @brief <20><><EFBFBD><EFBFBD>֪ͨ
|
||
* @retval <20>´λ<C2B4><CEBB><EFBFBD>ʱ<EFBFBD><CAB1>(<28><>λ:ms, 0 - <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>)
|
||
*/
|
||
unsigned int (*sleep_notify)(void);
|
||
/**
|
||
* @brief <20><><EFBFBD><EFBFBD>֪ͨ
|
||
* @retval none
|
||
*/
|
||
void (*wakeup_notify)(void);
|
||
}pm_item_t;
|
||
|
||
/*<2A><EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ---------------------------------------------------------------*/
|
||
typedef struct {
|
||
/**
|
||
* @brief ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(ms)
|
||
*/
|
||
unsigned int max_sleep_time;
|
||
/**
|
||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||
* @param[in] time - <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(ms)
|
||
* @retval ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||
* @note <20><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD>Ź<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* <20>ڼ䷢<DABC><E4B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ϵͳ<CFB5>δ<EFBFBD>ʱ<EFBFBD><CAB1>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䲻<E4B2BB><D7BC>
|
||
*/
|
||
unsigned int (*goto_sleep)(unsigned int time);
|
||
}pm_adapter_t;
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||
* @param[in] name - <20><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
||
* @param[in] idle - ָʾ<D6B8>豸<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NULL,<2C><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
||
* @param[in] sleep_notify - <20><><EFBFBD><EFBFBD>֪ͨ,<2C><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>NULL
|
||
* @param[in] wakeup_notify - <20><><EFBFBD><EFBFBD>֪ͨ,<2C><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>NULL
|
||
*/
|
||
#define pm_dev_register(name, idle, sleep_notify, wakeup_notify)\
|
||
__pm_item_register(name, idle, sleep_notify, wakeup_notify)
|
||
|
||
|
||
void pm_init(const pm_adapter_t *adt);
|
||
|
||
void pm_enable(void);
|
||
|
||
void pm_disable(void);
|
||
|
||
void pm_process(void);
|
||
|
||
|
||
#endif
|
||
|