• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2018 Realtek Corporation.
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 "bt_hci_bdroid.h"
27 #include "bt_vendor_lib.h"
28 #include <errno.h>
29 #include <stdio.h>
30 #include <stdlib.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
53 {
54   DATA_TYPE_COMMAND = 1,
55   DATA_TYPE_ACL = 2,
56   DATA_TYPE_SCO = 3,
57   DATA_TYPE_EVENT = 4
58 } serial_data_type_t;
59 
60 typedef struct hci_h5_callbacks_t
61 {
62   uint16_t (*h5_int_transmit_data_cb)(serial_data_type_t type, uint8_t *data, uint16_t length);
63   void (*h5_data_ready_cb)(serial_data_type_t type, unsigned int total_length);
64 } hci_h5_callbacks_t;
65 
66 typedef struct hci_h5_t
67 {
68   void (*h5_int_init)(hci_h5_callbacks_t *h5_callbacks);
69   void (*h5_int_cleanup)(void);
70   uint16_t (*h5_send_cmd)(serial_data_type_t type, uint8_t *data, uint16_t length);
71   uint8_t (*h5_send_sync_cmd)(uint16_t opcode, uint8_t *data, uint16_t length);
72   uint16_t (*h5_send_acl_data)(serial_data_type_t type, uint8_t *data, uint16_t length);
73   uint16_t (*h5_send_sco_data)(serial_data_type_t type, uint8_t *data, uint16_t length);
74   bool (*h5_recv_msg)(uint8_t *byte, uint16_t length);
75   size_t (*h5_int_read_data)(uint8_t *data_buffer, size_t max_size);
76 } hci_h5_t;
77 
78 const hci_h5_t *hci_get_h5_int_interface(void);
79 
80 #endif
81