Ejemplo n.º 1
0
/*---------------------------------------------------------------------------
 * Name: PWR_EnterLowPower
 * Description: - 
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
PWRLib_WakeupReason_t PWR_EnterLowPower(void)
{
    PWRLib_WakeupReason_t ReturnValue;
    
#if (gTMR_EnableLowPowerTimers_d) 
    bool_t unlockTMRThread = FALSE;
#endif
    
    ReturnValue.AllBits = 0;
    
    if(PWR_LVD_ReportLevel() == PWR_LEVEL_CRITICAL)
    {
        /* Voltage <= 1.8V so enter power-off state - to disable false Tx'ing(void)*/
        ReturnValue = PWR_CheckForAndEnterNewPowerState(PWR_OFF);
    }
    
    OSA_InterruptDisable();
    
    if (TMR_AreAllTimersOff())  /*No timer running*/
    {
        /* If power lib is enabled */	
#if (cPWR_UsePowerDownMode)
        /* If Low Power Capability is enabled */
#if (gTMR_EnableLowPowerTimers_d) 
        /* If more low power timers are running, stop the hardware timer
         *and save the spend time in ticks that wasn't counted.
         */
        unlockTMRThread = TRUE;
#endif /* (gTMR_EnableLowPowerTimers_d) */
#endif /* (cPWR_UsePowerDownMode) */
        
        ReturnValue = PWR_CheckForAndEnterNewPowerState(PWR_DeepSleep);
    }
    else /* Timers are running */
    {
        ReturnValue = PWR_CheckForAndEnterNewPowerState(PWR_Sleep);
    }
    
    OSA_InterruptEnable();
    
#if (gTMR_EnableLowPowerTimers_d)
    if(unlockTMRThread)
    {
        TMR_MakeTMRThreadReady();
    }
    
#endif    
    return ReturnValue;
}
Ejemplo n.º 2
0
PWRLib_WakeupReason_t PWR_EnterLowPower(void)
{
		 
  uint8_t ccr;
  PWRLib_WakeupReason_t ReturnValue;  
  ReturnValue.AllBits = 0;
  
  
  if (PWRLib_LVD_ReportLevel() == PWR_NODEPOWER_LEVEL_CRITICAL) {
    /* Voltage <= 1.8V so enter power-off state - to disable false Tx'ing(void)*/
    ReturnValue = PWR_CheckForAndEnterNewPowerState( PWR_OFF, 0);
  }
  IrqControlLib_BackupIrqStatus(ccr);    
  IrqControlLib_DisableAllIrqs();
  if (TS_PendingEvents() == FALSE)
  {		 
    PWRLib_SetCurrentZigbeeStackPowerState(StackPS_DeepSleep);
    if (TMR_AreAllTimersOff())  /*No timer running*/
    {			
      /* if Low Power Capability is enabled*/
      #if (gTMR_EnableLowPowerTimers_d)   
       /* if more low power timers are running, stop the hardware timer
        and save the spend time in millisecond that wasn't counted.
        */
       notCountedTimeBeforeSleep = TMR_NotCountedMillisTimeBeforeSleep();
      #endif /* #if (gTMR_EnableLowPowerTimers_d)  */
    
      ReturnValue = PWR_CheckForAndEnterNewPowerState ( PWR_DeepSleep, cPWR_RTITicks);
    }else /*timers are running*/
    { 	 
     ReturnValue = PWR_CheckForAndEnterNewPowerState ( PWR_Sleep, 0);
    }
  } /* enable irq's if there is pending evens */
  IrqControlLib_RestoreIrqStatus(ccr);
  
  return ReturnValue;
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------
 * Name: PWR_EnterPowerOff
 * Description: - Radio on Reset, MCU on VLLS1
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
void PWR_EnterPowerOff(void)
{
    OSA_InterruptDisable();
    (void)PWR_CheckForAndEnterNewPowerState(PWR_OFF);
    OSA_InterruptEnable();
}