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

📄 headset_private.h

📁 CSR蓝牙芯片 无线蓝牙耳机的语音网关程序 蓝牙耳机程序已经上传
💻 H
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004

FILE NAME
    headset_private.h
    
DESCRIPTION
    
*/

#ifndef _HEADSET_PRIVATE_H_
#define _HEADSET_PRIVATE_H_

#include "headset_buttons.h"

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


#ifdef DEBUG_PRINT_ENABLED
#include <stdio.h>
#define DEBUG(x) {printf x;}
#else
#define DEBUG(x) 
#endif


/* 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_MINOR_MICROPHONE     0x000010
#define AV_MINOR_SPEAKER        0x000014
#define AV_MINOR_HEADPHONES     0x000018
#define AV_MINOR_PORTABLE       0x00001c
#define AV_MINOR_HIFI           0x000028
#define AV_COD_RENDER           0x040000
#define AV_COD_CAPTURE          0x080000

/* PIO definititions */
#define LED                 (1<<1)
#define LED_CHARGE			(1<<0)
#define POWER_HOLD          (1<<9)

/* LED defines */
#define LED_NONE            0
#define LED_PAIRING         1
#define LED_CONNECTABLE     (1<<1)
#define LED_CONNECTED       (1<<2)
#define LED_CALL_ACTIVE     (1<<3)
#define LED_STREAMING       (1<<4)

/* PS keys used by the app */
#define LAST_USED_AG        (0)
#define LAST_USED_AV_SOURCE (1)
#define VOLUME_LEVEL        (2)

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

/* Number of bits used for each stored volume */
#define VOLUME_SHIFT        8

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

typedef uint16 ledState;

/* Local App messages */
enum
{
    APP_HEADSET_INIT_CFM = HEADSET_MSG_BASE,
    APP_MUSIC_RESTART_IND,
    APP_PAIR_MODE_END_IND,
    APP_LED_UPDATE_IND,
    APP_POWER_OFF_IND,
    APP_DISCONNECT_HFP_SLC_IND,
    APP_HFP_SLC_TIMEOUT_IND,
    APP_HFP_SLC_REQ
};

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

typedef enum
{
    avHeadsetA2dpInitialising,
    avHeadsetA2dpReady,
    avHeadsetA2dpInitiating,
    avHeadsetA2dpConnected,
    avHeadsetA2dpStreaming,
    avHeadsetA2dpDisconnecting
} avHeadsetA2dpState;

typedef enum
{
    avHeadsetAvrcpInitialising,
    avHeadsetAvrcpReady,
    avHeadsetAvrcpConnecting,
    avHeadsetAvrcpConnected,
    avHeadsetAvrcpDisconnecting
} avHeadsetAvrcpState;

typedef enum
{
    none_active,
    hfp_active,
    av_active
} activeProfileState;

typedef enum
{
    default_ring,
    error_tone
} toneType;

typedef enum
{
    pcm_none,
    pcm_ringtone,
    pcm_av,
    pcm_sco
} pcmAudioState;

typedef struct
{
    TaskData            task;
    Task				codec_task;

    /* Common states */
    uint16              speaker_volume;
    ledState            led_state;
    uint16              page_scan_enabled;
    uint16              inquiry_scan_enabled;
    uint16              pairing_enabled;
    activeProfileState  active_profile;
    pcmAudioState       pcm_audio_state;
    bool                powering_down;
    PioState            pio_state;
    
    /* AV states */
    A2DP*               a2dp;
    AVRCP*              avrcp;
    avHeadsetA2dpState  a2dp_state;
    avHeadsetAvrcpState avrcp_state;
    Sink                media_sink;
    bdaddr              remote_bdaddr;
    a2dp_channel_mode	channel_mode;
	vm_pcm_rate			rate;
    Sink                avrcp_sink;
    bool                avrcp_pending;
    TaskData            controls_task;
    uint8               codec_caps;
    bool                av_stream_stopped;
    bool                sent_suspend;
    
    /* HFP states */
    headsetState        hfp_state;
    uint16              in_band_ring_enabled;
    uint16              voice_recognition_enabled;
    uint16              button_action_pending_lock;
    Sink                sco_sink;
    uint16              supp_features_0;
    hfp_profile         profile_connected;
    HFP                 *hfp;
    HFP                 *hsp;
    
} 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);


/*************************************************************************
NAME    
    setAvHeadsetA2dpState
    
DESCRIPTION
    Set the AV Headset A2DP State to the specified state

RETURNS
    
*/
void avHeadsetSetA2dpState(const avHeadsetA2dpState state);


/*************************************************************************
NAME    
    avSetHeadsetAvrcpState
    
DESCRIPTION
    Set the AV Headset AVRCP State to the specified state

RETURNS
    
*/
void avHeadsetSetAvrcpState(const avHeadsetAvrcpState state);


#endif /* _HEADSET_PRIVATE_H_ */

⌨️ 快捷键说明

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