comparison gpf/inc/gsi.h @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 #ifndef GSI_H
2 #define GSI_H
3 /*
4 +-----------------------------------------------------------------------------
5 | Project :
6 | Modul :
7 +-----------------------------------------------------------------------------
8 | Copyright 2002 Texas Instruments Berlin, AG
9 | All rights reserved.
10 |
11 | This file is confidential and a trade secret of Texas
12 | Instruments Berlin, AG
13 | The receipt of or possession of this file does not convey
14 | any rights to reproduce or disclose its contents or to
15 | manufacture, use, or sell anything it may describe, in
16 | whole, or in part, without the specific written consent of
17 | Texas Instruments Berlin, AG.
18 +-----------------------------------------------------------------------------
19 | Purpose : These definitions provide a driver interface to multiple serial
20 | ports.
21 +-----------------------------------------------------------------------------
22 */
23
24
25 /*==== INCLUDES =============================================================*/
26
27 #include "gpfconf.h"
28 #include "gdi.h"
29
30 /*==== DEFINITIONS ==========================================================*/
31
32 /*
33 * Baud rates
34 */
35 #define GSI_BAUD_AUTO ( 1)
36 #define GSI_BAUD_75 ( 2)
37 #define GSI_BAUD_150 ( 3)
38 #define GSI_BAUD_300 ( 4)
39 #define GSI_BAUD_600 ( 5)
40 #define GSI_BAUD_1200 ( 6)
41 #define GSI_BAUD_2400 ( 7)
42 #define GSI_BAUD_4800 ( 8)
43 #define GSI_BAUD_7200 ( 9)
44 #define GSI_BAUD_9600 (10)
45 #define GSI_BAUD_14400 (11)
46 #define GSI_BAUD_19200 (12)
47 #define GSI_BAUD_28800 (13)
48 #define GSI_BAUD_33900 (14)
49 #define GSI_BAUD_38400 (15)
50 #define GSI_BAUD_57600 (16)
51 #define GSI_BAUD_115200 (17)
52 #define GSI_BAUD_203125 (18)
53 #define GSI_BAUD_406250 (19)
54 #define GSI_BAUD_812500 (20)
55
56 /*
57 * Bits per character
58 */
59 #define GSI_CHAR5 ( 5)
60 #define GSI_CHAR6 ( 6)
61 #define GSI_CHAR7 ( 7)
62 #define GSI_CHAR8 ( 8)
63
64 /*
65 * Stop bits
66 */
67 #define GSI_STOP1 ( 1)
68 #define GSI_STOP15 (15)
69 #define GSI_STOP2 ( 2)
70
71 /*
72 * Parity bit
73 */
74 #define GSI_PARITYNO ( 1)
75 #define GSI_PARITYODD ( 2)
76 #define GSI_PARITYEVEN ( 3)
77 #define GSI_PARITYSPACE ( 4)
78
79 /*
80 * Flow control
81 */
82 #define GSI_FLOWNO ( 1)
83 #define GSI_FLOWHW ( 2)
84 #define GSI_FLOWSW ( 3)
85
86 /*
87 * Bit positions
88 */
89 #define GSI_BRKLEN_POS ( 0)
90 #define GSI_BRK_POS (25)
91 #define GSI_DISC_POS (26)
92 #define GSI_ESC_POS (27)
93 #define GSI_RING_POS (28)
94 #define GSI_X_POS (29)
95 #define GSI_SB_POS (30)
96 #define GSI_SA_POS (31)
97
98 /*
99 * Bit masks
100 */
101 #define GSI_BRKLEN_MASK (255UL << GSI_BRKLEN_POS)
102 #define GSI_BRK_MASK (1UL << GSI_BRK_POS)
103 #define GSI_DISC_MASK (1UL << GSI_DISC_POS)
104 #define GSI_ESC_MASK (1UL << GSI_ESC_POS)
105 #define GSI_RING_MASK (1UL << GSI_RING_POS)
106 #define GSI_X_MASK (1UL << GSI_X_POS)
107 #define GSI_SB_MASK (1UL << GSI_SB_POS)
108 #define GSI_SA_MASK (1UL << GSI_SA_POS)
109
110 /*
111 * Size of the circular buffers used in the driver.
112 */
113 #define GSI_MAX_BUFFER_SIZE (512)
114
115 /*==== TYPES ================================================================*/
116
117 /*
118 * Device Control Block
119 */
120 typedef struct {
121 USHORT Baud;
122 UBYTE DataBits;
123 UBYTE StopBits;
124 UBYTE Parity;
125 UBYTE RxFlowControl;
126 UBYTE TxFlowControl;
127 USHORT RxBufferSize;
128 USHORT TxBufferSize;
129 USHORT RxThreshold;
130 USHORT TxThreshold;
131 UBYTE XON;
132 UBYTE XOFF;
133 UBYTE EscChar;
134 USHORT GuardPeriod;
135 } T_GSI_DCB;
136
137 /*==== FUNCTION PROTOTYPES ==================================================*/
138
139 #ifdef _TARGET_
140 /*
141 +------------------------------------------------------------------------------
142 | Function : GSI_Init
143 +------------------------------------------------------------------------------
144 | Description : The function initializes the module and the connected serial
145 | device.
146 |
147 | Parameters : DeviceNo - serial device number
148 | DrvHandle - unique handle for this device
149 | CallbackFunc - callback function for this device
150 | DrvInfo - pointer to the driver parameters
151 |
152 | Return : DRV_OK - Initialization successful
153 | DRV_INVALID_PARAMS - The specified device does not exist
154 | DRV_INTERNAL_ERROR - Internal driver error
155 | DRV_INITIALIZED - Driver already initialized
156 |
157 +------------------------------------------------------------------------------
158 */
159 extern USHORT GSI_Init (UBYTE DeviceNo,
160 USHORT DrvHANDLE,
161 T_DRV_CB_FUNC CallbackFunc,
162 T_DRV_EXPORT **DrvInfo);
163
164 /*
165 +------------------------------------------------------------------------------
166 | Function : GSI_Exit
167 +------------------------------------------------------------------------------
168 | Description : The function is called when the driver functionality is no
169 | longer required. The driver terminates regardless of any
170 | outstanding data to be sent.
171 |
172 | Parameters : DeviceNo - serial device number
173 |
174 | Return : no return value
175 |
176 +------------------------------------------------------------------------------
177 */
178 extern void GSI_Exit (UBYTE DeviceNo);
179
180 /*
181 +------------------------------------------------------------------------------
182 | Function : GSI_Read
183 +------------------------------------------------------------------------------
184 | Description : This function copies received data into a caller provided
185 | buffer and returns the line status. It should always return
186 | immediately after copying the data, without waiting for any
187 | more data.
188 |
189 | Parameters : DeviceNo - serial device number
190 | Buffer - buffer to copy the data
191 | Length - On call: size of Buffer; On return: copied bytes
192 | State - line states of the serial connection
193 |
194 | Return : DRV_OK - Function successful
195 | DRV_INVALID_PARAMS - The specified device does not exist
196 | DRV_INTERNAL_ERROR - Internal driver error
197 | DRV_NOTCONFIGURED - The driver is not yet configured
198 |
199 +------------------------------------------------------------------------------
200 */
201 extern USHORT GSI_Read (UBYTE DeviceNo,
202 void *Buffer,
203 USHORT *Length,
204 ULONG *State);
205
206 /*
207 +------------------------------------------------------------------------------
208 | Function : GSI_Write
209 +------------------------------------------------------------------------------
210 | Description : This functions copies the provided data into the buffer of the
211 | driver and sets the line states. This function must return
212 | immediately after copying, even if there is not enough space in
213 | the driver buffer to copy all provided data.
214 |
215 | Parameters : DeviceNo - serial device number
216 | Buffer - buffer containing the data
217 | Length - On call: size of data; On return: copied bytes
218 | State - line states of the serial connection
219 | Mask - manipulated State bits
220 |
221 | Return : DRV_OK - Function successful
222 | DRV_INVALID_PARAMS - The specified device does not exist
223 | DRV_INTERNAL_ERROR - Internal driver error
224 | DRV_NOTCONFIGURED - The driver is not yet configured
225 |
226 +------------------------------------------------------------------------------
227 */
228 extern USHORT GSI_Write (UBYTE DeviceNo,
229 void *Buffer,
230 USHORT *Length,
231 ULONG State,
232 ULONG Mask);
233
234 /*
235 +------------------------------------------------------------------------------
236 | Function : GSI_Look
237 +------------------------------------------------------------------------------
238 | Description : This function copies received data into a caller provided
239 | buffer without delete the data in the driver buffer. It should
240 | always return immediately after copying the data, without
241 | waiting for any more data.
242 |
243 | Parameters : DeviceNo - serial device number
244 | Buffer - buffer to copy the data
245 | Length - On call: size of Buffer; On return: copied bytes
246 | State - line states of the serial connection
247 |
248 | Return : DRV_OK - Function successful
249 | DRV_INVALID_PARAMS - The specified device does not exist
250 | DRV_INTERNAL_ERROR - Internal driver error
251 | DRV_NOTCONFIGURED - The driver is not yet configured
252 |
253 +------------------------------------------------------------------------------
254 */
255 extern USHORT GSI_Look (UBYTE DeviceNo,
256 void *Buffer,
257 USHORT *Length,
258 ULONG *State);
259
260 /*
261 +------------------------------------------------------------------------------
262 | Function : GSI_Clear
263 +------------------------------------------------------------------------------
264 | Description : This function is used to clear the device internal buffers.
265 |
266 | Parameters : DeviceNo - serial device number
267 | BufferType - buffer to be cleared
268 |
269 | Return : DRV_OK - Function successful
270 | DRV_INVALID_PARAMS - The specified device does not exist
271 | DRV_INTERNAL_ERROR - Internal driver error
272 | DRV_INPROCESS - The driver is busy clearing the buffers
273 |
274 +------------------------------------------------------------------------------
275 */
276 extern USHORT GSI_Clear (UBYTE DeviceNo,
277 USHORT BufferType);
278
279 /*
280 +------------------------------------------------------------------------------
281 | Function : GSI_Flush
282 +------------------------------------------------------------------------------
283 | Description : This function is used to flush the device internal transmit
284 | buffer.
285 |
286 | Parameters : DeviceNo - serial device number
287 |
288 | Return : DRV_OK - Function successful
289 | DRV_INVALID_PARAMS - The specified device does not exist
290 | DRV_INTERNAL_ERROR - Internal driver error
291 | DRV_INPROCESS - The driver is busy clearing the buffers
292 | DRV_NOTCONFIGURED - The driver is not yet configured
293 |
294 +------------------------------------------------------------------------------
295 */
296 extern USHORT GSI_Flush (UBYTE DeviceNo);
297
298 /*
299 +------------------------------------------------------------------------------
300 | Function : GSI_SetSignal
301 +------------------------------------------------------------------------------
302 | Description : This function enables indication signals from the driver. These
303 | signals are sent via the device callback function.
304 |
305 | Parameters : DeviceNo - serial device number
306 | SignalType - Signal type to be set
307 |
308 | Return : DRV_OK - Function successful
309 | DRV_INVALID_PARAMS - parameters out of range
310 | DRV_INTERNAL_ERROR - Internal driver error
311 | DRV_SIGFCT_NOTAVAILABLE - no event signaling functionality
312 |
313 +------------------------------------------------------------------------------
314 */
315 extern USHORT GSI_SetSignal (UBYTE DeviceNo,
316 USHORT SignalType);
317
318 /*
319 +------------------------------------------------------------------------------
320 | Function : GSI_ResetSignal
321 +------------------------------------------------------------------------------
322 | Description : This function disables indication signals from the driver.
323 |
324 | Parameters : DeviceNo - serial device number
325 | SignalType - Signal type to be reset
326 |
327 | Return : DRV_OK - Function successful
328 | DRV_INVALID_PARAMS - parameters out of range
329 | DRV_INTERNAL_ERROR - Internal driver error
330 | DRV_SIGFCT_NOTAVAILABLE - no event signaling functionality
331 |
332 +------------------------------------------------------------------------------
333 */
334 extern USHORT GSI_ResetSignal (UBYTE DeviceNo,
335 USHORT SignalType);
336
337 /*
338 +------------------------------------------------------------------------------
339 | Function : GSI_SetConfig
340 +------------------------------------------------------------------------------
341 | Description : This function configures the serial device.
342 |
343 | Parameters : DeviceNo - serial device number
344 | DCBPtr - pointer to the driver control block
345 |
346 | Return : DRV_OK - Function successful
347 | DRV_INVALID_PARAMS - parameters out of range
348 | DRV_INTERNAL_ERROR - Internal driver error
349 |
350 +------------------------------------------------------------------------------
351 */
352 extern USHORT GSI_SetConfig (UBYTE DeviceNo,
353 T_GSI_DCB *DCBPtr);
354
355 /*
356 +------------------------------------------------------------------------------
357 | Function : GSI_GetConfig
358 +------------------------------------------------------------------------------
359 | Description : This function reads the serial device configuration.
360 |
361 | Parameters : DeviceNo - serial device number
362 | DCBPtr - pointer to the driver control block
363 |
364 | Return : DRV_OK - Function successful
365 | DRV_INTERNAL_ERROR - Internal driver error
366 | DRV_NOTCONFIGURED - The driver is not yet configured
367 |
368 +------------------------------------------------------------------------------
369 */
370 extern USHORT GSI_GetConfig (UBYTE DeviceNo,
371 T_GSI_DCB *DCBPtr);
372
373 /*
374 +------------------------------------------------------------------------------
375 | Function : GSI_Callback
376 +------------------------------------------------------------------------------
377 | Description : This function is needed for cascaded drivers. This function
378 | must not be confused with the parameter CallbackFunc passed to
379 | GSI_Init().
380 |
381 | Parameters : Signal - pointer to the signal information data
382 |
383 | Return : no return value
384 |
385 +------------------------------------------------------------------------------
386 */
387 extern void GSI_Callback (T_DRV_SIGNAL *Signal);
388
389 #endif /* _TARGET_ */
390 #endif /* !GSI_H */