From 620cbfd42880e77890231a44d82a3312bfc642a3 Mon Sep 17 00:00:00 2001 From: zwl Date: Mon, 27 Feb 2023 21:45:32 +0800 Subject: [PATCH 1/3] ble: Fixed flow control count error on ESP32-C2 --- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 1 - 1 file changed, 1 deletion(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 4ff90dace2..a529666167 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -823,7 +823,6 @@ r_ble_ll_get_tx_pwr_compensation = 0x40000f88; r_ble_ll_hci_acl_rx = 0x40000f8c; r_ble_ll_hci_adv_mode_ext = 0x40000f90; r_ble_ll_hci_adv_set_enable = 0x40000f94; -r_ble_ll_hci_cb_host_buf_size = 0x40000f98; r_ble_ll_hci_cb_set_ctrlr_to_host_fc = 0x40000f9c; r_ble_ll_hci_cb_set_event_mask = 0x40000fa0; r_ble_ll_hci_cb_set_event_mask2 = 0x40000fa4; From 57c7310512f933ac98bf4008c5aa53692bf7c9b0 Mon Sep 17 00:00:00 2001 From: zwl Date: Tue, 28 Feb 2023 17:43:46 +0800 Subject: [PATCH 2/3] ble: Add assertion checking for bluedroid hci on ESP32-C2,ESP32-C6 and ESP32-H2 --- components/bt/controller/esp32c2/bt.c | 2 +- components/bt/controller/esp32c6/bt.c | 2 +- components/bt/controller/esp32h2/bt.c | 2 +- components/bt/controller/esp32h4/bt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 1ed40d5140..e1d6592625 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -320,7 +320,7 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) if (*(data) == DATA_TYPE_ACL) { struct os_mbuf *om = os_msys_get_pkthdr(len, ACL_DATA_MBUF_LEADINGSPCAE); assert(om); - os_mbuf_append(om, &data[1], len - 1); + assert(os_mbuf_append(om, &data[1], len - 1) == 0); ble_hci_trans_hs_acl_tx(om); } diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 2a858c169b..375a883085 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -308,7 +308,7 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) if (*(data) == DATA_TYPE_ACL) { struct os_mbuf *om = os_msys_get_pkthdr(len, ACL_DATA_MBUF_LEADINGSPCAE); assert(om); - os_mbuf_append(om, &data[1], len - 1); + assert(os_mbuf_append(om, &data[1], len - 1) == 0); ble_hci_trans_hs_acl_tx(om); } } diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 30e1c77f51..7d824d83bd 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -308,7 +308,7 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) if (*(data) == DATA_TYPE_ACL) { struct os_mbuf *om = os_msys_get_pkthdr(len, ACL_DATA_MBUF_LEADINGSPCAE); assert(om); - os_mbuf_append(om, &data[1], len - 1); + assert(os_mbuf_append(om, &data[1], len - 1) == 0); ble_hci_trans_hs_acl_tx(om); } } diff --git a/components/bt/controller/esp32h4/bt.c b/components/bt/controller/esp32h4/bt.c index 665968fb28..568f1ebb0d 100644 --- a/components/bt/controller/esp32h4/bt.c +++ b/components/bt/controller/esp32h4/bt.c @@ -324,7 +324,7 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) if (*(data) == DATA_TYPE_ACL) { struct os_mbuf *om = os_msys_get_pkthdr(len, ACL_DATA_MBUF_LEADINGSPCAE); assert(om); - os_mbuf_append(om, &data[1], len - 1); + assert(os_mbuf_append(om, &data[1], len - 1) == 0); ble_hci_trans_hs_acl_tx(om); } From 45d207572b7606f7c37d1878303d2689a6ec2dfe Mon Sep 17 00:00:00 2001 From: zwl Date: Tue, 7 Mar 2023 18:52:30 +0800 Subject: [PATCH 3/3] Add hci uart pin reconfig API --- components/bt/porting/transport/include/hci_uart.h | 10 ++++++++++ components/bt/porting/transport/uart/hci_uart.c | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/components/bt/porting/transport/include/hci_uart.h b/components/bt/porting/transport/include/hci_uart.h index 5995397342..02bc91b403 100644 --- a/components/bt/porting/transport/include/hci_uart.h +++ b/components/bt/porting/transport/include/hci_uart.h @@ -84,6 +84,16 @@ void hci_uart_start_tx(int port_num); */ void hci_uart_start_rx(int port_num); +/** + * @brief reconfig hci uart pin + * + * @param tx_pin The Tx pin + * @param rx_pin The Rx pin + * @param cts_pin The CTS pin + * @param rts_pin The RTS pin + * @return int 0 on success, non-zero error code on failure + */ +int hci_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); #ifdef __cplusplus } diff --git a/components/bt/porting/transport/uart/hci_uart.c b/components/bt/porting/transport/uart/hci_uart.c index edb2278e30..0f89ebf857 100644 --- a/components/bt/porting/transport/uart/hci_uart.c +++ b/components/bt/porting/transport/uart/hci_uart.c @@ -191,4 +191,17 @@ int hci_uart_close(int port_num) return 0; } +int hci_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin) +{ + int port_num = hci_uart.port; + int32_t baud_rate = hci_uart.cfg.baud_rate; + uint8_t data_bits = hci_uart.cfg.data_bits; + uint8_t stop_bits = hci_uart.cfg.stop_bits; + uart_parity_t parity = hci_uart.cfg.parity; + uart_hw_flowcontrol_t flow_ctl = hci_uart.cfg.flow_ctrl; + hci_uart_close(port_num); + hci_uart_config(port_num, baud_rate, data_bits, stop_bits, parity, flow_ctl); + ESP_ERROR_CHECK(uart_set_pin(port_num, tx_pin, rx_pin, rts_pin, cts_pin)); + return 0; +} #endif //CONFIG_BT_LE_HCI_INTERFACE_USE_UART