• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2001-2012 Broadcom 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 /******************************************************************************
20  *
21  *  This file contains serial definitions from WIDCOMM's Universal Embedded
22  *  Drivers API.
23  *
24  ******************************************************************************/
25 
26 #ifndef USERIAL_H
27 #define USERIAL_H
28 
29 /*******************************************************************************
30 ** Serial APIs
31 *******************************************************************************/
32 
33 /**** port IDs ****/
34 #define USERIAL_PORT_1            0
35 #define USERIAL_PORT_2            1
36 #define USERIAL_PORT_3            2
37 #define USERIAL_PORT_4            3
38 #define USERIAL_PORT_5            4
39 #define USERIAL_PORT_6            5
40 #define USERIAL_PORT_7            6
41 #define USERIAL_PORT_8            7
42 #define USERIAL_PORT_9            8
43 #define USERIAL_PORT_10           9
44 #define USERIAL_PORT_11           10
45 #define USERIAL_PORT_12           11
46 #define USERIAL_PORT_13           12
47 #define USERIAL_PORT_14           13
48 #define USERIAL_PORT_15           14
49 #define USERIAL_PORT_16           15
50 #define USERIAL_PORT_17           16
51 #define USERIAL_PORT_18           17
52 
53 typedef UINT8 tUSERIAL_PORT;
54 
55 /**** baud rates ****/
56 #define USERIAL_BAUD_300          0
57 #define USERIAL_BAUD_600          1
58 #define USERIAL_BAUD_1200         2
59 #define USERIAL_BAUD_2400         3
60 #define USERIAL_BAUD_9600         4
61 #define USERIAL_BAUD_19200        5
62 #define USERIAL_BAUD_57600        6
63 #define USERIAL_BAUD_115200       7
64 #define USERIAL_BAUD_230400       8
65 #define USERIAL_BAUD_460800       9
66 #define USERIAL_BAUD_921600       10
67 #define USERIAL_BAUD_1M           11
68 #define USERIAL_BAUD_1_5M         12
69 #define USERIAL_BAUD_2M           13
70 #define USERIAL_BAUD_3M           14
71 #define USERIAL_BAUD_4M           15
72 #define USERIAL_BAUD_AUTO         16
73 
74 /**** Data Format ****/
75 
76 /* Stop Bits */
77 #define USERIAL_STOPBITS_1        1
78 #define USERIAL_STOPBITS_1_5      (1<<1)
79 #define USERIAL_STOPBITS_2        (1<<2)
80 
81 /* Parity Bits */
82 #define USERIAL_PARITY_NONE       (1<<3)
83 #define USERIAL_PARITY_EVEN       (1<<4)
84 #define USERIAL_PARITY_ODD        (1<<5)
85 
86 /* Data Bits */
87 #define USERIAL_DATABITS_5        (1<<6)
88 #define USERIAL_DATABITS_6        (1<<7)
89 #define USERIAL_DATABITS_7        (1<<8)
90 #define USERIAL_DATABITS_8        (1<<9)
91 
92 
93 /**** Flow Control ****/
94 #define USERIAL_FC_NONE           0
95 #define USERIAL_FC_HW             1
96 #define USERIAL_FC_SW             2
97 
98 /**** Data Buffering Mechanism ****/
99 #define USERIAL_BUF_BYTE          0
100 #define USERIAL_BUF_GKI           1
101 
102 /**** Signals ****/
103 #define USERIAL_SIG_RTSCTS        1
104 #define USERIAL_SIG_DSRDTR        (1<<1)
105 #define USERIAL_SIG_RI            (1<<2)
106 #define USERIAL_SIG_CD            (1<<3)
107 #define USERIAL_SIG_DTE_DEVICE    (1<<4)
108 
109 /**** Errors *****/
110 #define USERIAL_ERR_OVERRUN       1
111 #define USERIAL_ERR_PARITY        (1<<1)
112 #define USERIAL_ERR_FRAMING       (1<<2)
113 #define USERIAL_ERR_BREAK         (1<<3)
114 
115 /**** Serial Operations ****/
116 #define USERIAL_OP_FLUSH          0
117 #define USERIAL_OP_FLUSH_RX       1
118 #define USERIAL_OP_FLUSH_TX       2
119 #define USERIAL_OP_BREAK_OFF      3
120 #define USERIAL_OP_BREAK_ON       4
121 #define USERIAL_OP_BAUD_RD        5
122 #define USERIAL_OP_BAUD_WR        6
123 #define USERIAL_OP_FMT_RD         7
124 #define USERIAL_OP_FMT_WR         8
125 #define USERIAL_OP_SIG_RD         9
126 #define USERIAL_OP_SIG_WR         10
127 #define USERIAL_OP_FC_RD          11
128 #define USERIAL_OP_FC_WR          12
129 #define USERIAL_OP_CTS_AS_WAKEUP  13    /* H4IBSS */
130 #define USERIAL_OP_CTS_AS_FC      14    /* H4IBSS */
131 
132 #if (defined LINUX_OS) && (LINUX_OS == TRUE)
133 #define USERIAL_OP_SCO_UP         20    /* LINUX SCO */
134 #define USERIAL_OP_SCO_DOWN       21    /* LINUX SCO */
135 #endif
136 
137 typedef UINT8 tUSERIAL_OP;
138 
139 
140 /**** Serial feature types ****/
141 #define USERIAL_FEAT_PORT_1       0
142 #define USERIAL_FEAT_PORT_2       1
143 #define USERIAL_FEAT_PORT_3       2
144 #define USERIAL_FEAT_PORT_4       3
145 #define USERIAL_FEAT_BAUD_AUTO    4
146 #define USERIAL_FEAT_BAUD_300     5
147 #define USERIAL_FEAT_BAUD_600     6
148 #define USERIAL_FEAT_BAUD_1200    7
149 #define USERIAL_FEAT_BAUD_2400    8
150 #define USERIAL_FEAT_BAUD_9600    9
151 #define USERIAL_FEAT_BAUD_19200   10
152 #define USERIAL_FEAT_BAUD_57600   11
153 #define USERIAL_FEAT_BAUD_115200  12
154 #define USERIAL_FEAT_BAUD_230400  13
155 #define USERIAL_FEAT_BAUD_460800  14
156 #define USERIAL_FEAT_BAUD_921600  15
157 #define USERIAL_FEAT_STOPBITS_1   16
158 #define USERIAL_FEAT_STOPBITS_1_5 17
159 #define USERIAL_FEAT_STOPBITS_2   18
160 #define USERIAL_FEAT_PARITY_NONE  19
161 #define USERIAL_FEAT_PARITY_EVEN  20
162 #define USERIAL_FEAT_PARITY_ODD   21
163 #define USERIAL_FEAT_DATABITS_5   22
164 #define USERIAL_FEAT_DATABITS_6   23
165 #define USERIAL_FEAT_DATABITS_7   24
166 #define USERIAL_FEAT_DATABITS_8   25
167 #define USERIAL_FEAT_FC_NONE      26
168 #define USERIAL_FEAT_FC_HW        27
169 #define USERIAL_FEAT_FC_SW        28
170 #define USERIAL_FEAT_BUF_BYTE     29
171 #define USERIAL_FEAT_BUF_GKI      30
172 #define USERIAL_FEAT_SIG_RTS      31
173 #define USERIAL_FEAT_SIG_CTS      32
174 #define USERIAL_FEAT_SIG_DSR      33
175 #define USERIAL_FEAT_SIG_DTR      34
176 #define USERIAL_FEAT_SIG_RI       35
177 #define USERIAL_FEAT_SIG_CD       36
178 #define USERIAL_FEAT_OP_FLUSH     37
179 #define USERIAL_FEAT_OP_FLUSH_RX  38
180 #define USERIAL_FEAT_OP_FLUSH_TX  39
181 #define USERIAL_FEAT_OP_BREAK     40
182 #define USERIAL_FEAT_OP_BAUD_RD   41
183 #define USERIAL_FEAT_OP_BAUD_WR   42
184 #define USERIAL_FEAT_OP_FMT_RD    43
185 #define USERIAL_FEAT_OP_FMT_WR    44
186 #define USERIAL_FEAT_OP_SIG_RD    45
187 #define USERIAL_FEAT_OP_SIG_WR    46
188 #define USERIAL_FEAT_OP_FC_RD     47
189 #define USERIAL_FEAT_OP_FC_WR     48
190 
191 typedef UINT8 tUSERIAL_FEATURE;
192 
193 
194 /**** Event types ****/
195 #define USERIAL_RX_READY_EVT      0
196 #define USERIAL_TX_DONE_EVT       1
197 #define USERIAL_SIG_EVT           2
198 #define USERIAL_ERR_EVT           3
199 #define USERIAL_WAKEUP_EVT        4 /* H4IBSS */
200 
201 typedef UINT8 tUSERIAL_EVT;
202 
203 
204 /* Structure used to configure serial port during open        */
205 typedef struct
206 {
207     UINT16 fmt;          /* Data format                       */
208     UINT8  baud;         /* Baud rate                         */
209     UINT8  fc;           /* Flow control                      */
210     UINT8  buf;          /* Data buffering mechanism          */
211     UINT8  pool;         /* GKI buffer pool for received data */
212     UINT16 size;         /* Size of GKI buffer pool           */
213     UINT16 offset;       /* Offset in GKI buffer pool         */
214 } tUSERIAL_OPEN_CFG;
215 
216 /* Union used to pass ioctl arguments */
217 typedef union
218 {
219     UINT16 fmt;
220     UINT8  baud;
221     UINT8  fc;
222     UINT8  sigs;
223 #if (defined LINUX_OS) && (LINUX_OS == TRUE)
224     UINT16 sco_handle;
225 #endif
226 } tUSERIAL_IOCTL_DATA;
227 
228 
229 /* Union to pass event data */
230 typedef union
231 {
232     UINT8 sigs;
233     UINT8 error;
234 } tUSERIAL_EVT_DATA;
235 
236 /* callback for events */
237 typedef void (tUSERIAL_CBACK)(tUSERIAL_PORT, tUSERIAL_EVT, tUSERIAL_EVT_DATA *);
238 
239 /*******************************************************************************
240 ** Function Prototypes
241 *******************************************************************************/
242 
243 #ifdef __cplusplus
244 extern "C" {
245 #endif
246 
247 UDRV_API extern void    USERIAL_Init(void *);
248 UDRV_API extern void    USERIAL_Open(tUSERIAL_PORT, tUSERIAL_OPEN_CFG *, tUSERIAL_CBACK *);
249 UDRV_API extern void    USERIAL_ReadBuf(tUSERIAL_PORT, BT_HDR **);
250 UDRV_API extern UINT16  USERIAL_Read(tUSERIAL_PORT, UINT8 *, UINT16);
251 UDRV_API extern BOOLEAN USERIAL_WriteBuf(tUSERIAL_PORT, BT_HDR *);
252 UDRV_API extern UINT16  USERIAL_Write(tUSERIAL_PORT, UINT8 *, UINT16);
253 UDRV_API extern void    USERIAL_Ioctl(tUSERIAL_PORT, tUSERIAL_OP, tUSERIAL_IOCTL_DATA *);
254 UDRV_API extern void    USERIAL_Close(tUSERIAL_PORT);
255 UDRV_API extern BOOLEAN USERIAL_Feature(tUSERIAL_FEATURE);
256 UDRV_API extern BOOLEAN USERIAL_IsClosed();
257 UDRV_API extern void    USERIAL_PowerupDevice(tUSERIAL_PORT port);
258 
259 /*******************************************************************************
260  **
261  ** Function           USERIAL_GetLineSpeed
262  **
263  ** Description        This function convert USERIAL baud to line speed.
264  **
265  ** Output Parameter   None
266  **
267  ** Returns            line speed
268  **
269  *******************************************************************************/
270 UDRV_API extern UINT32 USERIAL_GetLineSpeed(UINT8 baud);
271 /*******************************************************************************
272  **
273  ** Function           USERIAL_GetBaud
274  **
275  ** Description        This function convert line speed to USERIAL baud.
276  **
277  ** Output Parameter   None
278  **
279  ** Returns            line speed
280  **
281  *******************************************************************************/
282 UDRV_API extern UINT8 USERIAL_GetBaud(UINT32 line_speed);
283 
284 #ifdef __cplusplus
285 }
286 #endif
287 
288 #endif /* USERIAL_H */
289