comparison gpf/INC/dio.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 /*
2 +-----------------------------------------------------------------------------
3 | Copyright 2004 Texas Instruments Berlin, AG
4 | All rights reserved.
5 |
6 | This file is confidential and a trade secret of Texas
7 | Instruments Berlin, AG
8 | The receipt of or possession of this file does not convey
9 | any rights to reproduce or disclose its contents or to
10 | manufacture, use, or sell anything it may describe, in
11 | whole, or in part, without the specific written consent of
12 | Texas Instruments Berlin, AG.
13 +-----------------------------------------------------------------------------
14 | Purpose : General definitions of DIO driver interface
15 +-----------------------------------------------------------------------------
16 */
17
18 #ifndef __DIO_H__
19 #define __DIO_H__
20
21 /*==== INCLUDES =============================================================*/
22
23 #include "gdi.h"
24
25 /*==== DEFINITIONS ==========================================================*/
26
27 /*
28 * Device Type
29 */
30 #define DIO_DATA_SER 0x00800000 /* device can transfer serial data */
31 #define DIO_DATA_PKT 0x00400000 /* device can transfer packet data */
32 #define DIO_DATA_MUX 0x00200000 /* device can start a multiplexer */
33 #define DIO_TYPE_ID 0x0000FF00 /* id to separate different capabilities */
34
35 #define DIO_TYPE_SER (DIO_DATA_SER | 0x00000100) /* serial device */
36 #define DIO_TYPE_SER_MUX (DIO_DATA_SER | DIO_DATA_MUX | 0x00000100) /* mux device */
37 #define DIO_TYPE_PKT (DIO_DATA_PKT | 0x00000100) /* packet device */
38
39 /*
40 * Device Flags
41 */
42 #define DIO_FLAG_SLEEP 0x80000000 /* sleep state allowed */
43
44 /*
45 * Baud rates
46 */
47 #define DIO_BAUD_921600 0x00800000
48 #define DIO_BAUD_812500 0x00400000
49 #define DIO_BAUD_460800 0x00200000
50 #define DIO_BAUD_406250 0x00100000
51 #define DIO_BAUD_230400 0x00080000
52 #define DIO_BAUD_203125 0x00040000
53 #define DIO_BAUD_115200 0x00020000
54 #define DIO_BAUD_57600 0x00010000
55 #define DIO_BAUD_38400 0x00008000
56 #define DIO_BAUD_33900 0x00004000
57 #define DIO_BAUD_28800 0x00002000
58 #define DIO_BAUD_19200 0x00001000
59 #define DIO_BAUD_14400 0x00000800
60 #define DIO_BAUD_9600 0x00000400
61 #define DIO_BAUD_7200 0x00000200
62 #define DIO_BAUD_4800 0x00000100
63 #define DIO_BAUD_2400 0x00000080
64 #define DIO_BAUD_1200 0x00000040
65 #define DIO_BAUD_600 0x00000020
66 #define DIO_BAUD_300 0x00000010
67 #define DIO_BAUD_150 0x00000008
68 #define DIO_BAUD_110 0x00000004
69 #define DIO_BAUD_75 0x00000002
70 #define DIO_BAUD_AUTO 0x00000001 /* automatic baud rate detection */
71
72 /*
73 * Character framing
74 */
75 #define DIO_CF_7N1 0x00000800
76 #define DIO_CF_7S1 0x00000400
77 #define DIO_CF_7M1 0x00000200
78 #define DIO_CF_7E1 0x00000100
79 #define DIO_CF_7O1 0x00000080
80 #define DIO_CF_7N2 0x00000040
81 #define DIO_CF_8N1 0x00000020
82 #define DIO_CF_8S1 0x00000010
83 #define DIO_CF_8M1 0x00000008
84 #define DIO_CF_8E1 0x00000004
85 #define DIO_CF_8O1 0x00000002
86 #define DIO_CF_8N2 0x00000001
87
88 /*
89 * Types of flow control
90 */
91 #define DIO_FLOW_XTR_CTS 0x00000800 /* TX= transp. XON/XOFF RX=CTS */
92 #define DIO_FLOW_XTR_XOFF 0x00000400 /* TX= transp. XON/XOFF RX=XON/XOFF */
93 #define DIO_FLOW_XTR_NO 0x00000200 /* TX= transp. XON/XOFF RX=OFF */
94 #define DIO_FLOW_RTS_CTS 0x00000100 /* TX=RTS RX=CTS */
95 #define DIO_FLOW_RTS_XOFF 0x00000080 /* TX=RTS RX=XON/XOFF */
96 #define DIO_FLOW_RTS_NO 0x00000040 /* TX=RTS RX=OFF */
97 #define DIO_FLOW_XON_CTS 0x00000020 /* TX=XON/XOFF RX=CTS */
98 #define DIO_FLOW_XON_XOFF 0x00000010 /* TX=XON/XOFF RX=XON/XOFF */
99 #define DIO_FLOW_XON_NO 0x00000008 /* TX=XON/XOFF RX=OFF */
100 #define DIO_FLOW_NO_CTS 0x00000004 /* TX=OFF RX=CTS */
101 #define DIO_FLOW_NO_XOFF 0x00000002 /* TX=OFF RX=XON/XOFF */
102 #define DIO_FLOW_NONE 0x00000001 /* TX=OFF RX=OFF */
103
104 /*
105 * Serial device flags
106 */
107 #define DIO_FLAG_SER_ESC 0x80000000 /* device supports esc seq detection */
108
109 /*
110 * MUX mode
111 */
112 #define DIO_MUX_I 0x00000008 /* advanced option with I frames */
113 #define DIO_MUX_UI 0x00000004 /* advanced option with UI frames */
114 #define DIO_MUX_UIH 0x00000002 /* advanced option with UIH frames */
115 #define DIO_MUX_BASIC 0x00000001 /* basic option */
116
117 /*
118 * Sleep Mode
119 */
120 #define DIO_SLEEP_ENABLE 0x01 /* enter sleep mode if possible */
121 #define DIO_SLEEP_DISABLE 0x02 /* do not enter sleep mode */
122
123 /*
124 * Special Guard Period
125 */
126 #define DIO_ESC_OFF 0x0000 /* turn escape sequence detection off */
127
128 /*
129 * Device Mode
130 */
131 #define DIO_MODE_MUX 0x00000002 /* acts as 27.010 multiplexer device */
132 #define DIO_MODE_SER 0x00000001 /* acts as serial device */
133
134 /*
135 * Control Type
136 */
137 #define DIO_CTRL_LINES 0x0001 /* associated structure is T_DIO_CTRL_LINES */
138 #define DIO_CTRL_MUX 0x0002 /* associated structure is T_DIO_CTRL_MUX */
139
140 /*
141 * Line State definition & control structure.
142 */
143 #define DIO_SA 0x80000000 /* state: read=DTR write-DSR */
144 #define DIO_SB 0x40000000 /* state: read=RTS write=DCD */
145 #define DIO_X 0x20000000 /* state: read=RTS write=CTS */
146 #define DIO_RING 0x10000000 /* state: ring indicator */
147 #define DIO_ESC 0x08000000 /* state: escape sequence detested. */
148 #define DIO_MUX_STOPPED 0x04000000 /* multiplexer stopped */
149 #define DIO_BRK 0x02000000 /* state: break received/to be sent */
150 #define DIO_BRKLEN 0x000000FF /* state: break signal # of characters */
151
152 /*==== TYPES ================================================================*/
153
154 /*
155 * Device Capabilities
156 */
157 typedef struct
158 {
159 U32 device_type;
160 U32 device_flags;
161 U16 mtu_control;
162 U16 mtu_data;
163 char const *driver_name;
164 } T_DIO_CAP;
165
166 typedef struct
167 {
168 U32 device_type;
169 U32 device_flags;
170 U16 mtu_control;
171 U16 mtu_data;
172 char const *driver_name;
173 U32 baudrate_auto;
174 U32 baudrate_fixed;
175 U32 char_frame;
176 U32 flow_control;
177 U32 ser_flags;
178 } T_DIO_CAP_SER;
179
180 typedef struct
181 {
182 U32 device_type;
183 U32 device_flags;
184 U16 mtu_control;
185 U16 mtu_data;
186 char const *driver_name;
187 U32 baudrate_auto;
188 U32 baudrate_fixed;
189 U32 char_frame;
190 U32 flow_control;
191 U32 ser_flags;
192 U32 mux_mode;
193 } T_DIO_CAP_SER_MUX;
194
195 typedef struct
196 {
197 U32 device_type;
198 U32 device_flags;
199 U16 mtu_control;
200 U16 mtu_data;
201 char const *driver_name;
202 } T_DIO_CAP_PKT;
203
204 /*
205 * Device Control Block
206 */
207 typedef struct
208 {
209 U32 device_type; /*< 0: 4> device identifier with general capability information */
210 U8 sleep_mode; /*< 4: 1> enter sleep mode is possible or not */
211 U8 _align0; /*< 5: 1> alignment */
212 U8 _align1; /*< 6: 1> alignment */
213 U8 _align2; /*< 7: 1> alignment */
214 } T_DIO_DCB;
215
216 typedef struct
217 {
218 U32 device_type; /*< 0: 4> device identifier with general capability information */
219 U8 sleep_mode; /*< 4: 1> enter sleep mode is possible or not */
220 U8 _align0; /*< 5: 1> alignment */
221 U8 _align1; /*< 6: 1> alignment */
222 U8 _align2; /*< 7: 1> alignment */
223 U32 baudrate; /*< 8: 4> user set baudrate */
224 U32 char_frame; /*< 12: 4> supported character framing */
225 U32 flow_control; /*< 16: 4> supported modes of flow control */
226 U8 xon; /*< 20: 1> set/reset XON for flow control */
227 U8 xoff; /*< 21: 1> set/reset XOFF for flow control */
228 U8 esc_char; /*< 22: 1> ASCII character which is used in an escape sequence */
229 U8 _align3; /*< 23: 1> alignment */
230 U16 guard_period; /*< 24: 2> duration value for escape sequence */
231 U8 _align4; /*< 26: 1> alignment */
232 U8 _align5; /*< 27: 1> alignment */
233 } T_DIO_DCB_SER;
234
235 typedef struct
236 {
237 U32 device_type; /*< 0: 4> device identifier with general capability information */
238 U8 sleep_mode; /*< 4: 1> enter sleep mode is possible or not */
239 U8 _align0; /*< 5: 1> alignment */
240 U8 _align1; /*< 6: 1> alignment */
241 U8 _align2; /*< 7: 1> alignment */
242 U32 baudrate; /*< 8: 4> user set baudrate */
243 U32 char_frame; /*< 12: 4> supported character framing */
244 U32 flow_control; /*< 16: 4> supported modes of flow control */
245 U8 xon; /*< 20: 1> set/reset XON for flow control */
246 U8 xoff; /*< 21: 1> set/reset XOFF for flow control */
247 U8 esc_char; /*< 22: 1> ASCII character which is used in an escape sequence */
248 U8 _align3; /*< 23: 1> alignment */
249 U16 guard_period; /*< 24: 2> duration value for escape sequence */
250 U8 _align4; /*< 26: 1> alignment */
251 U8 _align5; /*< 27: 1> alignment */
252 U32 device_mode; /*< 28: 4> work mode of device */
253 U32 mux_mode; /*< 32: 4> supported multiplexer modes */
254 U16 n1; /*< 36: 2> max frame size of mux frame */
255 U8 n2; /*< 38: 1> max number of retransmissions */
256 U8 t1; /*< 39: 1> acknowledgement timer */
257 U8 t2; /*< 40: 1> response timer */
258 U8 t3; /*< 41: 1> wake up response timer */
259 U8 k; /*< 42: 1> windows size */
260 U8 _align6; /*< 43: 1> alignment */
261 } T_DIO_DCB_SER_MUX;
262
263 typedef struct
264 {
265 U32 device_type; /*< 0: 4> device identifier with general capability information */
266 U8 sleep_mode; /*< 4: 1> enter sleep mode is possible or not */
267 U8 _align0; /*< 5: 1> alignment */
268 U8 _align1; /*< 6: 1> alignment */
269 U8 _align2; /*< 7: 1> alignment */
270 } T_DIO_DCB_PKT;
271
272 /*
273 * Data Control
274 */
275 typedef struct
276 {
277 U16 control_type ;
278 U16 length ;
279 }T_DIO_CTRL ;
280
281 typedef struct
282 {
283 U16 control_type;
284 U16 length;
285 U32 state;
286 } T_DIO_CTRL_LINES;
287
288 typedef struct
289 {
290 U16 control_type ;
291 U16 length ;
292 U32 state;
293 }T_DIO_CTRL_MUX ;
294
295 /*
296 * DIO Data format.
297 */
298 typedef struct
299 {
300 U8 _align0; /*< 0: 1> alignment */
301 U8 _align1; /*< 1: 1> alignment */
302 U16 c_data; /*< 2: 2> counter */
303 U8 *ptr_data; /*< 4: 4> pointer to pointer to the first byte of the data buffer segment */
304 } T_dio_segment;
305
306 typedef struct
307 {
308 U16 length; /*< 0: 2> len of dio_ctrl */
309 U8 _align0; /*< 2: 1> alignment */
310 U8 c_dio_segment; /*< 3: 1> counter */
311 T_dio_segment *ptr_dio_segment; /*< 4: 4> pointer to Structured Element */
312 } T_dio_buffer;
313
314 /*==== PROTOTYPES ===========================================================*/
315
316 /*
317 +------------------------------------------------------------------------------
318 | Function : dio_init
319 +------------------------------------------------------------------------------
320 | Description : The function initializes the interface and the drivers.
321 |
322 | Parameters : none
323 |
324 | Return : DRV_OK - Initialization successful
325 | DRV_INITIALIZED - Interface already initialized
326 | DRV_INITFAILURE - Initialization failed
327 |
328 +------------------------------------------------------------------------------
329 */
330 extern U16 dio_init(void);
331
332 /*
333 +------------------------------------------------------------------------------
334 | Function : dio_user_init
335 +------------------------------------------------------------------------------
336 | Description : The function sets the signal callback of a DIO user.
337 |
338 | Parameters : user_name - DIO user name
339 | drv_handle - unique handle for this user
340 | signal_callback - callback function for this user
341 |
342 | Return : DRV_OK - Callback successfully set
343 | DRV_INVALID_PARAMS - The specified user does not exist
344 | DRV_INTERNAL_ERROR - Internal error
345 | DRV_NOTCONFIGURED - DIO interface is not yet initialized.
346 |
347 +------------------------------------------------------------------------------
348 */
349 extern U16 dio_user_init(char const * user_name,
350 U16 drv_handle,
351 T_DRV_CB_FUNC signal_callback);
352
353 /*
354 +------------------------------------------------------------------------------
355 | Function : dio_user_exit
356 +------------------------------------------------------------------------------
357 | Description : Termination of User Operation.
358 |
359 | Parameters : user_name - DIO user name
360 |
361 | Return : DRV_OK - User operation successfully terminated.
362 | DRV_INVALID_PARAMS - User operation can not be terminated yet.
363 | DRV_INTERNAL_ERROR - Internal error
364 |
365 +------------------------------------------------------------------------------
366 */
367 extern U16 dio_user_exit(char const * user_name);
368
369 /*
370 +------------------------------------------------------------------------------
371 | Function : dio_exit
372 +------------------------------------------------------------------------------
373 | Description : Termination of the Interface.
374 |
375 | Parameters : none
376 |
377 | Return : none
378 |
379 +------------------------------------------------------------------------------
380 */
381 extern void dio_exit(void);
382
383 /*
384 +------------------------------------------------------------------------------
385 | Function : dio_set_rx_buffer
386 +------------------------------------------------------------------------------
387 | Description : This function provides a receive buffer to the driver.
388 |
389 | Parameters : device - device number
390 | buffer - buffer to copy received data in it
391 |
392 | Return : DRV_OK - Function successful
393 | DRV_BUFFER_FULL - Buffer queue full.
394 | DRV_INVALID_PARAMS - The specified device does not exist or
395 | the data buffer is not big enough.
396 | DRV_INTERNAL_ERROR - Internal driver error
397 | DRV_NOTCONFIGURED - The device is not yet configured
398 |
399 +------------------------------------------------------------------------------
400 */
401 extern U16 dio_set_rx_buffer(U32 device,
402 T_dio_buffer * buffer);
403
404 /*
405 +------------------------------------------------------------------------------
406 | Function : dio_read
407 +------------------------------------------------------------------------------
408 | Description : This function returns a receive buffer and control information.
409 |
410 | Parameters : device - device number
411 | control_info - control information from the driver
412 | buffer - buffer with received data in it
413 |
414 | Return : DRV_OK - Function successful
415 | DRV_INVALID_PARAMS - The specified device does not exist
416 | DRV_INTERNAL_ERROR - Internal driver error
417 | DRV_NOTCONFIGURED - The device is not yet configured
418 |
419 +------------------------------------------------------------------------------
420 */
421 extern U16 dio_read(U32 device,
422 T_DIO_CTRL * control_info,
423 T_dio_buffer ** buffer);
424
425 /*
426 +------------------------------------------------------------------------------
427 | Function : dio_write
428 +------------------------------------------------------------------------------
429 | Description : This function provides a send buffer to the driver which
430 | contains data to send.
431 |
432 | Parameters : device - device number
433 | control_info - control information for the driver
434 | buffer - buffer with data to send
435 |
436 | Return : DRV_OK - Function successful
437 | DRV_BUFFER_FULL - Buffer queue full.
438 | DRV_INVALID_PARAMS - The specified device does not exist or
439 | the data buffer to big.
440 | DRV_INTERNAL_ERROR - Internal driver error
441 | DRV_NOTCONFIGURED - The device is not yet configured
442 |
443 +------------------------------------------------------------------------------
444 */
445 extern U16 dio_write(U32 device,
446 T_DIO_CTRL * control_info,
447 T_dio_buffer * buffer);
448
449 /*
450 +------------------------------------------------------------------------------
451 | Function : dio_get_tx_buffer
452 +------------------------------------------------------------------------------
453 | Description : This function returns a send buffer provided via dio_write().
454 |
455 | Parameters : device - device number
456 | buffer - return sent data buffer
457 |
458 | Return : DRV_OK - Function successful
459 | DRV_INVALID_PARAMS - The specified device does not exist
460 | DRV_INTERNAL_ERROR - Internal driver error
461 | DRV_NOTCONFIGURED - The device is not yet configured
462 |
463 +------------------------------------------------------------------------------
464 */
465 extern U16 dio_get_tx_buffer(U32 device,
466 T_dio_buffer ** buffer);
467
468 /*
469 +------------------------------------------------------------------------------
470 | Function : dio_clear
471 +------------------------------------------------------------------------------
472 | Description : This function is used to clear the hardware send buffer.
473 |
474 | Parameters : device - device number
475 |
476 | Return : DRV_OK - Function successful
477 | DRV_INVALID_PARAMS - The specified device does not exist
478 | DRV_INTERNAL_ERROR - Internal driver error
479 | DRV_NOTCONFIGURED - The device is not yet configured
480 | DRV_INPROCESS - The driver is busy clearing the buffer
481 |
482 +------------------------------------------------------------------------------
483 */
484 extern U16 dio_clear(U32 device);
485
486 /*
487 +------------------------------------------------------------------------------
488 | Function : dio_flush
489 +------------------------------------------------------------------------------
490 | Description : With this function the driver is requested to inform the
491 | user, when data of the hardware send buffer have been written
492 | successfully.
493 |
494 | Parameters : device - device number
495 |
496 | Return : DRV_OK - Function successful
497 | DRV_INVALID_PARAMS - The specified device does not exist
498 | DRV_INTERNAL_ERROR - Internal driver error
499 | DRV_NOTCONFIGURED - The device is not yet configured
500 | DRV_INPROCESS - The driver is busy flushing the buffer
501 |
502 +------------------------------------------------------------------------------
503 */
504 extern U16 dio_flush(U32 device);
505
506 /*
507 +------------------------------------------------------------------------------
508 | Function : dio_get_capabilities
509 +------------------------------------------------------------------------------
510 | Description : This function is used to retrieve the capabilities of a device.
511 |
512 | Parameters : device - device number
513 | capabilities - Return: Pointer to the device capabilities
514 |
515 | Return : DRV_OK - Function successful
516 | DRV_INVALID_PARAMS - The specified device does not exist
517 | DRV_INTERNAL_ERROR - Internal driver error
518 |
519 +------------------------------------------------------------------------------
520 */
521 extern U16 dio_get_capabilities(U32 device,
522 T_DIO_CAP ** capabilities);
523
524 /*
525 +------------------------------------------------------------------------------
526 | Function : dio_set_config
527 +------------------------------------------------------------------------------
528 | Description : This function is used to configure a device.
529 |
530 | Parameters : device - device number
531 | dcb - pointer to a device control block
532 |
533 | Return : DRV_OK - Function successful
534 | DRV_INVALID_PARAMS - parameter invalid or out of range
535 | DRV_INTERNAL_ERROR - Internal driver error
536 |
537 +------------------------------------------------------------------------------
538 */
539 extern U16 dio_set_config(U32 device,
540 T_DIO_DCB * dcb);
541
542 /*
543 +------------------------------------------------------------------------------
544 | Function : dio_get_config
545 +------------------------------------------------------------------------------
546 | Description : This function reads the device configuration.
547 |
548 | Parameters : device - device number
549 | dcb - pointer to a device control block
550 |
551 | Return : DRV_OK - Function successful
552 | DRV_INVALID_PARAMS - The specified device does not exist or
553 | wrong Device Control Block provided.
554 | DRV_INTERNAL_ERROR - Internal driver error
555 | DRV_NOTCONFIGURED - The device is not yet configured
556 |
557 +------------------------------------------------------------------------------
558 */
559 extern U16 dio_get_config(U32 device,
560 T_DIO_DCB * dcb);
561
562 /*
563 +------------------------------------------------------------------------------
564 | Function : dio_close_device
565 +------------------------------------------------------------------------------
566 | Description : This function is used to close a device.
567 |
568 | Parameters : device - device number
569 |
570 | Return : DRV_OK - Function successful
571 | DRV_INVALID_PARAMS - The specified device can not be closed yet
572 | DRV_INTERNAL_ERROR - Internal driver error
573 |
574 +------------------------------------------------------------------------------
575 */
576 extern U16 dio_close_device(U32 device);
577
578 #endif /* __DIO_H__ */