1 /****************************************************************************** 2 * 3 * Copyright (C) 2013-2014 Google Inc. 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 19 #ifndef RTK_HCI_H5_INT_H 20 #define RTK_HCI_H5_INT_H 21 22 #pragma once 23 24 #include <stdbool.h> 25 #include <stdint.h> 26 #include <errno.h> 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include "bt_hci_bdroid.h" 30 #include "bt_vendor_lib.h" 31 #include "rtk_hcidefs.h" 32 #include "rtk_common.h" 33 34 // HCI Command opcodes 35 #define HCI_LE_READ_BUFFER_SIZE 0x2002 36 #define DATA_TYPE_H5 0x05 37 38 // HCI VENDOR Command opcode 39 #define HCI_VSC_H5_INIT 0xFCEE 40 #define HCI_VSC_UPDATE_BAUDRATE 0xFC17 41 #define HCI_VSC_DOWNLOAD_FW_PATCH 0xFC20 42 #define HCI_VSC_READ_ROM_VERSION 0xFC6D 43 #define HCI_VSC_READ_CHIP_TYPE 0xFC61 44 #define HCI_VSC_SET_WAKE_UP_DEVICE 0xFC7B 45 #define HCI_VSC_BT_OFF 0xFC28 46 #define HCI_READ_LMP_VERSION 0x1001 47 #define HCI_VENDOR_RESET 0x0C03 48 #define HCI_VENDOR_FORCE_RESET_AND_PATCHABLE 0xFC66 49 50 void ms_delay(uint32_t timeout); 51 52 typedef enum { DATA_TYPE_COMMAND = 1, DATA_TYPE_ACL = 2, DATA_TYPE_SCO = 3, DATA_TYPE_EVENT = 4 } serial_data_type_t; 53 54 typedef struct hci_h5_callbacks_t { 55 uint16_t (*h5_int_transmit_data_cb)(serial_data_type_t type, uint8_t *data, uint16_t length); 56 void (*h5_data_ready_cb)(serial_data_type_t type, unsigned int total_length); 57 } hci_h5_callbacks_t; 58 59 typedef struct hci_h5_t { 60 void (*h5_int_init)(hci_h5_callbacks_t *h5_callbacks); 61 void (*h5_int_cleanup)(void); 62 uint16_t (*h5_send_cmd)(serial_data_type_t type, uint8_t *data, uint16_t length); 63 uint8_t (*h5_send_sync_cmd)(uint16_t opcode, uint8_t *data, uint16_t length); 64 uint16_t (*h5_send_acl_data)(serial_data_type_t type, uint8_t *data, uint16_t length); 65 uint16_t (*h5_send_sco_data)(serial_data_type_t type, uint8_t *data, uint16_t length); 66 bool (*h5_recv_msg)(uint8_t *byte, uint16_t length); 67 size_t (*h5_int_read_data)(uint8_t *data_buffer, size_t max_size); 68 } hci_h5_t; 69 70 const hci_h5_t *hci_get_h5_int_interface(void); 71 void set_h5_init_datatrans_flag(int flag); 72 void set_h5_log_enable(unsigned int enable); 73 74 #endif 75