CSR Bluetooth headset solution

Bluetooth headsets provide a safe and cordless way to send and receive calls and perform voice transmission. Especially when the user is inconvenient to hold the mobile phone, this method is particula

Bluetooth headsets provide a safe and cordless way to send and receive calls and perform voice transmission. Especially when the user is inconvenient to hold the mobile phone, this method is particularly convenient. The user of the Bluetooth headset can move freely within the range where the connection can be maintained, and can communicate with a variety of devices, and is widely used.


This article is based on the CSR Blue Core5Multi2MediaExternal (CSRBC52MME) embedded system, and carries on the design research and realization of the Bluetooth headset. CSR is the world’s leading supplier of Bluetooth technology. Its Blue Core5 embedded platform has a high-performance on-chip DSP. It is the only Bluetooth platform that can support third-party audio enhancement software. It can provide excellent sound quality and best-in-class information. The noise ratio reaches -90dB, and it is the industry leader in power consumption and radio design. It is currently the preferred development platform for headset products. Through the 2.4GHz short-distance radio frequency wireless communication technology in the ISM band, short-distance, low-cost wireless connections are used instead of cable connections. Bluetooth technology provides a unified connection for existing data networks and small peripheral device interfaces. The Bluetooth headset follows the Bluetooth headset specification and hands-free specification defined by the Bluetooth SIG organization, and realizes the wireless communication between the headset and the audio gateway.


蓝牙耳机研发设计

1. Introduction to the Bluetooth headset hardware platform

The system design is a mid-to-high-end Bluetooth headset product with single-channel dual-microphone noise reduction processing. It has a separate power switch, 1 multi-function button and 1 3-color LED light. It uses CSR's Blue Core5Multimedia chip with external FLASH memory. , Use the CSR Blue Lab headset software development system to support integrated speech synthesis, that is, text-to-speech (TTS) function, and speech recognition function. It is highly customizable and flexible in function, and there are different packaging options for selection , There is a dedicated DSP audio noise cancellation processor and a wealth of peripheral interfaces such as I2C, USB, UART, PCM/I2S/SPDIF and other interfaces. The block diagram of the Bluetooth headset hardware module is shown in Figure 1. The main features of the BC52MME platform:


图 1 蓝牙耳机硬件模块框图

(1) The 16b MCU has a speed of 100MHz and can support up to 32Mb external FLASH and 48kB internal RAM. (2) Ultra-low power consumption Kalimba DSP coprocessor, 64MIPS, can integrate third-party software, and provide high-quality audio processing such as noise cancellation. (3) Dual-channel 16bADC and DAC processing, support dual MIC and dual SPK, can achieve stereo audio. (4) It has rich interfaces such as UART, USB, SPI, PCM, I2S/SPDIF, which can realize connection and communication with external devices. (5) There are 2 dedicated LED interfaces, which can realize the flicker effect of fade in and fade out.


Second, the software platform of the Bluetooth headset

The Bluetooth headset software is designed and developed independently based on the Blue Core embedded development environment Blue Lab software platform provided by CSR. The Blue Lab software platform is a software development tool developed by CSR for its high-end chips. The content includes the platform's related development tools, Bluetooth protocol library and some source code. The design uses the software platform provided by CSR to customize and develop Bluetooth headset products. The Bluetooth headset software can be divided into two parts: the Bluetooth protocol system part and the Bluetooth headset specification application.


2.1 Bluetooth headset protocol stack


As shown in Figure 2, the Bluetooth protocol system can be divided into 4 layers, including the core protocol layer, the alternative cable protocol layer, the telephone control protocol layer, and the optional protocol layer. Each layer has some specific protocols:


图 2 蓝牙耳机协议体系结构

(1) Core protocols: baseband, link management protocol (LMP), logical link control and adaptation protocol (L2CAP), service discovery protocol (SDP); (2) alternative cable protocol: serial circuit emulation protocol (RFCOMM) ; (3) Telephone control protocol: binary telephone control specification (TCSBi2nary) and AT2 command (AT2Command); (4) optional protocol: point-to-point protocol (PPP), object exchange protocol (OBEX), etc. The host controller interface (HCI) provides a command interface to access the baseband controller, link controller, and hardware status and control registers. In Figure 2, the HCI layer is located below the L2CAP.


2.2 Bluetooth headset specifications


The application specifications in the Bluetooth headset software include headset profile protocol (HSP), hands-free profile protocol (HFP), advanced audio profile protocol (A2DP), audio and video remote control profile protocol (AVRCP), etc. At present, the headset profile protocol and the hands-free profile protocol are the content that must be supported in Bluetooth headsets; while high-end stereo Bluetooth headsets will add support for audio profile protocols and audio and video remote control profile protocols.


3. Bluetooth headset software design and implementation

3.1Blue Core task structure and message flow


In the Blue Core embedded development environment, on the one hand, you can configure the corresponding project compilation and development environment to facilitate software debugging; on the other hand, you can use the Bluetooth protocol library and part of the source code, that is, the Blue Core firmware and some Bluetooth protocol files, such as Shown in Figure 3. Based on the embedded software layered structure, you only need to focus on the development and implementation of the application profile. In Figure 3:


