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

📄 headset_private.h

📁 针对bluelab3.42的handsfree车载蓝牙的参考
💻 H
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.4.2-release

FILE NAME
    headset_private.h
    
DESCRIPTION
    
*/

#ifndef _HEADSET_PRIVATE_H_
#define _HEADSET_PRIVATE_H_

#include "headset_battery.h"
#include "headset_debug.h"
#include "stereo_headset_buttons.h"

#include <a2dp.h>
#include <avrcp.h>
#include <hfp.h>
#include <connection.h>
#include <message.h>
#include <app/message/system_message.h>


/* Local application messages base value */ 
#define HEADSET_MSG_BASE    (0x0)

/* Class of device defines */
#define AUDIO_MAJOR_SERV_CLASS  0x200000
#define AV_MAJOR_DEVICE_CLASS   0x000400
#define AV_MINOR_HEADSET        0x000004
#define AV_COD_RENDER           0x040000


/* PIO definititions */
#ifdef DEV_1307

#define LED_RED             (1<<0)
#define LED_BLUE            (1<<1)
#define MFB_BUTTON          (1<<6)
#define AUDIO_AMP_LINE      (1<<11)

#else

#define LED_RED             (1<<2)
#define LED_BLUE            (1<<11)
#define MFB_BUTTON          (1<<3)
#define AUDIO_AMP_LINE      (1<<4)

#endif


#define PIO_AIO1            (1<<13)
#define PIO_AIO3            (1<<15)

#define POWER_HOLD          (1<<9)


/* LED defines */
#define LED_NONE            0
#define LED_PAIRING         1
#define LED_CONNECTED       (1<<1)
#define LED_CHARGING        (1<<2)
#define LED_BATTERY_LOW     (1<<3)
#define LED_INIT            (1<<4)
#define LED_POWER_DOWN      (1<<5)
#define LED_OFF             (1<<6)
#define LED_DEL_PAIRED_LIST (1<<7) 
#define LED_BATTERY_FULL    (1<<8)

/* PS keys used by the app */
#define LAST_USED_AG        (0)
#define LAST_USED_AV_SOURCE (1)
#define VOLUME_LEVEL        (2)
#define AUTO_RECONNECT      (3)
#define HEADSET_SECURITY    (4)
#define RING_TONE_SELECT    (5)
#define AUTO_SWITCH_OFF_ENABLED    (6)
#define AUTO_SWITCH_OFF_TIMEOUT    (7)
#define LAST_PAIRED_DEVICE (8)
#define MP3_ENABLED (9)
#define LAST_USED_AV_SOURCE_SEP (12)
/* CVC PS Keys used */
#define PS_PARAM_BASE		(10)
#define	PS_SEC_KEY			(28)

/* Time to wait after audio has ended before switching off the audio amp */
#define AMP_IDLE_TIMER  6000

/* How long to wait before restarting audio. Used to avoid conficts in signalling */
#define MUSIC_RESTART_DELAY 500

/* If SLC connection not created after this has expired then abort the connect attempt. */
#define SLC_CONNECT_TIMEOUT     (10000)

/* Remain in pairing mode only for this length of time */
#define PAIRING_TIMEOUT         (60000)


typedef uint16 ledState;

/* Local App messages */
enum
{
    APP_AMP_IDLE_IND = HEADSET_MSG_BASE,
    APP_AUTO_SWITCH_OFF_IND,
    APP_A2DP_CLOSE_TIMER,
    APP_BATTERY_DEAD_IND,
    APP_BATTERY_FULL_IND,
    APP_BATTERY_LOW_END_IND,
    APP_BATTERY_LOW_IND,
    APP_CHARGER_CONNECTED_IND,
    APP_CHARGER_DISCONNECTED_IND,
    APP_DISCONNECT_HFP_SLC_IND,
    APP_HEADSET_INIT_CFM,
    APP_HFP_SLC_REQ,
    APP_HFP_SLC_TIMEOUT_IND,
    APP_INIT_END,
    APP_INIT_LED_UPDATE_IND,
    APP_LED_OFF_PANIC,
    APP_LED_UPDATE_IND,
    APP_MUSIC_RESTART_IND,
    APP_MUTE_REMINDER,
    APP_PAIR_MODE_END_IND,
    APP_PAIR_RESET_LED_UPDATE_IND,
    APP_POWER_CHARGING_OFF,
    APP_POWER_DOWN_LED_UPDATE_IND,    
    APP_POWER_OFF,
    APP_POWER_OFF_IND,
	APP_RED_LED_UPDATE_IND,
    APP_RING_TIMEOUT_IND,
	APP_POWER_ON_EVENT_SEEN,
	APP_PREVENT_POWER_ON,
    APP_TONE_TO_PLAY_IND,
    APP_UNMUTE_MIC,
    APP_VOICE_DIAL,
    APP_PLAY_PAUSE_SHORT
};

