CSR8811 Port for POSIX Systems with HCI H4 bus

Figure: CSR8811 module over an USB-TTL_UART converter which had a 3.3v power supply
Configuration
Most Bluetooth Bluetooth Controllers connected via UART/H4 require some special configuration, e.g. to set the UART baud rate, and/or require firmware patches during startup. In this port, we’ve tried to do most of these automatically based on information gathered from the Bluetooth Controller.
HW connection:
Connection: Since CSR8811 is a 3.3V device,make sure the power supply for CSR8811 is 3.3V, not 5V. Then my demo connection from CSR module to USB-TTL_UART board is:
- VCC to VCC, with jumper on USB-TTL_UART board set to 3.3v power.
- GND to GND
- TxD to RxD
- RxD to TXD
- /CTS to RTS#
- /RTS to CTS#
- /RST to DSR#

main.c fix
Test on macOS/MacbookPro,with USB to TTL UART board,named “/dev/cu.usbserial-A50285BI”.
we should have:
// pick serial port // my USB-TTL_UART board on macBook config.device_name = "/dev/cu.usbserial-A50285BI";
I had tested that my CSR module can speedup to 3000000bps on H4 interface, while the default speed is 115200 bps. Then we can change into this hi-speed baud rate for audio application.
On main.c, line 134:
static void use_fast_uart(void){
printf("Using 3000000 baud.\n"); //cyue add
config.baudrate_main = 3000000;
return;
Since my CSR module on-hand had a 3rd. party demo only firmware, with 5 minute shutdown interval after each reset.
platform/posix/bt_uart_block_posix.c: line 289 fix
Since I had force the /DSR pin of TTL_UART to reset the CSR module, the CSR module can boot-up correctly.
//cyue: Reset Uart BT chip use DTR pin. We had UART fd opened...
static void bt_uart_reset(int fd){
/*--------------------- Controll the DTR pin using ioctl() system call ---------------------*/
// cyue add: use DTR as reset pin
int DTR_flag;
DTR_flag = TIOCM_DTR; // Modem Constant for DTR PIN
#define clrDTRI() ioctl(fd,TIOCMBIS,&DTR_flag)
#define setDTRI() ioctl(fd,TIOCMBIC,&DTR_flag)
clrDTRI(); usleep(25000);
setDTRI(); usleep(50000);
}
and reset the module when device open(line 300):
static int bt_uart_posix_open(void){
const char * device_name = uart_config->device_name;
const int flowcontrol = uart_config->flowcontrol;
const uint32_t baudrate = uart_config->baudrate;
struct termios toptions;
int flags = O_RDWR | O_NOCTTY | O_NONBLOCK;
int fd = open(device_name, flags);
if (fd == -1) {
log_error("Unable to open port %s", device_name);
return -1;
}
bt_uart_reset(fd);//cyue add reset here...
bt_uart_reset(fd);//cyue add reset here...
。
。
。
make
make -j
RUN demo application(s)
choose any built application, for example, a2dp_sink_demo:
./a2dp_sink_demo
Packet Log: /tmp/hci_dump.pklg
H4 device: /dev/cu.usbserial-A50285BI
Audio playback supported.
Starting tinyBT2 ...
Local version information:
- HCI Version 0x0007
- HCI Revision 0x2918
- LMP Version 0x0007
- LMP Subversion 0x2918
- Manufacturer 0x000a
Cambridge Silicon Radio - CSR chipset, Build ID: 10520.
Using 3000000 baud.
Local name: CSR - bc7
tinyBT2 up and running at 11:22:33:44:55:66
Meet application failure?
if meet application failure, we should kill the running process before run it again. For the a2dp_sink_demo application:
pkill a2dp_sink_demo
./a2dp_sink_demo