图 3 BlueCore 嵌入式软件分层架构

(1) Task: Each Task corresponds to 1 task, which corresponds to 1 basic block, and multiple blocks form an application. Each task completes the interface connection between the application and Blue Core firm ware and is responsible for the corresponding function. Each task has a message processing function and corresponding task state structure. All tasks are run in a single process, and multiple tasks are not allowed to be processed in parallel.


(2) Message: Message is to complete the information transfer between tasks. Its parameter form and meaning are as follows: Task t: Identify the destination address of the message, which is the pointer of the receiving task; Message Id id: The label of the message, when the task receives the message Used to identify and call the corresponding function function; Message pay load: The load of the message should include the required state data, so that the processing function can be processed correctly. The memory of the payload must be released after the message is delivered. The payload content is optional and can be set to Null. After the message is sent, all messages must enter the message FIFO queue for queuing and forwarding processing. The Message Loop function controls the main scheduling loop and processes the dispatch task messages; each dispatch checks the first message in the queue and dispatches it to the corresponding task. The call location is shown in the pseudo code section in Section 3.3.


3.2 MMI design and task design


The Bluetooth headset software is based on the Blue Core embedded software hierarchical architecture and message mechanism, and is designed and implemented according to the requirements of man machine interface (MMI). The design of the man-machine interface MMI of the Bluetooth headset is related to the positioning and complexity of the product. The Bluetooth headset designed in this article supports the headset profile protocol, hands-free profile protocol, realizes the function of voice call, and completes the compatibility test of the product. The design of MMI mainly includes four parts: button function, LED indication, voice prompt and Bluetooth status operation process. According to the design requirements of MMI, it is divided into: I/O input management task (io in Task), I/O output management task (io out Task), Bluetooth profile management task (prof Task), headset profile management task (hshf Task) , Audio driver management task (audio Task) and battery power management task (batt Task) 6 application tasks.


(1) I/O input management task: ①Initialize the task, apply for the task memory and initialize variables and the message processing function of the task; ②Initialize the configuration input I/O port, initialize according to the table of I/O input port properties; ③ Initialize I/O input events, initialize according to the event list; ④ Manage and send corresponding trigger events to different tasks.


(2) I/O output management tasks: ①Initialize the task, apply for the task memory and initialize variables and the message processing function of the task; ②Initialize the configuration output I/O port, initialize according to the I/O output attribute table; ③I/ O output management, including PIO and dedicated LED ports, is handled in the task processing function according to the LED flashing mode and timing requirements.


(3) Bluetooth profile management tasks: ①Initialize the task, apply for the task memory and initialize variables and the message processing function of the task; ②Initialize and manage the operating mode of the headset, initialize the Bluetooth protocol stack Connection Task; ③Manage the Bluetooth status, register, Inquire about the Bluetooth status transfer management during the process of pairing, authentication, reconnection and other Bluetooth connected devices; display the corresponding MMI according to the Bluetooth status.


(4) Headset profile management tasks: ①Initialize the task, apply for the task memory and initialize variables and the message processing function of the task; ②Initialize the Bluetooth profile protocol HSP and HFP; ③Manage the Bluetooth headset call processing, which is one of the important tasks of the Bluetooth headset .


(5) Audio driver management tasks: ①Initialize the task, apply for the task memory and initialize variables and the message processing function of the task; ②Adjust the gain of Speaker and Mic; ③Configure the SCO audio channel of the platform. (6) Battery power management task ①Initialize the task, apply for the task memory and initialize variables and the message processing function of the task; ②Charge power display and algorithm; ③Discharge power display and algorithm.


Different functions are distinguished by task, which is easy to understand, flexible and expandable. Task modules can be added or shielded by task module. Each task can realize the communication between each task through Blue Core's FIFO message mechanism, so as to realize the Bluetooth headset function, as shown in Figure 4.



图 4 蓝牙耳机功能

3.3 Bluetooth headset initialization and working process


The VREGENABLEH pin on the BC52MMExt chip can be compatible with a maximum voltage of 4.9V. When the pin is pulled up by a high-level pulse for 2s, the Firmware runs and locks the pull-up internally. After that, the pin can be used as an input pin. After the firmware startup is complete, the VM virtual machine is run, which provides a running environment for the Application Task.


After the headset is initialized, the headset first enters the pairing mode (pai2ringmodeorinquiryscanmode), AG (audio gateway) queries (inquiry mode) the current pairable devices, and the password authentication verification can be performed after the headset device is found. After the authentication is passed, the headset and AG can be Make a service connection (SLC establishment). After that, the Bluetooth headset enters the normal standby mode and can perform related operations such as incoming calls and dialing that comply with the HSP/HFP profile specification. The headset can pass the PTS (front line test system) function test and conform to the communication process of the Bluetooth headset HSP and HFP profile protocol.


Conclusion


Based on the CSR Bluetooth embedded platform design, the Bluetooth headset call function is realized. Through in-depth research on the Blue Core5Multimedia embedded system platform, the platform has the characteristics of high performance, high flexibility, and customization, which is suitable for the development of high-end headset products. The Bluetooth headset products on this platform will surely win the high-end customer market and have important application significance.