RtStatus_t hw_power_InitPowerSupplies(void) { RtStatus_t Status; //---------------------------------------------------------------------- // Make sure the power supplies are configured for their power sources. // This sets the LINREG_OFFSET field correctly for each power supply. //--------------------------------------------------------------------- if(hw_power_Get5vPresentFlag()) { if((Status = hw_power_SetVdddPowerSource(HW_POWER_LINREG_DCDC_READY)) != SUCCESS) return Status; if((Status = hw_power_SetVddaPowerSource(HW_POWER_LINREG_DCDC_READY)) != SUCCESS) return Status; if((Status = hw_power_SetVddioPowerSource(HW_POWER_LINREG_DCDC_READY)) != SUCCESS) return Status; } else { if((Status = hw_power_SetVdddPowerSource(HW_POWER_DCDC_LINREG_READY)) != SUCCESS) return Status; if((Status = hw_power_SetVddaPowerSource(HW_POWER_DCDC_LINREG_READY)) != SUCCESS) return Status; if((Status = hw_power_SetVddioPowerSource(HW_POWER_DCDC_LINREG_READY)) != SUCCESS) return Status; // Need to make sure the DCDC does not run with a bad or broken battery. if( hw_power_GetBatteryVoltage() <= 2800 ) { hw_power_PowerDown(); } hw_power_ClearBatteryBrownoutInterrupt(); hw_power_EnableBatteryBrownoutInterrupt(true); hw_power_EnableDcdc(true); } //-------------------------------------------------------------------------- // Done. //-------------------------------------------------------------------------- return SUCCESS; }
//////////////////////////////////////////////////////////////////////////////// //! \brief Transfers the power source from battery to 5V. //! //! \fntype Function //! //! This function handles the transitions on each of the power rails necessary //! to power the chip from the 5V power supply when it was previously powered //! from the battery power supply. //! //////////////////////////////////////////////////////////////////////////////// void ddi_power_ExecuteBatteryTo5VoltsHandoff(void) { //---------------------------------------------------------------------- // Start the 4p2 rail and power DCDC from it. //---------------------------------------------------------------------- if(ddi_power_Is4p2Enabled()) { ddi_power_Start4p2(); return; } //-------------------------------------------------------------------------- // We are about to power the chip solely from 5V, and possibly without // handoffs enabled. We need to make sure the chip shuts down properly // if 5V is removed in this window. //-------------------------------------------------------------------------- hw_power_Enable5vBrownoutPowerdown( true ); hw_power_SetVdddPowerSource(HW_POWER_LINREG_DCDC_READY); hw_power_SetVddaPowerSource(HW_POWER_LINREG_DCDC_READY); hw_power_SetVddioPowerSource(HW_POWER_LINREG_DCDC_READY); //---------------------------------------------------------------------- // Disable the DCDC during 5V connections. //---------------------------------------------------------------------- hw_power_EnableDcdc(false); }
//////////////////////////////////////////////////////////////////////////////// //! \brief Transfers the power source from 5V to the battery. //! //! \fntype Function //! //! This function will handle all the power rail transitions necesarry to power //! the chip from the battery when it was previously powered from the 5V power //! source. //! //////////////////////////////////////////////////////////////////////////////// void ddi_power_Execute5VoltsToBatteryHandoff(void) { if(ddi_power_Is4p2Enabled()) { //---------------------------------------------------------------------- // Stop the 4p2 rail from powering the DCDC //---------------------------------------------------------------------- ddi_power_Stop4p2(); //-------------------------------------------------------------------------- // Disable hardware power down when 5V is inserted or removed //-------------------------------------------------------------------------- hw_power_Enable5vBrownoutPowerdown( false ); //-------------------------------------------------------------------------- // Re-enable the battery brownout interrupt in case it was disabled. //-------------------------------------------------------------------------- hw_power_EnableBatteryBrownoutInterrupt(TRUE); return; } //-------------------------------------------------------------------------- // We are about to power the chip from battery. If the battery level is // at the hard brownout level, the FIQ handler will shut down the chip. // Set the hard level and enable the battery interrupt. //-------------------------------------------------------------------------- hw_power_SetBatteryBrownoutCode( g_ddi_power_BatteryBrownOutVoltageCode ); hw_power_EnableBatteryBrownoutInterrupt( true ); // Enforce battery powered operation hw_power_EnableDcdc(true); //-------------------------------------------------------------------------- if(hw_power_GetVdddPowerSource() == HW_POWER_EXTERNAL_SOURCE_5V) { // When powered from external sources, we need to temporarily // increase the target to prevent the DCDC from fighting // with the external source. PMI will change the target to // the correct voltage after the source transition. hw_power_SetVdddBrownoutValue(175); hw_power_SetVdddValue(1575); ddi_power_WaitForVdddStable(); hw_power_SetVdddBrownoutValue(125); } hw_power_SetVdddPowerSource(HW_POWER_DCDC_LINREG_READY); //-------------------------------------------------------------------------- // Power VDDA and VDDIO from the DCDC. //-------------------------------------------------------------------------- hw_power_SetVddaPowerSource(HW_POWER_DCDC_LINREG_READY); hw_power_SetVddioPowerSource(HW_POWER_DCDC_LINREG_ON); //-------------------------------------------------------------------------- // Disable hardware power down when 5V is inserted or removed //-------------------------------------------------------------------------- hw_power_Enable5vBrownoutPowerdown( false ); //-------------------------------------------------------------------------- // Transition to battery power went smoothly. Now reset the soft battery // level for normal battery operation. //-------------------------------------------------------------------------- hw_power_SetBatteryBrownoutCode( g_ddi_power_SafeBatteryVoltageCode ); hw_power_EnableBatteryBrownoutInterrupt( true ); }