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