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

📄 headset_init.c

📁 bc5_stereo:bluetooth stereo Headset CODE 支持A2DP HSP 和 HSP 。可作为车载免提。BlueLab 2007环境下编译
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2007

FILE NAME
    headset_init.c

DESCRIPTION
    
*/

#include "headset_configmanager.h"
#include "headset_config.h"
#include "headset_init.h"
#include "headset_LEDmanager.h"
#include "headset_statemanager.h"
#include "headset_tones.h"
#include "headset_states.h"
#include "headset_volume.h"

#include "headset_debug.h"

#include <a2dp.h>
#include <avrcp.h>
#include <codec.h>
#include <connection.h>
#include <hfp.h>
#include <stdlib.h>
#include <memory.h>


/****************************************************************************
  FUNCTIONS
*/

/*************************************************************************
NAME    
    headsetInitComplete
    
DESCRIPTION
    This function is called when all the libraries have been initialised,
    and the config has been loaded. The headset is now ready to be used.    
*/
static void headsetInitComplete( hsTaskData *pApp )
{
    /* Enter the limbo state as we may be ON due to a charger being plugged in */
    stateManagerEnterLimboState ( pApp );  

    /* Initialise the A2DP state */
    stateManagerEnterA2dpConnectableState ( pApp, TRUE );
    
    /* Set the class of device to indicate this is a headset */
    ConnectionWriteClassOfDevice(AUDIO_MAJOR_SERV_CLASS | AV_COD_RENDER | AV_MAJOR_DEVICE_CLASS | AV_MINOR_HEADSET);
    
    /* Disable SDP security  */
    ConnectionSmSetSdpSecurityIn(TRUE);
    
	PROFILE_TIME(("InitComplete"))
	PROFILE_MEMORY(("InitComplete"))
}


/**************************************************************************/
void InitHeadsetData ( hsTaskData *pApp ) 
{      
	memset(&pApp->a2dp, 0, sizeof(a2dpData));
	memset(&pApp->avrcp, 0, sizeof(avrcpData));
	
    pApp->hfp = NULL;
    pApp->hsp = NULL;
    
    pApp->profile_connected = hfp_no_profile;
    
	pApp->slc_sink = 0;
    pApp->sco_sink = 0;
    
    pApp->voice_recognition_enabled = FALSE;
	
	pApp->a2dpSourceSuspended = FALSE;
	pApp->dsp_process = dsp_process_none;
}


/**************************************************************************/
void InitUserFeatures ( hsTaskData *pApp ) 
{
    /* Initialise the Tones */
    TonesInit( pApp ) ;
    
    /* Initialise the Volume */    
    VolumeInit( pApp ) ;
    
    /* Initialise the LED Manager */
	LEDManagerInit( &pApp->theLEDTask ) ;
    
	/* Initialise the Button Manager */
    buttonManagerInit( &pApp->theButtonTask , &pApp->task);
    
    /* Initialise the Power Manager */
	pApp->power = powerManagerInit( );
    
    /* Once system Managers are initialised, load up the configuration */
    configManagerInit( pApp );
       
    /* The headset initialisation is almost complete. */
    headsetInitComplete( pApp );
	
	/* Enable LEDs */
	LedManagerEnableLEDS( &pApp->theLEDTask ) ;
}


/*****************************************************************************/
void InitCodec(void)
{
    CodecInitCsrInternal (getAppTask()) ;
}


/*****************************************************************************/
void InitConnection(void)
{
    ConnectionInit (getAppTask()) ;
}


/*****************************************************************************/
void InitHfp(hsTaskData *pApp)
{
    hfp_init_params init;
    
    configManagerSetupSupportedFeatures(pApp);
    
    /* Initialise an HFP profile instance */
    init.supported_profile = hfp_handsfree_15_profile;
    init.supported_features = pApp->local_hfp_features;
    init.size_service_record = 0;
    init.service_record = 0;
    init.priority = 255;

    HfpInit(&pApp->task, &init);

    /* Initialise an HSP profile instance */
    init.supported_profile = hfp_headset_profile;
    init.supported_features = 0;
    init.size_service_record = 0;
    init.service_record = 0;
    init.priority = 255;
    
    HfpInit(&pApp->task, &init);
}


/*****************************************************************************/
void InitA2dp(void)
{
    hsTaskData* app = (hsTaskData*)getAppTask();
    
    a2dp_init_params a2dp_config;
    a2dp_config.role = a2dp_sink;
    a2dp_config.priority = 512;
    a2dp_config.size_service_record = 0;
    a2dp_config.service_record = 0;
    
    A2dpInit(&app->task, &a2dp_config);
}


/*****************************************************************************/
void InitAvrcp(void)
{
    avrcp_init_params config;
    hsTaskData* app = (hsTaskData*)getAppTask();
    
    config.device_type = avrcp_controller;
    config.priority = 50;

    stateManagerSetAvrcpState(app, avrcpInitialising);
    
	/* Go ahead and Initialise the AVRCP library */
	AvrcpInit(&app->task, &config);
}

⌨️ 快捷键说明

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