!952 fix: 修复低功耗下时间更新缺陷
Merge pull request !952 from zhushengle/pm_timer
This commit is contained in:
commit
588abc0645
|
@ -101,21 +101,27 @@ STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
|
||||||
if ((tickTimer->timerStop != NULL) && (pm->enterSleepTime != 0)) {
|
if (tickTimer->timerStop != NULL) {
|
||||||
/* Restore the main CPU frequency */
|
if (pm->enterSleepTime != 0) {
|
||||||
sleepTime = tickTimer->timerCycleGet();
|
/* Restore the main CPU frequency */
|
||||||
tickTimer->timerStop();
|
sleepTime = tickTimer->timerCycleGet();
|
||||||
|
tickTimer->timerStop();
|
||||||
|
|
||||||
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
|
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
|
||||||
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, g_sysClock);
|
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, g_sysClock);
|
||||||
currTime = pm->enterSleepTime + realSleepTime;
|
currTime = pm->enterSleepTime + realSleepTime;
|
||||||
pm->enterSleepTime = 0;
|
pm->enterSleepTime = 0;
|
||||||
|
|
||||||
OsTickTimerBaseReset(currTime);
|
OsTickTimerBaseReset(currTime);
|
||||||
OsSchedResetSchedResponseTime(0);
|
OsSchedResetSchedResponseTime(0);
|
||||||
|
/* Restart the system tick timer */
|
||||||
|
tickTimer->tickUnlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Restore the system tick timer */
|
||||||
tickTimer->tickUnlock();
|
tickTimer->tickUnlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -142,14 +148,21 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||||
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
|
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
|
||||||
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
||||||
|
|
||||||
|
if (sleepCycle == 0) {
|
||||||
|
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* The main CPU reduces the frequency */
|
/* The main CPU reduces the frequency */
|
||||||
pm->enterSleepTime = LOS_SysCycleGet();
|
pm->enterSleepTime = LOS_SysCycleGet();
|
||||||
|
/* Turn off the system tick timer and clear the count value to zero */
|
||||||
tickTimer->tickLock();
|
tickTimer->tickLock();
|
||||||
tickTimer->timerStart(sleepCycle);
|
tickTimer->timerStart(sleepCycle);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Pause the system tick timer */
|
||||||
tickTimer->tickLock();
|
tickTimer->tickLock();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +180,7 @@ STATIC VOID OsPmCpuResume(LosPmCB *pm)
|
||||||
|
|
||||||
STATIC VOID OsPmCpuSuspend(LosPmCB *pm)
|
STATIC VOID OsPmCpuSuspend(LosPmCB *pm)
|
||||||
{
|
{
|
||||||
/* cpu enter low power mode */
|
/* cpu enter low-power mode */
|
||||||
|
|
||||||
if (pm->sysMode == LOS_SYS_NORMAL_SLEEP) {
|
if (pm->sysMode == LOS_SYS_NORMAL_SLEEP) {
|
||||||
pm->sysctrl->normalSuspend();
|
pm->sysctrl->normalSuspend();
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_pm
|
* @ingroup los_pm
|
||||||
* Pm error code: Invalid low power mode.
|
* Pm error code: Invalid low-power mode.
|
||||||
*
|
*
|
||||||
* Value: 0x02002001
|
* Value: 0x02002001
|
||||||
*
|
*
|
||||||
|
@ -141,21 +141,33 @@ typedef enum {
|
||||||
} LOS_PmNodeType;
|
} LOS_PmNodeType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 (*suspend)(UINT32 mode); /* The device enters low power consumption, Unlocked task scheduling. */
|
UINT32 (*suspend)(UINT32 mode); /* The device enters low-power consumption, Unlocked task scheduling. */
|
||||||
VOID (*resume)(UINT32 mode); /* The device exits from low power consumption, Unlocked task scheduling. */
|
VOID (*resume)(UINT32 mode); /* The device exits from low-power consumption, Unlocked task scheduling. */
|
||||||
} LosPmDevice;
|
} LosPmDevice;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 freq; /* The frequency of the low power timer */
|
/* Low-power timer related implementation functions.
|
||||||
VOID (*timerStart)(UINT64); /* Start the low power timer */
|
* The function is not NULL, the low-power timer is enabled.
|
||||||
VOID (*timerStop)(VOID); /* Stop the low power timer */
|
*/
|
||||||
UINT64 (*timerCycleGet)(VOID); /* Gets the running time of the low power timer in unit cycle */
|
UINT32 freq; /* The frequency of the low-power timer */
|
||||||
VOID (*tickLock)(VOID); /* Pause the system tick timer */
|
VOID (*timerStart)(UINT64); /* Start the low-power timer and set the response period */
|
||||||
VOID (*tickUnlock)(VOID); /* Restore the system tick timer */
|
VOID (*timerStop)(VOID); /* Turn off the low-power timer */
|
||||||
|
UINT64 (*timerCycleGet)(VOID); /* Gets the time the system sleeps */
|
||||||
|
|
||||||
|
/* When the low-power timer is enabled, the function of tickLock is to turn off the system tick timer and
|
||||||
|
* clear the timer's count value to zero.
|
||||||
|
* When the low-power timer is disabled, the function of tickLock is to pause the system timer.
|
||||||
|
*/
|
||||||
|
VOID (*tickLock)(VOID);
|
||||||
|
|
||||||
|
/* When the low-power timer is enabled, the function of tickUnlock is to restart the system tick timer.
|
||||||
|
* When the low-power timer is disabled, the function of tickUnlock is to restore the system tick timer.
|
||||||
|
*/
|
||||||
|
VOID (*tickUnlock)(VOID);
|
||||||
} LosPmTickTimer;
|
} LosPmTickTimer;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Preparations before the CPU enters low power consumption.
|
/* Preparations before the CPU enters low-power consumption.
|
||||||
* All modes except normal mode are invoked.
|
* All modes except normal mode are invoked.
|
||||||
* Unlocked task scheduling.
|
* Unlocked task scheduling.
|
||||||
*/
|
*/
|
||||||
|
@ -203,10 +215,10 @@ typedef struct {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_pm
|
* @ingroup los_pm
|
||||||
* @brief Initialize system low power frame.
|
* @brief Initialize system low-power frame.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
* This API is used to initialize the system low power frame.
|
* This API is used to initialize the system low-power frame.
|
||||||
*
|
*
|
||||||
* @attention None.
|
* @attention None.
|
||||||
*
|
*
|
||||||
|
@ -221,10 +233,10 @@ UINT32 OsPmInit(VOID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_pm
|
* @ingroup los_pm
|
||||||
* @brief Whether the low power consumption condition is met.
|
* @brief Whether the low-power consumption condition is met.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
* This API is used to check whether low power consumption is met.
|
* This API is used to check whether low-power consumption is met.
|
||||||
*
|
*
|
||||||
* @attention None.
|
* @attention None.
|
||||||
*
|
*
|
||||||
|
@ -302,10 +314,10 @@ VOID LOS_PmWakeSet(VOID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_pm
|
* @ingroup los_pm
|
||||||
* @brief Get the low power mode of the current system.
|
* @brief Get the low-power mode of the current system.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
* This API is used to get the low power mode of the current system.
|
* This API is used to get the low-power mode of the current system.
|
||||||
*
|
*
|
||||||
* @attention None.
|
* @attention None.
|
||||||
*
|
*
|
||||||
|
@ -320,14 +332,14 @@ LOS_SysSleepEnum LOS_PmModeGet(VOID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_pm
|
* @ingroup los_pm
|
||||||
* @brief Set low power mode.
|
* @brief Set low-power mode.
|
||||||
*
|
*
|
||||||
* @par Description:
|
* @par Description:
|
||||||
* This API is used to set low power mode.
|
* This API is used to set low-power mode.
|
||||||
*
|
*
|
||||||
* @attention None.
|
* @attention None.
|
||||||
*
|
*
|
||||||
* @param mode [IN] low power mode.
|
* @param mode [IN] low-power mode.
|
||||||
*
|
*
|
||||||
* @retval error code, LOS_OK means success.
|
* @retval error code, LOS_OK means success.
|
||||||
* @par Dependency:
|
* @par Dependency:
|
||||||
|
|
|
@ -64,7 +64,7 @@ LITE_OS_SEC_TEXT STATIC VOID OsUpdateSysTimeBase(VOID)
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT VOID OsTickTimerBaseReset(UINT64 currTime)
|
LITE_OS_SEC_TEXT VOID OsTickTimerBaseReset(UINT64 currTime)
|
||||||
{
|
{
|
||||||
LOS_ASSERT(currTime > g_tickTimerBase);
|
LOS_ASSERT(currTime >= g_tickTimerBase);
|
||||||
|
|
||||||
g_tickTimerBase = currTime;
|
g_tickTimerBase = currTime;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue