示例#1
0
/****************************************************************************
NAME    
    powerManagerHandleVbatLow
    
DESCRIPTION
    Called when the battery voltage is detected to be in Battery Low state
*/
static void powerManagerHandleVbatLow( void )
{
    sinkState lSinkState = stateManagerGetState ();
    bool batt_was_low = powerManagerIsVbatLow();

    PM_DEBUG(("PM: Battery Low\n"));
    if(powerManagerIsChargerConnected() || lSinkState == deviceLimbo)
    {
        theSink.battery_state = POWER_BATT_LEVEL0;
    }
    else
    {
        theSink.battery_state = POWER_BATT_LOW;  
    }

    if(!batt_was_low || !powerManagerIsVbatLow())
    {
        /* update state indication to indicate low batt state change */
#ifndef NO_LED         
        LEDManagerIndicateState( lSinkState );
#endif        
    }
    
    AudioSetPower(powerManagerGetLBIPM());
}
示例#2
0
/****************************************************************************
NAME    
    powerManagerChargerConnected
    
DESCRIPTION
    This function is called when the charger is plugged into the device
    
RETURNS
    void
*/
void powerManagerChargerConnected( void )
{
    PM_DEBUG(("PM: Charger has been connected\n"));
    /* Monitor charger state */
    PowerChargerMonitor();
    /* notify the audio plugin of the new power state */
    AudioSetPower(POWER_BATT_LEVEL3);
}
/****************************************************************************
NAME    
    powerManagerChargerConnected
    
DESCRIPTION
  	This function is called when the charger is plugged into the headset
    
RETURNS
    void
*/
void powerManagerChargerConnected( void )
{
    PM_DEBUG(("PM: Charger has been connected\n"));
    setChargeEnablePio(TRUE);

	#ifdef InitCharger
	if(theHeadset.BHC612_PowerInitComplete)
		PowerCharger(TRUE);
	#else
	PowerCharger(TRUE);
    #endif
		
    /* notify the audio plugin of thenew power state */
    AudioSetPower(POWER_BATT_LEVEL3);
    
}
示例#4
0
/****************************************************************************
NAME    
    batteryNormal
    
DESCRIPTION
    Called when the battery voltage is detected to be in a Normal state
*/
static void powerManagerHandleVbatNormal(uint8 level)
{
#ifndef NO_LED     
    bool low_batt = powerManagerIsVbatLow();
#endif    
    PM_DEBUG(("PM: Battery Normal %d\n", level));
    MessageSend(&theSink.task, EventSysBatteryOk, 0);
    
    /* If charger connected send a charger gas gauge message (these don't have any functional use but can be associated with LEDs/tones) */
    if (powerManagerIsChargerConnected())
        MessageSend(&theSink.task, (EventSysChargerGasGauge0+level), 0);
    
    /* reset any low battery warning that may be in place */
    theSink.battery_state = POWER_BATT_LEVEL0 + level;
    csr2csrHandleAgBatteryRequestRes(level);
#ifndef NO_LED 
    /* when changing from low battery state to a normal state, refresh the led state pattern
       to replace the low battery pattern should it have been shown */
    if(low_batt) LEDManagerIndicateState(stateManagerGetState());
#endif    
    AudioSetPower(powerManagerGetLBIPM());
}
/****************************************************************************
NAME    
    handleBatteryLevelInd
    
DESCRIPTION
    Called when the battery voltage is detected to be in a Normal state
*/
static void handleBatteryLevelInd(power_battery_level pLevel)
{
    /* based on the pLevel and send different messages */
    switch(pLevel)
    {
        case POWER_BATT_CRITICAL:
            PM_DEBUG(("PM: POWER_BATTERY_SHUTDOWN\n"));
            if ( (!ChargerIsChargerConnected()) && stateManagerGetState() != headsetLimbo )
	        {
    	        MessageSend(&theHeadset.task, EventLowBattery, 0); 
		        MessageSend(&theHeadset.task, EventPowerOff, 0);
	        }
            /* reset any low battery warning that may be in place */
            theHeadset.battery_low_state   = FALSE;  
            theHeadset.low_battery_flag_ag = FALSE;
        break;
        case POWER_BATT_LOW:
#ifdef BHC612
		if(theHeadset.batt_level != POWER_BATT_LOW)
		{
			theHeadset.batt_level = POWER_BATT_LOW;
			/*MessageSendLater(&theHeadset.task, EventBatteryLevelRequest, 0,100);*/ 
			PM_DEBUG(("batt_level = low\n"));
		}
#endif			
            handleBatteryLow();
        break;
        case POWER_BATT_LEVEL0:
#ifdef BHC612
		if(theHeadset.batt_level != POWER_BATT_LEVEL0)
		{
			theHeadset.batt_level = POWER_BATT_LEVEL0;
			/*MessageSendLater(&theHeadset.task, EventBatteryLevelRequest, 0,100);*/ 
			PM_DEBUG(("batt_level = 0\n"));
		}
#endif
		handleBatteryNormal(pLevel);
		break;
	    case POWER_BATT_LEVEL1:
#ifdef BHC612
		if(theHeadset.batt_level != POWER_BATT_LEVEL1)
		{
			theHeadset.batt_level = POWER_BATT_LEVEL1;
			/*MessageSendLater(&theHeadset.task, EventBatteryLevelRequest, 0,100); */
			PM_DEBUG(("batt_level = 1\n"));
		}
#endif
		handleBatteryNormal(pLevel);
		break;			
	    case POWER_BATT_LEVEL2:
#ifdef BHC612
		if(theHeadset.batt_level != POWER_BATT_LEVEL2)
		{
			theHeadset.batt_level = POWER_BATT_LEVEL2;
			/*MessageSendLater(&theHeadset.task, EventBatteryLevelRequest, 0,100); */
			PM_DEBUG(("batt_level = 2\n"));
		}
#endif
		handleBatteryNormal(pLevel);
		break;						
	    case POWER_BATT_LEVEL3:
#ifdef BHC612
		if(theHeadset.batt_level != POWER_BATT_LEVEL3)
		{
			theHeadset.batt_level = POWER_BATT_LEVEL3;
			/*MessageSendLater(&theHeadset.task, EventBatteryLevelRequest, 0,100); */
			PM_DEBUG(("batt_level = 3\n"));
		}
#endif
		handleBatteryNormal(pLevel);			
        	break;
        default :
            PM_DEBUG(("PM: Unhandled Battery Level[%x]\n", pLevel));
        break ;           
    }
    
    /* notify the audio plugin of the new power state, 
       if the charger is connected this is fixed at max level */
    AudioSetPower(LBIPMPowerLevel());
}