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; }
RtStatus_t hw_power_InitFiq(void) { uint16_t u16SafeBattVolt; extern uint8_t g_ddi_power_SafeBatteryVoltageCode; //-------------------------------------------------------------------------- // Clear the brownout interrupts. //-------------------------------------------------------------------------- hw_power_ClearVdddBrownoutInterrupt(); hw_power_ClearVddaBrownoutInterrupt(); hw_power_ClearVddioBrownoutInterrupt(); //-------------------------------------------------------------------------- // Enable the power supply to assert brownout interrupts. //-------------------------------------------------------------------------- hw_power_EnableVdddBrownoutInterrupt(TRUE); hw_power_EnableVddaBrownoutInterrupt(TRUE); hw_power_EnableVddioBrownoutInterrupt(TRUE); //-------------------------------------------------------------------------- // Enable the battery brownout interrupt. //-------------------------------------------------------------------------- // Check the battery. Don't enable the brownout until the battery has at // least reached a level where it can do a handoff. u16SafeBattVolt = hw_power_ConvertSettingToBattBo( g_ddi_power_SafeBatteryVoltageCode ); // Check if the battery level is high enough for DCDC to operate. if( hw_power_GetBatteryVoltage() > u16SafeBattVolt ) { hw_power_ClearBatteryBrownoutInterrupt(); hw_power_EnableBatteryBrownoutInterrupt( true ); hw_power_EnableBattBrownoutPowerdown( false ); } return SUCCESS; }
//////////////////////////////////////////////////////////////////////////////// //! \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 ); }