Beispiel #1
0
////////////////////////////////////////////////////////////////////////////////
//! See hw_power.h for details.
////////////////////////////////////////////////////////////////////////////////
void hw_power_SetBatteryBrownoutVoltage( uint16_t BoVolt )
{
    uint16_t BoRegCode;
    uint16_t MaxBoRegCode;

    BoRegCode = hw_power_ConvertBattBoToSetting( BoVolt);

    // Verify the value is valid and set it.  Note that an invalid value
    // will not be set to the register.

    MaxBoRegCode = BATT_BRWNOUT_MAX_REG_CODE_378x;

    if ( BoRegCode <= MaxBoRegCode )
    {
        hw_power_SetBatteryBrownoutCode( BoRegCode );
    }
}
////////////////////////////////////////////////////////////////////////////////
//! \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 );


}