[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] if you use the infineon chipset with axis stack




Here are some vendor specific functions for the Infineon BlueMoon Chipset.
Simply add them to btconfig.h and hci_vendor.c and to your application. I
have only done some simple tests with btd.

Regards
  Christian


In btconfig.h add the define for INFINEON see below

/* This sets current HW */
#undef CONFIG_BLUETOOTH_NOINIT     
#define CONFIG_BLUETOOTH_INFINEON_BMI
#undef CONFIG_BLUETOOTH_CSR        
#undef CONFIG_BLUETOOTH_DIGIANSWER 
#undef CONFIG_BLUETOOTH_ERICSSON
#undef CONFIG_BLUETOOTH_GENERIC    
#undef CONFIG_BLUETOOTH_USBMODULE  /* Not implemented */

-----------------------------------

Add this to hci_vendor.c somewhere between the vendor specific defines

#elif defined(CONFIG_BLUETOOTH_INFINEON_BMI)
/***************************************************************************
**/
/***************** Functions for Infineon BlueMoon I chips
*******************/
/***************************************************************************
**/

s32
hci_set_bd_addr(u8 bd[6])
{
	D_ERR(__FUNCTION__" not supported.\n");
	return 0;
}


s32
hci_read_firmware_rev_info(void)
{
	D_CMD(__FUNCTION__"\n");
	c_pkt.type = CMD_PKT;
	c_pkt.opcode = hci_put_opcode(0x0005, 0x3f) ;
	c_pkt.len = 0;

	return send_cmd_block((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN +
HCI_HDR_LEN);
}

s32
hci_set_baudrate(u32 baudrate)
{
	u8 pkt[6];
	s32 tmp;

	D_CMD(__FUNCTION__"(%d baud)\n", baudrate);
	pkt[0] = CMD_PKT;
	pkt[1] = 0x06;
	pkt[2] = 0xfc;
	pkt[3] = 0x02;
	switch (baudrate) {
          case 9600:
            pkt[4]=3;
            pkt[5]=168;
            break;
          case 19200:
            pkt[4]=2;
            pkt[5]=168;
            break;
          case 38400:
            pkt[4]=1;
            pkt[5]=168;
            break;
          case 57600:
            pkt[4]=0;
            pkt[5]=225;
            break;
          case 115200:
            pkt[4]=0;
            pkt[5]=112;
            break;
          case 230400:
            pkt[4]=0;
            pkt[5]=55;
            break;
          case 460800:
            pkt[4]=0;
            pkt[5]=27;
            break;
          default:
            D_ERR(__FUNCTION__ ": Baudrate not supported\n");
	}   // end of switch
	tmp = send_cmd(pkt,6);

/* the chip answers with two command complete events, the first using the
old baudrate,
   the second using the new baudrate. The second event is send at least
0.125seconds after
   the first to let the host change its baudrate too. */

	start_cmd_timer();
	interruptible_sleep_on(&hci_wq);

	return tmp;
}

void
process_vendor_event(u8 *buf, u32 len, u32 event_code)
{
  D_REC(__FUNCTION__" Infineon specific event\n");
  if (len>=1)  {
    switch (buf[0])  {
      case 0x00:
        printk("Infineon event: Hardware Startup complete.\n");
        break;
      case 0x04:
        printk("Infineon event: invalid packet length.\n");
        break;
      case 0x05:
        printk("Infineon event: BD-Data invalid (check EEPROM).\n");
        break;
      case 0x07:
        printk("Infineon event: invalid packet type.\n");
        break;
      case 0x09:
        printk("Infineon event: invalid ACL_BC_PB_Flag.\n");
        break;
      case 0x0A:
        printk("Infineon event: invalid ACL_CNC_Handle.\n");
        break;
      case 0x0B:
        printk("Infineon event: invalid SCO_CNC_Handle.\n");
        break;
      case 0x0C:
        printk("Infineon event: low power mode start.\n");
        break;
      case 0x0D:
        printk("Infineon event: low power mode end.\n");
        break;

      default:
        D_ERR(__FUNCTION__" Infineon specific unknown event\n");
    }  /* end of switch */
  }  else  {
    D_ERR(__FUNCTION__" Infineon specific invalid event\n");
  }
}


void
process_vendor_return_param(u32 ocf, u8* r_val)
{
  static int second=0;
  switch (ocf) {
    case 0x0005:  /* read software version */
       D_CMD(__FUNCTION__" Infineon software version\n");
       if (r_val[0]!=0)  {
         D_ERR(__FUNCTION__" Infineon software version read failure\n");
       }  else  {
         printk("Infineon LM-FW version is: %x.%x%x\n",
                  r_val[2]&0x0F,r_val[1]>>4,r_val[1]&0x0F);
         printk("Infineon BB-FW version is: %02x%02x\n",r_val[4],r_val[3]);
      }
      release_cmd_timer();
      wake_up_interruptible(&hci_wq);
      break;

    case 0x0006:  /* set baudrate */
       D_CMD(__FUNCTION__" Infineon baudrate set\n");
       if ( (r_val[0]==0x00) && (second==0) )  {
         printk("Infineon baudrate changes after this message\n");
         second=1;
       }  else if ( (r_val[0]==0x00) && second)  {
         printk("Infineon baudrate has changed to new value\n");
         second=0;
       }  else  {
         D_ERR(__FUNCTION__" Infineon baudrate set failure %x\n",r_val[0]);
       }
       release_cmd_timer();
       wake_up_interruptible(&hci_wq);
       break;

    default:
      release_cmd_timer();
      D_ERR(__FUNCTION__" Manufacturer specific : Invalid reply (0x%x)\n",
ocf);
      wake_up_interruptible(&hci_wq);
    break;
  }  /* end of switch */
}


char* get_hw_name(void)
{
	return "Chipset: Infineon BlueMoon I";
}


-----------------------------------

I have made some simple tests with one application - btd. I have added the
following code there.

#elif defined(CONFIG_BLUETOOTH_INFINEON_BMI)
/*********************************************************************/
/*********************************************************************/

/* Set the phys device to something, e.g. 115200 */ 
void init_phys(int fd)
{
  fd_setup(fd, 115200, USE_FLOW_CTRL);
}

void
init_hw(int spd)
{
#ifndef BTD_USERSTACK
  unsigned int wrscan = (PAGE_SCAN_ENABLE | INQUIRY_SCAN_ENABLE);
  unsigned char evfilter[3];
  
  sleep(1);
  printf("Setting write_scan_enable in Infineon chip!\n");
  if (ioctl(bt_cfd, HCIWRITESCANENABLE, &wrscan) < 0)
  { 
    perror("HCIWRITESCANENABLE");
    exit(1);
  }

  sleep(1); // wait for HW... 
  printf("Setting baudrate in Infineon module!\n");  
  if (ioctl(bt_cfd, HCISETBAUDRATE, &spd) < 0)
  {
    perror("HCISETBAUDRATE");
    exit(1);
  }
  printf("read Firmware version number\n");

#else  
  printf("Setting write_scan_enable in Infineon chip!\n");
  hci_write_scan_enable(PAGE_SCAN_ENABLE|INQUIRY_SCAN_ENABLE);		
  sleep(1); /* wait for HW... */
  
  tcflush(phys_fd, TCIOFLUSH);

  printf("Setting baudrate in Infineon chip!\n");
  hci_set_baudrate(spd);  
#endif

}


-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com