Beispiel #1
0
// Shut down for good after the user says it's OK and runs any last-minute logic
static void lvShutdown(void)
{
  uint16_t shutdownVoltage = emberAfPluginLowVoltageShutdownGetVoltage();
  if (emberAfPluginLowVoltageShutdownOkToShutdownCallback(shutdownVoltage)) {
    emberAfPluginLowVoltageShutdownPreShutdownCallback(shutdownVoltage);
    halPowerDown();
    halInternalSleep(SLEEPMODE_NOTIMER);
  } else {
    // User won't let us shut down yet, so check back after a brief interval
    emberEventControlSetDelayMS(myEvent, EMBER_AF_PLUGIN_LOW_VOLTAGE_SHUTDOWN_SHUTDOWN_POSTPONE_DURATION_MS);
  }
}
Beispiel #2
0
/**
  * @brief  check if the device needs to go to deep sleep to save power
  * @param  active: Flag to indicate whether the node is active or not
  * @param  batteryOperated: Flag to activate power management
  * @retval None
  */
void powerManagement(boolean active, boolean batteryOperated)
{
  static uint32_t inactiveStartTime = 0;
  
  if (!batteryOperated)
    return;
  
  if (inactiveStartTime == 0)
  {
    inactiveStartTime = halCommonGetInt16uQuarterSecondTick();
  }
  
  if (active)
  {
    /* Reset inactive start time */
    inactiveStartTime = halCommonGetInt16uQuarterSecondTick();
  }
  else
  {
    if(elapsedTimeInt16u(inactiveStartTime, halCommonGetInt16uQuarterSecondTick()) > INACTIVE_TIMEOUT) 
    {
      StStatus status;
      
      ST_RadioSleep();
      ATOMIC(
             halPowerDown();
             halSleepWithOptions(SLEEPMODE_NOTIMER,
                                 BUTTON_S1_WAKE_SOURCE|
#ifdef USE_MB950
                                 BUTTON_S2_WAKE_SOURCE|
                                 BUTTON_S3_WAKE_SOURCE|
                                 BUTTON_S4_WAKE_SOURCE|
                                 BUTTON_S5_WAKE_SOURCE|
#endif /* USE_MB950 */
                                 UART_RX_WAKE_SOURCE);
             halPowerUp();
             )
      /* It is the application's responsibility to reinitialize the UART */
      uartInit();
    
      status = ST_RadioInit(ST_RADIO_POWER_MODE_RX_ON);
      assert(status==ST_SUCCESS);  
      inactiveStartTime = halCommonGetInt16uQuarterSecondTick();
    }