⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headset_statemanager.c

📁 蓝牙耳机的源代码,结合csr的开发套件使用
💻 C
📖 第 1 页 / 共 2 页
字号:
	single point of entry for the incoming call establish stateRETURNS	void    */void stateManagerEnterIncomingCallEstablishState ( hsTaskData * pApp ){    if (stateManagerGetState() == headsetConnectable )    {        if (pApp->features.AutoAnswerOnConnect )        {                /*then attempt to answer the call*/            MessageSend (&pApp->task , EventAnswer , 0 ) ;        }    }    stateManagerSetState ( pApp , headsetIncomingCallEstablish ) ;        if (pApp->PIO.IncomingRingPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.IncomingRingPIO , TRUE) ;    }        soundManagerSendAndSetCurrentVolume (pApp ) ;}/****************************************************************************NAME		stateManagerEnterOutgoingCallEstablishStateDESCRIPTION	single point of entry for the outgoing call establish stateRETURNS	void    */void stateManagerEnterOutgoingCallEstablishState ( hsTaskData * pApp ){    stateManagerSetState ( pApp , headsetOutgoingCallEstablish ) ;        if (pApp->PIO.OutgoingRingPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.OutgoingRingPIO , TRUE) ;    }}/****************************************************************************NAME		stateManagerEnterActiveCallStateDESCRIPTION	single point of entry for the active call stateRETURNS	void    */void stateManagerEnterActiveCallState ( hsTaskData * pApp )   {    stateManagerSetState ( pApp , headsetActiveCall ) ;            /*disable the ring PIOs if enabled*/    if (pApp->PIO.IncomingRingPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.IncomingRingPIO , FALSE) ;    }    if (pApp->PIO.OutgoingRingPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.OutgoingRingPIO , FALSE) ;    }            /*enable the active call PIO if there is one*/    if (pApp->PIO.CallActivePIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.CallActivePIO , TRUE) ;    }  }/****************************************************************************NAME		stateManagerEnterPoweringOffStateDESCRIPTION	single point of entry for the powering off state - enables power offRETURNS	void    */void stateManagerEnterPoweringOffState ( hsTaskData *pApp ){    SM_DEBUG(("SM : EnterPowerOff\n")) ;             /*Power Down*/    if ( stateManagerIsConnected() )    {            /*then we have an SLC active*/       headsetDisconnectSlc( pApp );    }                /*now just waiting for switch off */    stateManagerEnterLimboState ( pApp ) ;}/****************************************************************************NAME		stateManagerPowerOffDESCRIPTION	actually power down the deviceRETURNS	void    */void stateManagerPowerOff ( hsTaskData * pApp ) {    SM_DEBUG(("SM : Power Off\n--goodbye--\n")) ;            /*used as a power on indication if required*/    if (pApp->PIO.PowerOnPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.PowerOnPIO , FALSE) ;    }        /*now we have finished with the LEDS     LEDManagerClean( &pApp->theLEDTask ) ;*/             /*attempt to physically power down device - this will fail if the chg is plugged in*/    LEDManagerSetPowerPin   (  pApp , POWER_OFF ) ;        }/****************************************************************************NAME		stateManagerPowerOnDESCRIPTION	Power on the deviece by latching on the power regsRETURNS	void    */void stateManagerPowerOn( hsTaskData * pApp ) {    SM_DEBUG(("--hello--\nSM : PowerOn\n"));	/* Check for DUT mode enable */	if(!checkForDUTModeEntry(pApp))	{            /*cancel the event power on message if there was one*/    	MessageCancelAll ( &pApp->task , EventLimboTimeout ) ;                	LEDManagerSetPowerPin ( pApp , POWER_ON ) ;        	if (pApp->PIO.PowerOnPIOEnabled )    	{        	LedManagerSetPIO ( pApp->PIO.PowerOnPIO , TRUE) ;    	}    	stateManagerEnterConnectableState ( pApp, TRUE ) ;           /*if we want to reconnect after a power on then atempt to reconnect*/    	if (pApp->features.AutoReconnectPowerOn )    	{           	SM_DEBUG(("SM: Auto Reconnect\n")) ;        	MessageSend ( &pApp->task , EventEstablishSLC , 0 ) ;    	}	}}/****************************************************************************NAME		stateManagerIsConnectedDESCRIPTION    Helper method to see if we are connected or notRETURNS	bool    */bool stateManagerIsConnected ( void ){    bool lIsConnected = FALSE ;        switch (stateManagerGetState() )    {        case headsetPoweringOn:        case headsetConnectable:        case headsetConnDiscoverable:        case headsetTestMode:            lIsConnected = FALSE ;            break ;        case headsetConnected:        case headsetOutgoingCallEstablish:        case headsetIncomingCallEstablish :        case headsetActiveCall:        case headsetThreeWayCallWaiting:        case headsetThreeWayCallOnHold:        case headsetThreeWayMulticall:            lIsConnected = TRUE ;        break ;                default:        break ;    }    return lIsConnected ;}/****************************************************************************NAME		stateManagerEnterPoweringOnStateDESCRIPTION    method to provide a single point of entry to the limbo /poweringOn stateRETURNS	    */void stateManagerEnterLimboState ( hsTaskData * pApp ){    SM_DEBUG(("SM: Enter Limbo State[%d]\n" , pApp->AutoPowerOnTimeoutSecs));          /*in limbo, the internal regs must be latched on (smps and LDO)*/    LEDManagerSetPowerPin ( pApp , POWER_ON ) ;        /*make sure we are neither connectable or discoverable*/    headsetDisableDiscoverable ( pApp ) ;        headsetDisableConnectable  ( pApp ) ;          /*set a timeout so that we will turn off eventually anyway*/    MessageSendLater ( &pApp->task , EventLimboTimeout , 0 , D_SEC(pApp->AutoPowerOnTimeoutSecs) ) ;	/* Reset SLC settings */	slcReset();      stateManagerSetState ( pApp , headsetPoweringOn ) ;}void stateManagerUpdateLimboState ( hsTaskData * pApp ) {          /*then we are entering here as a result of a power off*/        switch (pApp->power->charger.state)        {            case disconnected :                    /*power has been removed and we are logically off so switch off*/                SM_DEBUG(("SM: LimboDiscon\n")) ;                stateManagerPowerOff ( pApp ) ;            break ;                    /*this means connected*/            case trickle_charge:            case fast_charge:			case charge_error:                SM_DEBUG(("SM: LimboConn\n")) ;                /*stay in this state until a charger event or a power on occurs*/            break ;                           default:            break ;        }  }/****************************************************************************NAME		stateManagerEnterTestModeStateDESCRIPTION    method to provide a single point of entry to the test mode stateRETURNS	    */void stateManagerEnterTestModeState ( hsTaskData * pApp ){    stateManagerSetState (pApp , headsetTestMode ) ;}static void stateManagerResetPIOs ( hsTaskData * pApp ){        /*disable the ring PIOs if enabled*/    if (pApp->PIO.IncomingRingPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.IncomingRingPIO , FALSE) ;    }    if (pApp->PIO.OutgoingRingPIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.OutgoingRingPIO , FALSE) ;    }            /*diaable the active call PIO if there is one*/    if (pApp->PIO.CallActivePIOEnabled )    {        LedManagerSetPIO ( pApp->PIO.CallActivePIO , FALSE) ;    }     }/****************************************************************************NAME		stateManagerEnterCallWaitingStateDESCRIPTION    method to provide a single point of entry to the 3 way call waiting stateRETURNS	    */void stateManagerEnterThreeWayCallWaitingState ( hsTaskData * pApp ) {    stateManagerSetState ( pApp , headsetThreeWayCallWaiting ) ;}void stateManagerEnterThreeWayCallOnHoldState ( hsTaskData * pApp ) {       stateManagerSetState ( pApp , headsetThreeWayCallOnHold ) ;}void stateManagerEnterThreeWayMulticallState ( hsTaskData * pApp ) {    stateManagerSetState ( pApp , headsetThreeWayMulticall ) ;}void stateManagerEnterIncomingCallOnHoldState ( hsTaskData * pApp){    stateManagerSetState ( pApp , headsetIncomingCallOnHold ) ;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -