1 /* 2 * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 #include <inttypes.h> 13 #include "driver/uart.h" 14 #include "os/os_mbuf.h" 15 #include "esp_bt.h" 16 #include "esp_hci_transport.h" 17 18 /** 19 * @brief UART configuration parameters for the HCI driver 20 */ 21 typedef struct hci_driver_uart_params_config 22 { 23 uint8_t hci_uart_port; /*!< Port of UART for HCI */ 24 uint8_t hci_uart_data_bits; /*!< Data bits of UART for HCI */ 25 uint8_t hci_uart_stop_bits; /*!< Stop bits of UART for HCI */ 26 uint8_t hci_uart_flow_ctrl; /*!< Flow control of UART for HCI */ 27 uint8_t hci_uart_parity; /*!< UART parity */ 28 uint8_t hci_uart_driver_mode; /*!< UART driver mode */ 29 uint32_t hci_uart_baud; /*!< Baudrate of UART for HCI */ 30 int hci_uart_tx_pin; /*!< Tx Pin number of UART for HCI */ 31 int hci_uart_rx_pin; /*!< Rx Pin number of UART for HCI */ 32 int hci_uart_rts_pin; /*!< RTS Pin number of UART for HCI */ 33 int hci_uart_cts_pin; /*!< CTS Pin number of UART for HCI */ 34 } hci_driver_uart_params_config_t; 35 36 #define BT_HCI_DRIVER_UART_CONFIG_DEFAULT() { \ 37 .hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT, \ 38 .hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD, \ 39 .hci_uart_tx_pin = DEFAULT_BT_LE_HCI_UART_TX_PIN , \ 40 .hci_uart_rx_pin = DEFAULT_BT_LE_HCI_UART_RX_PIN, \ 41 .hci_uart_cts_pin = DEFAULT_BT_LE_HCI_UART_CTS_PIN, \ 42 .hci_uart_rts_pin = DEFAULT_BT_LE_HCI_UART_RTS_PIN, \ 43 .hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS, \ 44 .hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS, \ 45 .hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL, \ 46 .hci_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY, \ 47 } 48 49 /** 50 * @brief Configures the HCI driver UART parameters. 51 * This function sets up the UART interface according to the specified configuration parameters. 52 * 53 * @param uart_config A pointer to a structure containing the UART configuration parameters. 54 * The structure should include details such as baud rate, parity, stop bits, and flow control. 55 * Ensure that the uart_config structure is correctly initialized before calling this function. 56 * 57 * @return int Returns 0 on success, or a non-zero error code on failure. 58 * 59 * @note This function should be called before any UART communication is initiated. 60 */ 61 int hci_driver_uart_config(hci_driver_uart_params_config_t *uart_config); 62 63 #ifdef __cplusplus 64 } 65 #endif 66