1 /* 2 * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef H_ESP_HCI_TRANSPORT_ 8 #define H_ESP_HCI_TRANSPORT_ 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 #include <stdint.h> 14 #include "os/os_mbuf.h" 15 #include "esp_hci_driver.h" 16 17 /** 18 * @brief Enumeration of HCI packet indicators 19 */ 20 typedef enum { 21 HCI_CMD_IND = 0x01, /*!< HCI Command Indicator */ 22 HCI_ACL_IND, /*!< HCI ACL Data Indicator */ 23 HCI_SYNC_IND, /*!< HCI Synchronous Data Indicator */ 24 HCI_EVT_IND, /*!< HCI Event Indicator */ 25 HCI_ISO_IND, /*!< HCI Isochronous Data Indicator */ 26 HCI_VENDOR_IND, /*!< HCI Vendor data Indicator */ 27 } hci_trans_pkt_ind_t; 28 29 /** 30 * @brief Enumeration of HCI Transport Mode 31 */ 32 typedef enum { 33 HCI_TRANSPORT_VHCI, /*!< VHCI Transport Mode */ 34 HCI_TRANSPORT_UART_NO_DMA, /*!< UART_NO_DMA Transport Mode */ 35 HCI_TRANSPORT_UART_UHCI, /*!< UART_UHCI Transport Mode */ 36 HCI_TRANSPORT_SDIO, /*!< SDIO Transport Mode */ 37 HCI_TRANSPORT_USB, /*!< USB Transport Mode */ 38 } hci_trans_mode_t; 39 40 typedef int hci_transport_host_recv_fn(hci_trans_pkt_ind_t type, uint8_t *data, uint16_t len); 41 42 /** 43 * @brief Initialize the HCI transport layer. 44 * It should be called before using any other functions in the transport layer. 45 * 46 * @param hci_transport_mode The mode in which the HCI transport should operate. 47 * 48 * @return int Returns 0 on success, or a non-zero error code on failure. 49 */ 50 int hci_transport_init(uint8_t hci_transport_mode); 51 52 /** 53 * @brief Deinitialize the HCI transport layer for releasing any allocated resources. 54 */ 55 void hci_transport_deinit(void); 56 57 /** 58 * @brief Set the host's HCI callback which will be invoked when receiving ACL/Events from controller. 59 * @param callback hci_transport_host_recv_fn type variable 60 * @return int 0 on success, non-zero error code on failure. 61 */ 62 int hci_transport_host_callback_register(hci_transport_host_recv_fn *callback); 63 64 /** 65 * @brief Called to send HCI commands form host to controller. 66 * @param data Point to the commands data 67 * @param length Length of data 68 * @return int 0 on success, non-zero error code on failure. 69 */ 70 int hci_transport_host_cmd_tx(uint8_t *data, uint32_t length); 71 72 /** 73 * @brief Called to send HCI ACL form host to controller. 74 * @param data Point to the ACL data 75 * @param length Length of data 76 * @return int 0 on success, non-zero error code on failure. 77 */ 78 int hci_transport_host_acl_tx(uint8_t *data, uint32_t length); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 #endif /* H_ESP_HCI_TRANSPORT_ */ 84