/*--------------------------------------------------------------------------*/
/* Get system-level sleep status */
/*--------------------------------------------------------------------------*/
bool CPU_SystemSleepStatusGet(uint32_t *sysSleepStat)
{
bool rc = true;
/* Check conditions to enter system sleep */
*sysSleepStat = CPU_SLEEP_MODE_SUSPEND;
uint32_t cpuIdx = 0U;
for (cpuIdx = 0U; cpuIdx < CPU_NUM_IDX; cpuIdx++)
{
if ((cpuIdx != CPU_IDX_M33P) &&
((s_cpuLpComputeList & (1UL << cpuIdx)) == 0U))
{
/* Check if sleep is forced for the CPU */
bool sleepForce;
if (CPU_SleepForceGet(cpuIdx, &sleepForce))
{
/* If sleep is not forced, consider the CPU mode */
if (!sleepForce)
{
/* Get GPC CPU mode status */
uint32_t cpuModeStat =
s_gpcCpuCtrlPtrs[cpuIdx]->CMC_MODE_STAT;
/* Default CPU mode as RUN until SLEEPING_IDLE confirmed */
uint32_t cpuModeCur = CPU_SLEEP_MODE_RUN;
/* Check if CPU in SLEEPING_IDLE state */
if ((cpuModeStat &
GPC_CPU_CTRL_CMC_MODE_STAT_SLEEPING_IDLE_MASK) != 0U)
{
/* CPU_MODE_CURRENT reflects active mode */
cpuModeCur = (cpuModeStat &
GPC_CPU_CTRL_CMC_MODE_STAT_CPU_MODE_CURRENT_MASK) >>
GPC_CPU_CTRL_CMC_MODE_STAT_CPU_MODE_CURRENT_SHIFT;
}
/* Keep track of lowest CPU mode (RUN is lowest) */
if (cpuModeCur < *sysSleepStat)
{
*sysSleepStat = cpuModeCur;
}
}
}
}
}
return rc;
}