From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 23 Nov 2006 22:36:30 +0100 From: Michel Leconte To: bluez-users@lists.sourceforge.net Message-id: <002b01c70f47$70ba4a20$27b44856@claudia> MIME-version: 1.0 Subject: [Bluez-users] Change the uart baud rate for Semtech-Xemics kit Reply-To: BlueZ users List-Id: BlueZ users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0568173789==" Sender: bluez-users-bounces@lists.sourceforge.net Errors-To: bluez-users-bounces@lists.sourceforge.net This is a multi-part message in MIME format. --===============0568173789== Content-type: multipart/alternative; boundary="Boundary_(ID_KhJRIqIyIhoAGAptj0iSxg)" This is a multi-part message in MIME format. --Boundary_(ID_KhJRIqIyIhoAGAptj0iSxg) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT 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 > > > > > > /* > * 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; > } > > nanosleep(&tm, NULL); > > > > > return 0; > } > > > > 857a954,957 > /* Semtech Xemics development kit based on the SX1441 (bluetooth chip v1.2) */ > { "xemics", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL , xemics }, > > --Boundary_(ID_KhJRIqIyIhoAGAptj0iSxg) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: 7BIT
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
>
>
>
>
>
> /*
>  * 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;
>  }
>
>  nanosleep(&tm, NULL);
>
>
>
>  
>  return 0;
> }
>
>
>
>
857a954,957
>  /* Semtech Xemics development kit  based on the SX1441 (bluetooth chip v1.2) */
>  { "xemics",      0x0000, 0x0000, HCI_UART_H4,   115200, 115200, FLOW_CTL , xemics   },
>  
>  
--Boundary_(ID_KhJRIqIyIhoAGAptj0iSxg)-- --===============0568173789== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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 --===============0568173789== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bluez-users mailing list Bluez-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-users --===============0568173789==--