typedef struct
{
	uint8			count;
	MessageId		id;
} APP_ON_EVENT_LED_UPDATE_IND_T;

typedef struct
{
    uint16 id;
} APP_TONE_TO_PLAY_IND_T;

typedef struct
{
    uint16 voice_recog_enabled;
} APP_VOICE_DIAL_T;

typedef enum
{
    headsetInitialising,
    headsetReady,
    headsetConnecting,
    headsetConnected,
    headsetOutgoingCallEstablish,
    headsetIncomingCallEstablish,
    headsetActiveCall
} headsetHfpState;

typedef enum
{
    avHeadsetA2dpInitialising,
    avHeadsetA2dpReady,
    avHeadsetA2dpInitiating,
    avHeadsetA2dpConnected,
    avHeadsetA2dpStreaming
} headsetA2dpState;

typedef enum
{
    avHeadsetAvrcpInitialising,
    avHeadsetAvrcpReady,
    avHeadsetAvrcpConnecting,
    avHeadsetAvrcpConnected
} headsetAvrcpState;

typedef enum
{
    none_active,
    hfp_active,
    av_active
} activeProfileState;

typedef enum
{
    tone_type_power_on = 0,
    tone_type_power_off,
    tone_type_error,
    tone_type_button_press,
    tone_type_battery_low,
    tone_type_vol_limit,
    tone_type_connect,
	tone_type_mute_remind,
    tone_type_pairing,
	tone_type_call_end,
    /* Add new items here */
    tone_type_ring
} toneType;

typedef enum
{
    pcm_none,
    pcm_av,
    pcm_sco,
    pcm_ring,
    pcm_ringing,
    pcm_tone,
    pcm_tone_to_av,
    pcm_tone_to_sco
} pcmAudioState;

typedef enum
{
    power_state_off,
    power_state_off_charging,
    power_state_on,
    power_state_on_charging,
    power_state_powering_down
} power_state;

typedef struct
{
    unsigned auto_switch_off_timeout:16;
    unsigned dummy:10;
    unsigned auto_switch_off_enabled:1;
    unsigned auto_reconnect:1;
    unsigned ring_tone_select:4;
} features_type;

typedef struct
{
    unsigned hfp_volume:8;
    unsigned av_volume:8;
} volume_type;

typedef struct
{
    unsigned voice_recognition_enabled:8;
    unsigned old_voice_recognition_enabled:8;
} voice_type;

typedef struct
{
    uint16 amp_enabled;
    uint16 amp_powering_on;
} amp_type;

typedef struct
{
    TaskData            task;
    uint16              cvc_output_codec_gain;
    uint16              cvc_input_codec_gain;
    uint16              hfkdspready;
} cvcData;

typedef struct
{
    TaskData            task;
    Task				codec_task;
    TaskData            theSoundTask;

    /* Common states */
    volume_type         speaker_volume;
    ledState            led_state;
    uint16              pairing_enabled;
    activeProfileState  active_profile;
    pcmAudioState       pcm_audio_state;
    power_state         headset_power_state;
    PioState            pio_state;
    power_source_type   power_source;
    amp_type            amp;
    features_type       features;
	bool                headset_logically_on;
    
    /* AV states */
    A2DP*               a2dp;
    AVRCP*              avrcp;
    headsetA2dpState    a2dp_state;
    headsetAvrcpState   avrcp_state;
    Sink                media_sink;
    a2dp_channel_mode	channel_mode;
	uint32  			rate;
    bool                avrcp_pending;
    TaskData            controls_task;
    bool                av_stream_stopped;
    bool                sent_suspend;
    uint16              headset_connecting_av;
    
    /* HFP states */
    headsetHfpState     hfp_state;
    uint16              in_band_ring_enabled;
    voice_type          voice;
    uint16              headset_connecting_hfp;
    Sink                sco_sink;
    uint16              supp_features_0;
    hfp_profile         profile_connected;
    HFP                 *hfp;
    HFP                 *hsp;    
	bool                mic_mute_on;
	uint32              mic_volume;
    
    /* CVC states */
    cvcData             cvc;
    
} headsetTaskData;


/****************************************************************************
NAME    
    avGetAppTask
    
DESCRIPTION
  Returns the AV headset application main task.

RETURNS
    Task
*/
Task getAppTask(void);

/****************************************************************************
NAME    
    avGetApp
    
DESCRIPTION
  Returns the AV headset application state

RETURNS
    headsetTaskData
*/
headsetTaskData *getApp(void);


#endif /* _HEADSET_PRIVATE_H_ */

⌨️ 快捷键说明

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