Esempio n. 1
0
////////////////////////////////////////////////////////////////////////////////
//! See hw_power.h for details.
////////////////////////////////////////////////////////////////////////////////
uint16_t hw_power_GetBatteryBrownoutVoltage(void)
{
    uint16_t BoRegCode;

    // Collect parameters for the conversion.
    BoRegCode = hw_power_GetBatteryBrownoutCode();

    // Return the converted value.
    return hw_power_ConvertSettingToBattBo( BoRegCode);
}
Esempio n. 2
0
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 Determines if the battery is charged enough to power DCDC's after
//! a handoff.
//!
//! \fntype Function
//!
//! \retval true Battery is sufficiently charged to power DCDC.
//! \retval false Battery is not sufficient to power DCDC.
////////////////////////////////////////////////////////////////////////////////
bool ddi_power_IsBattValidForHandoff( void )
{
    uint16_t u16SafeBattVolt;

    // First, check if we have a battery
    if( bBatteryConnected == false )
    {
        return false;
    }

    // Determine the brownout voltage.
    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 )
        return true;
    else
        return false;


}