tzh
2024-08-15 d4a1bd480003f3e1a0590bc46fbcb24f05652ca7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/******************************************************************************
 *
 *  Copyright (C) 2019-2021 Aicsemi Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
 
/******************************************************************************
 *
 *  Filename:      userial_vendor.h
 *
 *  Description:   Contains vendor-specific definitions used in serial port
 *                 controls
 *
 ******************************************************************************/
 
#ifndef USERIAL_VENDOR_H
#define USERIAL_VENDOR_H
 
#include "bt_vendor_aic.h"
#include "userial.h"
#include "hci_h5_int.h"
#include <sys/poll.h>
#include <assert.h>
#include "aic_parse.h"
#include "bt_skbuff.h"
#include "aic_common.h"
 
/******************************************************************************
**  Constants & Macros
******************************************************************************/
#define AIC_NO_INTR(fn)                do {} while ((fn) == -1 && errno == EINTR)
 
/**** baud rates ****/
#define USERIAL_BAUD_300               0
#define USERIAL_BAUD_600               1
#define USERIAL_BAUD_1200              2
#define USERIAL_BAUD_2400              3
#define USERIAL_BAUD_9600              4
#define USERIAL_BAUD_19200             5
#define USERIAL_BAUD_57600             6
#define USERIAL_BAUD_115200            7
#define USERIAL_BAUD_230400            8
#define USERIAL_BAUD_460800            9
#define USERIAL_BAUD_921600            10
#define USERIAL_BAUD_1M                11
#define USERIAL_BAUD_1_5M              12
#define USERIAL_BAUD_2M                13
#define USERIAL_BAUD_3M                14
#define USERIAL_BAUD_4M                15
#define USERIAL_BAUD_AUTO              16
#define USERIAL_BAUD_2_5M              17
#define USERIAL_BAUD_3_5M              18
 
/**** Data Format ****/
/* Stop Bits */
#define USERIAL_STOPBITS_1             1
#define USERIAL_STOPBITS_1_5           (1<<1)
#define USERIAL_STOPBITS_2             (1<<2)
 
/* Parity Bits */
#define USERIAL_PARITY_NONE            (1<<3)
#define USERIAL_PARITY_EVEN            (1<<4)
#define USERIAL_PARITY_ODD             (1<<5)
 
/* Data Bits */
#define USERIAL_DATABITS_5             (1<<6)
#define USERIAL_DATABITS_6             (1<<7)
#define USERIAL_DATABITS_7             (1<<8)
#define USERIAL_DATABITS_8             (1<<9)
 
 
#define USERIAL_HW_FLOW_CTRL_OFF       0
#define USERIAL_HW_FLOW_CTRL_ON        1
 
 
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
/* These are the ioctl values used for bt_wake ioctl via UART driver. you may
 * need to redefine them on you platform!
 * Logically they need to be unique and not colide with existing uart ioctl's.
 */
#ifndef USERIAL_IOCTL_BT_WAKE_ASSERT
#define USERIAL_IOCTL_BT_WAKE_ASSERT   0x8003
#endif
#ifndef USERIAL_IOCTL_BT_WAKE_DEASSERT
#define USERIAL_IOCTL_BT_WAKE_DEASSERT 0x8004
#endif
#ifndef USERIAL_IOCTL_BT_WAKE_GET_ST
#define USERIAL_IOCTL_BT_WAKE_GET_ST   0x8005
#endif
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
 
/******************************************************************************
**  Type definitions
******************************************************************************/
/* Structure used to configure serial port during open */
typedef struct {
    uint16_t fmt;       /* Data format */
    uint8_t  baud;      /* Baud rate */
    uint8_t hw_fctrl; /*hardware flowcontrol*/
} tUSERIAL_CFG;
 
typedef enum {
#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
    USERIAL_OP_ASSERT_BT_WAKE,
    USERIAL_OP_DEASSERT_BT_WAKE,
    USERIAL_OP_GET_BT_WAKE_STATE,
#endif
    USERIAL_OP_NOP,
} userial_vendor_ioctl_op_t;
 
enum {
    AICBT_PACKET_IDLE,
    AICBT_PACKET_TYPE,
    AICBT_PACKET_HEADER,
    AICBT_PACKET_CONTENT,
    AICBT_PACKET_END
};
 
/******************************************************************************
**  Extern variables and functions
******************************************************************************/
 
/******************************************************************************
**  Functions
******************************************************************************/
 
/*******************************************************************************
**
** Function        userial_vendor_init
**
** Description     Initialize userial vendor-specific control block
**
** Returns         None
**
*******************************************************************************/
void userial_vendor_init(char *bt_device_node);
 
/*******************************************************************************
**
** Function        userial_vendor_open
**
** Description     Open the serial port with the given configuration
**
** Returns         device fd
**
*******************************************************************************/
int userial_vendor_open(tUSERIAL_CFG *p_cfg);
 
/*******************************************************************************
**
** Function        userial_vendor_close
**
** Description     Conduct vendor-specific close work
**
** Returns         None
**
*******************************************************************************/
void userial_vendor_close(void);
 
/*******************************************************************************
**
** Function        userial_vendor_set_baud
**
** Description     Set new baud rate
**
** Returns         None
**
*******************************************************************************/
void userial_vendor_set_baud(uint8_t userial_baud);
 
/*******************************************************************************
**
** Function        userial_vendor_ioctl
**
** Description     ioctl inteface
**
** Returns         None
**
*******************************************************************************/
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data);
 
void userial_vendor_set_hw_fctrl(uint8_t hw_fctrl);
int userial_socket_open(void);
int userial_vendor_usb_ioctl(int operation, void* param);
int userial_vendor_usb_open(void);
void userial_recv_rawdata_hook(unsigned char *buffer, unsigned int total_length);
void userial_set_bt_interface_state(int bt_on);
 
#define AIC_HANDLE_EVENT
#define AIC_HANDLE_CMD
#define CONFIG_SCO_OVER_HCI
//#define CONFIG_SCO_MSBC_PLC
 
#endif /* USERIAL_VENDOR_H */