1 /****************************************************************************** 2 * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") 3 * All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *****************************************************************************/ 18 #ifndef STACK_BLE_BQB_BT_HCI_H_ 19 #define STACK_BLE_BQB_BT_HCI_H_ 20 21 #include "bqb.h" 22 23 #include "stack/ble/hci/hci.h" 24 #include "stack/ble/hci/hci_cmd.h" 25 #include "stack/ble/hci/hci_const.h" 26 #include "stack/ble/hci/hci_event.h" 27 28 typedef enum { 29 HT_ERR_EVT_TIMEOUT_START = 0x80, 30 HT_ERR_EVT_TIMEOUT_LE_CONNECTION_COMPLETE = HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_LE_CONNECTION_COMPLETE, 31 HT_ERR_EVT_TIMEOUT_LE_ADVERTISING_REPORT = HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_LE_ADVERTISING_REPORT, 32 HT_ERR_EVT_TIMEOUT_LE_CONNECTION_UPDATE_COMPLETE = 33 HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_LE_CONNECTION_UPDATE_COMPLETE, 34 HT_ERR_EVT_TIMEOUT_LE_READ_REMOTE_USED_FEATURES_COMPLETE = 35 HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE, 36 37 HT_ERR_EVT_TIMEOUT_LE_DATA_LENGTH_CHANGE = HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_LE_DATA_LENGTH_CHANGE, 38 HT_ERR_EVT_TIMEOUT_LE_PHY_UPDATE_COMPLETE = HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_LE_PHY_UPDATE_COMPLETE, 39 40 HT_ERR_EVT_TIMEOUT_DISCONNECTION_COMPLETE = HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_MAX + 0, 41 HT_ERR_EVT_TIMEOUT_NUM_OF_COMPLETE_PACKETS = HT_ERR_EVT_TIMEOUT_START + HCI_SUB_EVT_MAX + 1, 42 43 HT_ERR_COMPLETE_EVT_TIMEOUT = 0xF0, 44 HT_ERR_STATUS_EVT_TIMEOUT = 0xF1, 45 HT_ERR_PARAM_LEN_ERR = 0xF2, 46 HT_ERR_OPCODE_ERR = 0xF3, 47 HT_ERR_UNEXPECT_STS = 0xF4, 48 49 HOST_RX_FIFO_OVERFLOW = 0xF8, 50 CONTROLLER_RX_FIFO_OVERFLOW = 0xF9, 51 } ht_err_t; 52 53 extern hci_fifo_t host_hciTxfifo; 54 extern hci_fifo_t host_hciRxfifo; 55 56 typedef int (*loop_func_t)(void); 57 58 void ht_hci_init(void); 59 60 int blc_register_host_loop_func(void *p); 61 int blc_register_controller_loop_func(void *p); 62 63 int host_process_wait_hci_event(void); 64 65 int host_hci_handler(u8 *p, int n); 66 67 ble_sts_t host_initHciTxFifo(u8 *pTxbuf, int fifo_size, int fifo_number); 68 ble_sts_t host_initHciRxFifo(u8 *pRxbuf, int fifo_size, int fifo_number); 69 70 void host_register_hci_handler(void *prx, void *ptx); 71 int ht_hci_send_data(u32 h, u8 *para, int n); 72 73 void host_testcase_function_register(char *testcase, callback_testcase_t func); 74 int exe_upper_tester_command(u8 *cmd); 75 76 void ht_reset_stack(void); 77 78 int ht_set_test_result(int err_flag); 79 80 #endif /* STACK_BLE_BQB_BT_HCI_H_ */ 81