From 56ef2d06f7315203f16c9e7399a6bdb2a993c1c4 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Fri, 22 Sep 2023 16:14:01 +0800 Subject: [PATCH] feat: add config to disable ble hci uart flow control --- components/bt/controller/esp32/Kconfig.in | 5 +++++ components/bt/controller/esp32/bt.c | 7 +++++++ .../main/controller_hci_uart_demo.c | 2 +- .../main/Kconfig.projbuild | 6 ++++++ .../controller_hci_uart_esp32c3/main/uhci_uart_demo.c | 11 +++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 8d97603164..052a13e984 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -205,6 +205,11 @@ menu "HCI UART(H4) Options" help UART Baudrate for HCI. Please use standard baudrate. + config BTDM_CTRL_HCI_UART_FLOW_CTRL_EN + bool "Enable UART flow control" + depends on BTDM_CTRL_HCI_MODE_UART_H4 + default y + endmenu menu "MODEM SLEEP Options" diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index c1417435b3..681cef055c 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -234,6 +234,7 @@ extern int coex_register_wifi_channel_change_callback(void *cb); /* Shutdown */ extern void esp_bt_controller_shutdown(void); extern void sdk_config_set_bt_pll_track_enable(bool enable); +extern void sdk_config_set_uart_flow_ctrl_enable(bool enable); extern char _bss_start_btdm; extern char _bss_end_btdm; @@ -1315,6 +1316,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE); #endif +#if CONFIG_BTDM_CTRL_HCI_UART_FLOW_CTRL_EN + sdk_config_set_uart_flow_ctrl_enable(true); +#else + sdk_config_set_uart_flow_ctrl_enable(false); +#endif + #ifdef CONFIG_PM_ENABLE if (!s_btdm_allow_light_sleep) { if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) { diff --git a/examples/bluetooth/hci/controller_hci_uart_esp32/main/controller_hci_uart_demo.c b/examples/bluetooth/hci/controller_hci_uart_esp32/main/controller_hci_uart_demo.c index 9aff571570..bf6205c158 100644 --- a/examples/bluetooth/hci/controller_hci_uart_esp32/main/controller_hci_uart_demo.c +++ b/examples/bluetooth/hci/controller_hci_uart_esp32/main/controller_hci_uart_demo.c @@ -25,7 +25,7 @@ static void uart_gpio_reset(void) periph_module_enable(PERIPH_UHCI0_MODULE); #ifdef CONFIG_BTDM_CTRL_HCI_UART_NO - ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX 18, CTS 23, RTS 19", CONFIG_BTDM_CTRL_HCI_UART_NO); + ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX 18, CTS 23, RTS 19 Baudrate:%d", CONFIG_BTDM_CTRL_HCI_UART_NO, CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE); uart_set_pin(CONFIG_BTDM_CTRL_HCI_UART_NO, 5, 18, 19, 23); #endif diff --git a/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/Kconfig.projbuild b/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/Kconfig.projbuild index 395e8bef94..0912aa239a 100644 --- a/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/Kconfig.projbuild +++ b/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/Kconfig.projbuild @@ -7,4 +7,10 @@ menu "Example Configuration" help UART Baudrate for HCI. Please use standard baudrate. + config EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE + bool "Enable HCI UART flow control" + default y + help + Enable/disable HCI UART flow control + endmenu diff --git a/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c b/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c index 77306f0e48..58a2438277 100644 --- a/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c +++ b/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c @@ -31,6 +31,12 @@ static const char *tag = "UHCI"; #define GPIO_OUTPUT_PIN_SEL ((1ULL<