mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-03 01:20:35 +00:00
hci_transport_h4: generalize ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
This commit is contained in:
parent
5ff6a55bc1
commit
7741d2d072
@ -151,11 +151,11 @@ static uint8_t * hci_packet = &hci_packet_with_pre_buffer[HCI_INCOMING_PRE_BUFFE
|
|||||||
static const uint8_t local_version_event_prefix[] = { 0x04, 0x0e, 0x0c, 0x01, 0x01, 0x10};
|
static const uint8_t local_version_event_prefix[] = { 0x04, 0x0e, 0x0c, 0x01, 0x01, 0x10};
|
||||||
static const uint8_t baud_rate_command_prefix[] = { 0x01, 0x36, 0xff, 0x04};
|
static const uint8_t baud_rate_command_prefix[] = { 0x01, 0x36, 0xff, 0x04};
|
||||||
static enum {
|
static enum {
|
||||||
CC256X_WORKAROUND_IDLE,
|
BAUDRATE_CHANGE_WORKAROUND_IDLE,
|
||||||
CC256X_WORKAROUND_CHIPSET_DETECTED,
|
BAUDRATE_CHANGE_WORKAROUND_CHIPSET_DETECTED,
|
||||||
CC256X_WORKAROUND_BAUDRATE_COMMAND_SENT,
|
BAUDRATE_CHANGE_WORKAROUND_BAUDRATE_COMMAND_SENT,
|
||||||
CC256X_WORKAROUND_DONE
|
BAUDRATE_CHANGE_WORKAROUND_DONE
|
||||||
} cc256x_workaround_state;
|
} baudrate_change_workaround_state;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int hci_transport_h4_set_baudrate(uint32_t baudrate){
|
static int hci_transport_h4_set_baudrate(uint32_t baudrate){
|
||||||
@ -244,16 +244,16 @@ static void hci_transport_h4_block_read(void){
|
|||||||
|
|
||||||
case H4_W4_PAYLOAD:
|
case H4_W4_PAYLOAD:
|
||||||
#ifdef ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
#ifdef ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
||||||
if (cc256x_workaround_state == CC256X_WORKAROUND_IDLE
|
if (baudrate_change_workaround_state == BAUDRATE_CHANGE_WORKAROUND_IDLE
|
||||||
&& memcmp(hci_packet, local_version_event_prefix, sizeof(local_version_event_prefix)) == 0){
|
&& memcmp(hci_packet, local_version_event_prefix, sizeof(local_version_event_prefix)) == 0){
|
||||||
if (little_endian_read_16(hci_packet, 11) == BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
|
if (little_endian_read_16(hci_packet, 11) == BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
|
||||||
// detect TI CC256x controller based on manufacturer
|
// detect TI CC256x controller based on manufacturer
|
||||||
log_info("Detected CC256x controller");
|
log_info("Detected CC256x controller");
|
||||||
cc256x_workaround_state = CC256X_WORKAROUND_CHIPSET_DETECTED;
|
baudrate_change_workaround_state = BAUDRATE_CHANGE_WORKAROUND_CHIPSET_DETECTED;
|
||||||
} else {
|
} else {
|
||||||
// work around not needed
|
// work around not needed
|
||||||
log_info("Bluetooth controller not by TI");
|
log_info("Bluetooth controller not by TI");
|
||||||
cc256x_workaround_state = CC256X_WORKAROUND_DONE;
|
baudrate_change_workaround_state = BAUDRATE_CHANGE_WORKAROUND_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -265,8 +265,8 @@ static void hci_transport_h4_block_read(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
#ifdef ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
||||||
if (cc256x_workaround_state == CC256X_WORKAROUND_BAUDRATE_COMMAND_SENT){
|
if (baudrate_change_workaround_state == BAUDRATE_CHANGE_WORKAROUND_BAUDRATE_COMMAND_SENT){
|
||||||
cc256x_workaround_state = CC256X_WORKAROUND_IDLE;
|
baudrate_change_workaround_state = BAUDRATE_CHANGE_WORKAROUND_IDLE;
|
||||||
// avoid flowcontrol problem by reading expected hci command complete event of 7 bytes in a single block read
|
// avoid flowcontrol problem by reading expected hci command complete event of 7 bytes in a single block read
|
||||||
h4_state = H4_W4_PAYLOAD;
|
h4_state = H4_W4_PAYLOAD;
|
||||||
bytes_to_read = 7;
|
bytes_to_read = 7;
|
||||||
@ -317,10 +317,10 @@ static int hci_transport_h4_send_packet(uint8_t packet_type, uint8_t * packet, i
|
|||||||
*packet = packet_type;
|
*packet = packet_type;
|
||||||
|
|
||||||
#ifdef ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
#ifdef ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
|
||||||
if ((cc256x_workaround_state == CC256X_WORKAROUND_CHIPSET_DETECTED)
|
if ((baudrate_change_workaround_state == BAUDRATE_CHANGE_WORKAROUND_CHIPSET_DETECTED)
|
||||||
&& (memcmp(packet, baud_rate_command_prefix, sizeof(baud_rate_command_prefix)) == 0)) {
|
&& (memcmp(packet, baud_rate_command_prefix, sizeof(baud_rate_command_prefix)) == 0)) {
|
||||||
log_info("CC256x baud rate command detected, expect command complete event next");
|
log_info("Baud rate command detected, expect command complete event next");
|
||||||
cc256x_workaround_state = CC256X_WORKAROUND_BAUDRATE_COMMAND_SENT;
|
baudrate_change_workaround_state = BAUDRATE_CHANGE_WORKAROUND_BAUDRATE_COMMAND_SENT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user