Skip to contentSkip to conversation

Change the uart baud rate for Semtech-Xemics kit

Bluez-users Michel Leconte 1 participant 1 message Nov 23, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi all,

I write a small function to modify the uart baud rate at the setup of the link between the stack bluez and the chip bluetooth. This function is highly inspired from functions in the hciattach.c file thanks to marcel. This function is specific to the development kit of Semtech-Xemics based on the SX1441 (bluetooth v1.2).

I don't know if that can be usefull but I send you the output of the "diff" command between the original hciattach.c and thus modified.

regards.

Michel

------------------ output of the diff command --------------------------------

804a805,900

Quoted 85 lines

/*
* Specific initialization for semtech-xemics
* development kit based on the SX1441 Bluetooth v1.2 *
*/
static int xemics(int fd, struct uart_t *u, struct termios *ti) {
struct timespec tm = {0, 50000};
char cmd[13];

cmd[0] = HCI_COMMAND_PKT;
cmd[1] = 0x0b; // OCF = Hci_Cmd_xemics_Set_Uart_Baud_Rate
cmd[2] = 0xfc; // OGF = Vendor specific
cmd[3] = 0x09;
cmd[4] = 0x08;
cmd[5] = 0x02;
cmd[6] = 0x00;

/* Xemics set baud rate command */
/* BaudRate cmd[7]---cmd[10]
/* 115200 = 0x01C200
230400 = 0x038400
460800 = 0x070800
921600 = 0x0E1000

Important : cmd[7] = LSB first */

switch (u->speed) {

case 115200:
cmd[7] = 0x00 ;
cmd[8] = 0xC2;
cmd[9] = 0x01;
cmd[10] = 0x00 ;

break;
case 230400:
cmd[7] = 0x00 ;
cmd[8] = 0x84;
cmd[9] = 0x03;
cmd[10] = 0x00 ;
break;
case 460800:
cmd[7] = 0x00;
cmd[8] = 0x08;
cmd[9] = 0x07;
cmd[10] = 0x00;
break;
case 921600:
cmd[7] = 0x00;
cmd[8] = 0x10;
cmd[9] = 0x0E;
cmd[10] = 0x00 ;
break;
default:
cmd[7] = 0x00 ;
cmd[8] = 0xC2;
cmd[9] = 0x01;
cmd[10] = 0x00 ;

u->speed = 115200;
break;
}

cmd[11] = 0xb1;
cmd[12] = 0x03;

/* Send uart rate */
if (write(fd, cmd, 13) != 13) {
perror("Can't write reset cmd.");
return -1;
}

Quoted 11 lines

nanosleep(&tm, NULL);

return 0;
}

857a954,957

Quoted 4 lines

/* Semtech Xemics development kit based on the SX1441 (bluetooth chip v1.2) */
{ "xemics", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL , xemics },

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users