1 /******************************************************************************
2  *
3  *  Copyright (C) 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 #pragma once
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
24 
25 //HCI Command opcodes
26 #define HCI_LE_READ_BUFFER_SIZE     0x2002
27 #define DATA_TYPE_H5                0x05
28 
29 //HCI VENDOR Command opcode
30 #define HCI_VSC_H5_INIT                 0xFCEE
31 #define HCI_VSC_UPDATE_BAUDRATE         0xFC17
32 #define HCI_VSC_DOWNLOAD_FW_PATCH       0xFC20
33 #define HCI_VSC_READ_ROM_VERSION        0xFC6D
34 #define HCI_VSC_READ_CHIP_TYPE          0xFC61
35 #define HCI_VSC_SET_WAKE_UP_DEVICE      0xFC7B
36 #define HCI_VSC_BT_OFF                  0xFC28
37 
38 typedef enum {
39     DATA_TYPE_NONE    = 0,
40     DATA_TYPE_COMMAND = 1,
41     DATA_TYPE_ACL     = 2,
42     DATA_TYPE_SCO     = 3,
43     DATA_TYPE_EVENT   = 4
44 } hci_data_type_t;
45 
46 typedef void (*packet_recv)(hci_data_type_t type, uint8_t *data, uint32_t len);
47 
48 typedef struct h5_t {
49      void     (*h5_int_init)(packet_recv h5_callbacks);
50      void     (*h5_int_cleanup)(void);
51      uint16_t (*h5_send_cmd)(hci_data_type_t type, uint8_t *data, uint16_t length);
52      uint8_t  (*h5_send_sync_cmd)(uint16_t opcode, uint8_t *data, uint16_t length);
53      uint16_t (*h5_send_acl_data)(hci_data_type_t type, uint8_t *data, uint16_t length);
54 } h5_t;
55 
56 const h5_t *get_h5_interface(void);
57 
58 
59