]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/io/serial/v2_0/include/serialio.h
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / io / serial / v2_0 / include / serialio.h
1 #ifndef CYGONCE_SERIALIO_H
2 #define CYGONCE_SERIALIO_H
3 // ====================================================================
4 //
5 //      serialio.h
6 //
7 //      Device I/O 
8 //
9 // ====================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
18 //
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 // for more details.
23 //
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 //
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
34 //
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
37 //
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 // ====================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):   gthomas
46 // Contributors:        gthomas
47 // Date:        1999-02-04
48 // Purpose:     Special support for serial I/O devices
49 // Description:
50 //
51 //####DESCRIPTIONEND####
52 //
53 // ====================================================================
54
55 // This file contains the user-level visible I/O interfaces
56
57 #include <pkgconf/system.h>
58 #include <pkgconf/io_serial.h>
59 #include <pkgconf/hal.h>
60 #include <cyg/infra/cyg_type.h>
61 #include <cyg/io/config_keys.h>
62
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66
67 // Supported baud rates
68 typedef enum {
69     CYGNUM_SERIAL_BAUD_50 = 1,
70     CYGNUM_SERIAL_BAUD_75,
71     CYGNUM_SERIAL_BAUD_110,
72     CYGNUM_SERIAL_BAUD_134_5,
73     CYGNUM_SERIAL_BAUD_150,
74     CYGNUM_SERIAL_BAUD_200,
75     CYGNUM_SERIAL_BAUD_300,
76     CYGNUM_SERIAL_BAUD_600,
77     CYGNUM_SERIAL_BAUD_1200,
78     CYGNUM_SERIAL_BAUD_1800,
79     CYGNUM_SERIAL_BAUD_2400,
80     CYGNUM_SERIAL_BAUD_3600,
81     CYGNUM_SERIAL_BAUD_4800,
82     CYGNUM_SERIAL_BAUD_7200,
83     CYGNUM_SERIAL_BAUD_9600,
84     CYGNUM_SERIAL_BAUD_14400,
85     CYGNUM_SERIAL_BAUD_19200,
86     CYGNUM_SERIAL_BAUD_38400,
87     CYGNUM_SERIAL_BAUD_57600,
88     CYGNUM_SERIAL_BAUD_115200,
89     CYGNUM_SERIAL_BAUD_230400,
90     CYGNUM_SERIAL_BAUD_460800,
91     CYGNUM_SERIAL_BAUD_921600
92 } cyg_serial_baud_rate_t;
93 #define CYGNUM_SERIAL_BAUD_MIN CYGNUM_SERIAL_BAUD_50
94 #define CYGNUM_SERIAL_BAUD_MAX CYGNUM_SERIAL_BAUD_921600
95
96 // Note: two levels of macro are required to get proper expansion.
97 #define _CYG_SERIAL_BAUD_RATE(n) CYGNUM_SERIAL_BAUD_##n
98 #define CYG_SERIAL_BAUD_RATE(n) _CYG_SERIAL_BAUD_RATE(n)
99
100 // Stop bit selections
101 typedef enum {
102     CYGNUM_SERIAL_STOP_1 = 1,
103     CYGNUM_SERIAL_STOP_1_5,
104     CYGNUM_SERIAL_STOP_2
105 } cyg_serial_stop_bits_t;
106
107 // Parity modes
108 typedef enum {
109     CYGNUM_SERIAL_PARITY_NONE = 0,
110     CYGNUM_SERIAL_PARITY_EVEN,
111     CYGNUM_SERIAL_PARITY_ODD,
112     CYGNUM_SERIAL_PARITY_MARK,
113     CYGNUM_SERIAL_PARITY_SPACE
114 } cyg_serial_parity_t;
115
116 // Word length
117 typedef enum {
118     CYGNUM_SERIAL_WORD_LENGTH_5 = 5,
119     CYGNUM_SERIAL_WORD_LENGTH_6,
120     CYGNUM_SERIAL_WORD_LENGTH_7,
121     CYGNUM_SERIAL_WORD_LENGTH_8
122 } cyg_serial_word_length_t;
123
124 typedef struct {
125     cyg_serial_baud_rate_t   baud;
126     cyg_serial_stop_bits_t   stop;
127     cyg_serial_parity_t      parity;
128     cyg_serial_word_length_t word_length;
129     cyg_uint32               flags;
130 } cyg_serial_info_t;
131
132 // cyg_serial_info_t flags
133 #define CYGNUM_SERIAL_FLOW_NONE              (0)
134 // receive flow control, send xon/xoff when necessary:
135 #define CYGNUM_SERIAL_FLOW_XONXOFF_RX        (1<<0)  
136 // transmit flow control, act on received xon/xoff:
137 #define CYGNUM_SERIAL_FLOW_XONXOFF_TX        (1<<1)
138 // receive flow control, send RTS when necessary:
139 #define CYGNUM_SERIAL_FLOW_RTSCTS_RX         (1<<2)
140 // transmit flow control, act when not CTS:
141 #define CYGNUM_SERIAL_FLOW_RTSCTS_TX         (1<<3)
142 // receive flow control, send DTR when necessary:
143 #define CYGNUM_SERIAL_FLOW_DSRDTR_RX         (1<<4)
144 // transmit flow control, act when not DSR:
145 #define CYGNUM_SERIAL_FLOW_DSRDTR_TX         (1<<5)
146
147 // arguments for CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE
148 #define CYGNUM_SERIAL_FLOW_THROTTLE_RX       0
149 #define CYGNUM_SERIAL_FLOW_RESTART_RX        1
150 #define CYGNUM_SERIAL_FLOW_THROTTLE_TX       2
151 #define CYGNUM_SERIAL_FLOW_RESTART_TX        3
152
153 // arguments for CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE
154 #define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE     0
155 #define CYGNUM_SERIAL_FLOW_HW_THROTTLE       0
156 #define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE     0
157
158 typedef struct {  
159     cyg_int32 rx_bufsize;
160     cyg_int32 rx_count;
161     cyg_int32 tx_bufsize;
162     cyg_int32 tx_count;
163 } cyg_serial_buf_info_t;
164
165 #define CYG_SERIAL_INFO_INIT(_baud,_stop,_parity,_word_length,_flags) \
166   { _baud, _stop, _parity, _word_length, _flags}
167
168 #ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
169
170 # define CYGNUM_SERIAL_STATUS_FLOW          0
171 # define CYGNUM_SERIAL_STATUS_BREAK         1
172 # define CYGNUM_SERIAL_STATUS_FRAMEERR      2
173 # define CYGNUM_SERIAL_STATUS_PARITYERR     3
174 # define CYGNUM_SERIAL_STATUS_OVERRUNERR    4
175 # define CYGNUM_SERIAL_STATUS_CARRIERDETECT 5
176 # define CYGNUM_SERIAL_STATUS_RINGINDICATOR 6
177
178 typedef struct {
179     cyg_uint32 which;        // one of CYGNUM_SERIAL_STATUS_* above
180     cyg_uint32 value;        // and its value
181 } cyg_serial_line_status_t;
182
183 typedef void (*cyg_serial_line_status_callback_fn_t)(
184                                                  cyg_serial_line_status_t *s,
185                                                  CYG_ADDRWORD priv );
186 typedef struct {
187     cyg_serial_line_status_callback_fn_t fn;
188     CYG_ADDRWORD priv;
189 } cyg_serial_line_status_callback_t;
190
191 #endif // ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
192
193 // Default configuration
194 #define CYG_SERIAL_BAUD_DEFAULT        CYGNUM_SERIAL_BAUD_38400
195 #define CYG_SERIAL_STOP_DEFAULT        CYGNUM_SERIAL_STOP_1
196 #define CYG_SERIAL_PARITY_DEFAULT      CYGNUM_SERIAL_PARITY_NONE
197 #define CYG_SERIAL_WORD_LENGTH_DEFAULT CYGNUM_SERIAL_WORD_LENGTH_8
198
199 #ifdef CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_XONXOFF
200 # define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_XONXOFF_RX|CYGNUM_SERIAL_FLOW_XONXOFF_TX)
201 #elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_RTSCTS)
202 # define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX)
203 #elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_DSRDTR)
204 # define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_DSRDTR_RX|CYGNUM_SERIAL_FLOW_DSRDTR_TX)
205 #else 
206 # define CYG_SERIAL_FLAGS_DEFAULT      0
207 #endif
208
209 #ifdef __cplusplus
210 }
211 #endif
212
213 #endif  /* CYGONCE_SERIALIO_H */
214 /* EOF serialio.h */