You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
software/kkk/los_lowpower_impl.h

160 lines
7.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/* ----------------------------------------------------------------------------
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: Low-power Framework.
* Author: Huawei LiteOS Team
* Create: 2020-09-19
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */
#ifndef _LOS_LOWPOWER_IMPL_H
#define _LOS_LOWPOWER_IMPL_H
#include "los_lowpower.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @ingroup los_lowpower
*
* Power manager run options
*/
typedef struct {
VOID (*changeFreq)(UINT8 freq); /**< Tune system frequency */
VOID (*enterLightSleep)(VOID); /**< Enter light sleep */
VOID (*enterDeepSleep)(VOID); /**< Enter deep sleep */
VOID (*setWakeUpTimer)(UINT32 timeout); /**< Set wakeup timer */
UINT32 (*withdrawWakeUpTimer)(VOID); /**< Withdraw wakeup timer */
UINT32 (*getSleepTime)(VOID); /**< Get sleep time */
UINT32 (*selectSleepMode)(UINT32); /**< Select sleep mode, developers can set their own mode selecetion
strategy */
UINT32 (*preConfig)(VOID); /**< Preconfig, provided for special needs before entering sleep */
VOID (*postConfig)(VOID); /**< Postconfig, provided for special needs after wakeup */
VOID (*contextSave)(VOID); /**< Context save */
VOID (*contextRestore)(VOID); /**< Context restore */
UINT32 (*getDeepSleepVoteCount)(VOID); /**< Get deep sleep vote count */
UINT32 (*getSleepMode)(VOID); /**< Get sleep mode */
VOID (*setSleepMode)(UINT32 mode); /**< Set sleep mode */
} PowerMgrRunOps;
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ýṹ<C3BD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>º<EFBFBD><C2BA><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>
changeFreq<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳƵ<EFBFBD>ʡ<EFBFBD>
enterLightSleep<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD>ߣ<EFBFBD>light sleep<65><70>ģʽ<C4A3><CABD>
enterDeepSleep<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD>ߣ<EFBFBD>deep sleep<65><70>ģʽ<C4A3><CABD>
setWakeUpTimer<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>Ѷ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
withdrawWakeUpTimer<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѷ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
getSleepTime<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ˯<EFBFBD><EFBFBD>ʱ<EFBFBD>
selectSleepMode<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ģʽ<EFBFBD>IJ<EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
preConfig<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
postConfig<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ڻ<EFBFBD><EFBFBD>Ѻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
contextSave<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD>
contextRestore<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD>
getDeepSleepVoteCount<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ͶƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
getSleepMode<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ˯<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
setSleepMode<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>*/
/**
* @ingroup los_lowpower
*
* Power manager config, corresponding to mode selection strategies.
*/
typedef struct {
UINT32 minLightSleepTicks; /**< Min light sleep ticks */
UINT32 minDeepSleepTicks; /**< Min deep sleep ticks */
UINT32 maxDeepSleepTicks; /**< Max deep sleep ticks */
} PowerMgrConfig;
/*minLightSleepTicks<6B><73><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>˯<EFBFBD>ߣ<EFBFBD>light sleep<65><70>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
minDeepSleepTicks<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD>ߣ<EFBFBD>deep sleep<65><70>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
maxDeepSleepTicks<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD>ߣ<EFBFBD>deep sleep<65><70>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>벻ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʹ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
/**
* @ingroup los_lowpower
*
* Power manager deep sleep options
*/
typedef struct {
BOOL (*couldDeepSleep)(VOID); /**< Check whether could enter deep sleep */
VOID (*systemWakeup)(VOID); /**< System wakup */
BOOL (*suspendPreConfig)(VOID); /**< Suspend preconfig, provided for special needs before entering deep sleep */
VOID (*suspendDevice)(VOID); /**< Supend device before entering deep sleep */
VOID (*rollback)(VOID); /**< Rollback if failed */
VOID (*resumeDevice)(VOID); /**< Resume device after wakeup from deep sleep */
VOID (*resumePostConfig)(VOID); /**< Resume postconfig, provided for special needs after wakeup from deep sleep */
VOID (*resumeCallBack)(VOID); /**< Resume callback */
VOID (*otherCoreResume)(VOID); /**< Other core Resume for multi-core scenes */
VOID (*resumeFromReset)(VOID); /**< Resume from image */
} PowerMgrDeepSleepOps;
/*couldDeepSleep<65><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>״̬<D7B4><CCAC>
systemWakeup<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD>
suspendPreConfig<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ͣԤ<EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
suspendDevice<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD>
rollback<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>
resumeDevice<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>״̬<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
resumePostConfig<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>״̬<EFBFBD>лָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĻָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
resumeCallBack<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>
otherCoreResume<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵĻָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
resumeFromReset<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>лָ<EFBFBD><EFBFBD><EFBFBD>*/
/**
* @ingroup los_lowpower
*
* Power manager parameter
*/
typedef struct {
PowerMgrRunOps runOps; /**< power manager framework running operations */
PowerMgrDeepSleepOps deepSleepOps; /**< power manager deep sleep operations */
PowerMgrConfig config; /**< power manager config */
} PowerMgrParameter;
/*runOps<70><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ PowerMgrRunOps <20>Ľṹ<C4BD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>״̬<D7B4>µĹ<C2B5><C4B9>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD>
deepSleepOps<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ PowerMgrDeepSleepOps <20>Ľṹ<C4BD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>״̬<D7B4>µĹ<C2B5><C4B9>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD>
config<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ PowerMgrConfig <20>Ľṹ<C4BD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><C3B9>Ĺ<EFBFBD><C4B9><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>벻ͬ<EBB2BB><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>ģʽ<C4A3><CABD>
ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD> PowerMgrParameter <20><EFBFBD><E1B9B9><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ֶ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>״̬<D7B4>µĹ<C2B5><C4B9>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳһ<CDB3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>*/
/**
* @ingroup los_lowpower
* @brief Init the power manager framework.
*
* @par Description:
* This API is used to init the power manager framework.
*
* @attention None.
*
* @param para [IN] The power manager parameter.
*
* @retval None.
* @par Dependency:
* <ul><li>los_lopower_impl.h: the header file that contains the API declaration.</li></ul>
* @see None.
* @since Huawei LiteOS V200R005C10
*/
extern VOID LOS_PowerMgrInit(const PowerMgrParameter *para);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif // _LOS_LOWPOWER_IMPL_H