| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "hm_chipset.h"
- #include "hm_hci_transport_h4.h"
- #include "hm_config.h"
- static uint8_t download_commands[] = {
- /* 0x2819: Read build ID */
- // 0x00, 0xFC, 0x17, 0xc2, 0x00, 0x00, 0x09, 0x00, 0x01, 0x00, 0x19, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- // 0x01fe: Set ANA_Freq to 26MHz
- 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0x03, 0x70, 0x00, 0x00, 0xfe, 0x01, 0x01, 0x00, 0x08, 0x00, 0x90, 0x65,
- // 0x00f2: Set HCI_NOP_DISABLE
- 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0x03, 0x70, 0x00, 0x00, 0xf2, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00,
- // 0x01bf: Enable RTS/CTS for BCSP (0806 -> 080e)
- 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0x03, 0x70, 0x00, 0x00, 0xbf, 0x01, 0x01, 0x00, 0x08, 0x00, 0x0e, 0x08,
- // 0x01ea: Set UART baudrate to 115200
- 0x00, 0xFC, 0x15, 0xc2, 0x02, 0x00, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x70, 0x00, 0x00, 0xea, 0x01, 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0xc2,
- // 0x0001: Set Bluetooth address
- 0x00, 0xFC, 0x19, 0xc2, 0x02, 0x00, 0x0A, 0x00, 0x03, 0x00, 0x03, 0x70, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0xf3, 0x00, 0xf5, 0xf4, 0xf2, 0x00, 0xf2, 0xf1,
- };
- static uint8_t warm_reset[] = {
- // WarmReset Command
- 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x03, 0x0e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- };
- int chipset_csr_init(void)
- {
- uint8_t *p = download_commands;
- uint8_t *end = download_commands + ARRAY_SIZE(download_commands);
- uint16_t len = 0;
- uint8_t recv[30];
- chip_send_hci_reset_cmd_until_ack();
- rt_kprintf("SCR8311 start init\n");
- while (p < end) {
- len = 3 + p[2];
- chip_hci_cmd_send(p, len);
- chip_hci_event_read(recv, ARRAY_SIZE(recv), RT_WAITING_FOREVER);
- if (recv[0] != 0xFF) // Vendor Event
- return HM_CHIPSET_INIT_ERROR;
-
- p += len;
- }
- /* warm reset */
- rt_kprintf("CSR8311 start warm reset\n");
- chip_hci_cmd_send(warm_reset, ARRAY_SIZE(warm_reset));
-
- /* Wait 10 ms for warm reset complete. */
- rt_thread_mdelay(10);
- /* Make sure chipset is normal now. */
- chip_send_hci_reset_cmd_until_ack();
- rt_kprintf("CSR8311 init success\n");
- return HM_SUCCESS;
- }
- static hm_chipset_t chipset_csr = {
- .name = "csr",
- .init = chipset_csr_init,
- };
- hm_chipset_t* hm_chipset_get_instance(void)
- {
- return &chipset_csr;
- }
|