1 /* 2 * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef H_ESP_HCI_DRIVER_ 7 #define H_ESP_HCI_DRIVER_ 8 #include <stdint.h> 9 10 /** 11 * @brief Enumeration of HCI transport direction. 12 */ 13 typedef enum { 14 HCI_DRIVER_DIR_C2H = 0x00, ///< From controller to host. 15 HCI_DRIVER_DIR_H2C, ///< From host to controller. 16 } hci_driver_direction_t; 17 18 typedef enum { 19 HCI_DRIVER_TYPE_CMD = 0x01, ///< HCI Command Indicator. 20 HCI_DRIVER_TYPE_ACL, ///< HCI ACL Data Indicator. 21 HCI_DRIVER_TYPE_SYNC, ///< HCI Synchronous Data Indicator. 22 HCI_DRIVER_TYPE_EVT, ///< HCI Event Indicator. 23 HCI_DRIVER_TYPE_ISO, ///< HCI Isochronous Data Indicator. 24 HCI_DRIVER_TYPE_VENDOR, ///< HCI Vendor data Indicator. 25 } hci_driver_data_type_t; 26 27 typedef int hci_driver_forward_fn(hci_driver_data_type_t data_type, uint8_t *data, uint32_t length, 28 hci_driver_direction_t dir); 29 30 /** 31 * @brief Structure of HCI driver operations. 32 */ 33 typedef struct hci_driver_ops { 34 int (*hci_driver_tx)(hci_driver_data_type_t data_type, uint8_t *data, uint32_t length, 35 hci_driver_direction_t dir); 36 int (*hci_driver_init)(hci_driver_forward_fn *cb); 37 void (*hci_driver_deinit)(void); 38 } hci_driver_ops_t; 39 40 41 #if CONFIG_BT_LE_HCI_INTERFACE_USE_RAM 42 extern hci_driver_ops_t hci_driver_vhci_ops; 43 #endif // CONFIG_BT_LE_HCI_INTERFACE_USE_RAM 44 45 #if CONFIG_BT_LE_HCI_INTERFACE_USE_UART 46 #if CONFIG_BT_LE_UART_HCI_DMA_MODE 47 extern hci_driver_ops_t hci_driver_uart_dma_ops; 48 /** 49 * @brief Reconfigure the UART pins for the HCI driver. 50 * 51 * This function changes the UART pin configuration for the HCI driver. 52 * 53 * @param tx_pin The pin number for the UART TX (transmit) line. 54 * @param rx_pin The pin number for the UART RX (receive) line. 55 * @param cts_pin The pin number for the UART CTS (clear to send) line. 56 * @param rts_pin The pin number for the UART RTS (request to send) line. 57 * 58 * @return int Returns 0 on success, or a negative error code on failure. 59 */ 60 int hci_driver_uart_dma_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); 61 #define hci_uart_reconfig_pin hci_driver_uart_dma_reconfig_pin 62 #else 63 extern hci_driver_ops_t hci_driver_uart_ops; 64 /** 65 * @brief Reconfigure the UART pins for the HCI driver. 66 * 67 * This function changes the UART pin configuration for the HCI driver. 68 * 69 * @param tx_pin The pin number for the UART TX (transmit) line. 70 * @param rx_pin The pin number for the UART RX (receive) line. 71 * @param cts_pin The pin number for the UART CTS (clear to send) line. 72 * @param rts_pin The pin number for the UART RTS (request to send) line. 73 * 74 * @return int Returns 0 on success, or a negative error code on failure. 75 */ 76 int hci_driver_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); 77 #define hci_uart_reconfig_pin hci_driver_uart_reconfig_pin 78 #endif // CONFIG_BT_LE_UART_HCI_DMA_MODE 79 #endif // CONFIG_BT_LE_HCI_INTERFACE_USE_UART 80 81 #endif // H_ESP_HCI_DRIVER_ 82