mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-26 00:40:38 +00:00
bcm: limit uart to 3 mbps
This commit is contained in:
parent
9227d9a864
commit
fab26ab36e
42
src/hci.c
42
src/hci.c
@ -903,8 +903,13 @@ static void hci_initializing_run(void){
|
|||||||
hci_stack->substate = HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT;
|
hci_stack->substate = HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT;
|
||||||
hci_send_cmd(&hci_reset);
|
hci_send_cmd(&hci_reset);
|
||||||
break;
|
break;
|
||||||
case HCI_INIT_SEND_BAUD_CHANGE:
|
case HCI_INIT_SEND_BAUD_CHANGE: {
|
||||||
hci_stack->control->baudrate_cmd(hci_stack->config, ((hci_uart_config_t *)hci_stack->config)->baudrate_main, hci_stack->hci_packet_buffer);
|
uint32_t baud_rate = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||||
|
// Limit baud rate for Broadcom chipsets to 3 mbps
|
||||||
|
if (hci_stack->manufacturer == 0x000f && baud_rate > 3000000){
|
||||||
|
baud_rate = 3000000;
|
||||||
|
}
|
||||||
|
hci_stack->control->baudrate_cmd(hci_stack->config, baud_rate, hci_stack->hci_packet_buffer);
|
||||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||||
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE;
|
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE;
|
||||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||||
@ -915,12 +920,19 @@ static void hci_initializing_run(void){
|
|||||||
run_loop_add_timer(&hci_stack->timeout);
|
run_loop_add_timer(&hci_stack->timeout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HCI_INIT_SEND_BAUD_CHANGE_BCM:
|
}
|
||||||
hci_stack->control->baudrate_cmd(hci_stack->config, ((hci_uart_config_t *)hci_stack->config)->baudrate_main, hci_stack->hci_packet_buffer);
|
case HCI_INIT_SEND_BAUD_CHANGE_BCM: {
|
||||||
|
uint32_t baud_rate = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||||
|
// Limit baud rate for Broadcom chipsets to 3 mbps
|
||||||
|
if (hci_stack->manufacturer == 0x000f && baud_rate > 3000000){
|
||||||
|
baud_rate = 3000000;
|
||||||
|
}
|
||||||
|
hci_stack->control->baudrate_cmd(hci_stack->config, baud_rate, hci_stack->hci_packet_buffer);
|
||||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||||
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE_BCM;
|
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE_BCM;
|
||||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case HCI_INIT_CUSTOM_INIT:
|
case HCI_INIT_CUSTOM_INIT:
|
||||||
log_info("Custom init");
|
log_info("Custom init");
|
||||||
// Custom initialization
|
// Custom initialization
|
||||||
@ -1119,11 +1131,15 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
return;
|
return;
|
||||||
case HCI_INIT_W4_SEND_BAUD_CHANGE:
|
case HCI_INIT_W4_SEND_BAUD_CHANGE:
|
||||||
// for STLC2500D, baud rate change already happened.
|
// for STLC2500D, baud rate change already happened.
|
||||||
// for CC256x, baud rate gets changed now
|
// for others, baud rate gets changed now
|
||||||
if (hci_stack->manufacturer != 0x0030){
|
if (hci_stack->manufacturer != 0x0030){
|
||||||
uint32_t new_baud = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
// Limit baud rate for Broadcom chipsets to 3 mbps
|
||||||
log_info("Local baud rate change to %"PRIu32, new_baud);
|
uint32_t baud_rate = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||||
hci_stack->hci_transport->set_baudrate(new_baud);
|
if (hci_stack->manufacturer == 0x000f && baud_rate > 3000000){
|
||||||
|
baud_rate = 3000000;
|
||||||
|
}
|
||||||
|
log_info("Local baud rate change to %"PRIu32, baud_rate);
|
||||||
|
hci_stack->hci_transport->set_baudrate(baud_rate);
|
||||||
}
|
}
|
||||||
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
||||||
return;
|
return;
|
||||||
@ -1147,9 +1163,13 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
hci_stack->substate = HCI_INIT_READ_BD_ADDR;
|
hci_stack->substate = HCI_INIT_READ_BD_ADDR;
|
||||||
return;
|
return;
|
||||||
case HCI_INIT_W4_SEND_BAUD_CHANGE_BCM: {
|
case HCI_INIT_W4_SEND_BAUD_CHANGE_BCM: {
|
||||||
uint32_t new_baud = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
// Limit baud rate for Broadcom chipsets to 3 mbps
|
||||||
log_info("Local baud rate change to %"PRIu32" after init script", new_baud);
|
uint32_t baud_rate = ((hci_uart_config_t *)hci_stack->config)->baudrate_main;
|
||||||
hci_stack->hci_transport->set_baudrate(new_baud);
|
if (hci_stack->manufacturer == 0x000f && baud_rate > 3000000){
|
||||||
|
baud_rate = 3000000;
|
||||||
|
}
|
||||||
|
log_info("Local baud rate change to %"PRIu32" after init script", baud_rate);
|
||||||
|
hci_stack->hci_transport->set_baudrate(baud_rate);
|
||||||
if (need_addr_change){
|
if (need_addr_change){
|
||||||
hci_stack->substate = HCI_INIT_SET_BD_ADDR;
|
hci_stack->substate = HCI_INIT_SET_BD_ADDR;
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user