Пример #1
0
/*---------------------------------------------------------------------------
 * Name: PWR_CheckForAndEnterNewPowerState
 * Description: - 
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
static PWRLib_WakeupReason_t PWR_CheckForAndEnterNewPowerState(PWR_CheckForAndEnterNewPowerState_t NewPowerState)
{
    PWRLib_WakeupReason_t ReturnValue;
    
    ReturnValue.AllBits = 0;
    
#if (cPWR_UsePowerDownMode)
    if (NewPowerState == PWR_Run)
    {
        /* ReturnValue = 0; */
    }
    else if(NewPowerState == PWR_OFF)
    {
        /* Disable all wake up sources */
#if cPWR_EnableDeepSleepMode_4    
        void PWRLib_LLWU_DisableAllWakeupSources();
        /* Configure MCU in VLLS0 mode */
        PWR_HandleDeepSleepMode_4();
#endif    
        /* Never returns */
        for(;;){}        
    }
    else if(NewPowerState == PWR_Reset)
    {
        /* Never returns */
        PWR_SystemReset();
    }
    
    else if(NewPowerState == PWR_DeepSleep)
    {
        if(PWR_CheckIfDeviceCanGoToSleep() && PWR_DeepSleepAllowed())
        {
            ReturnValue = PWR_HandleDeepSleep();
        }
    } 
    else if(NewPowerState == PWR_Sleep)
    {
        if(PWR_CheckIfDeviceCanGoToSleep() && PWR_SleepAllowed())
        {
            ReturnValue = PWR_HandleSleep();
        }
    }
    else
    {
        /* ReturnValue = FALSE; */
    }
    /* Clear wakeup reason */    
#else
    /* To remove warning for variabels in function call */
    (void)NewPowerState;
#endif /* #if (cPWR_UsePowerDownMode) */
    
    return ReturnValue;
}
Пример #2
0
void IdleTask(event_t events)
{
  /* Just to avoid the compiler warning */
  (void)events;
 #if gNvStorageIncluded_d
  /* Process NV Storage save-on-idle and save-on-count requests. */
  NvIdle();
 #endif
  #if (gLpmIncluded_d == 1)
  /*Low power management*/
    if(PWR_CheckIfDeviceCanGoToSleep())
      {
      PWR_EnterLowPower();
      }
  #endif /*gLpmIncluded_d*/ 
}