]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/io/serial/v2_0/include/serialio.h
Initial revision
[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 } cyg_serial_baud_rate_t;
91 #define CYGNUM_SERIAL_BAUD_MIN CYGNUM_SERIAL_BAUD_50 
92 #define CYGNUM_SERIAL_BAUD_MAX CYGNUM_SERIAL_BAUD_230400
93
94 // Note: two levels of macro are required to get proper expansion.
95 #define _CYG_SERIAL_BAUD_RATE(n) CYGNUM_SERIAL_BAUD_##n
96 #define CYG_SERIAL_BAUD_RATE(n) _CYG_SERIAL_BAUD_RATE(n)
97
98 // Stop bit selections
99 typedef enum {
100     CYGNUM_SERIAL_STOP_1 = 1,
101     CYGNUM_SERIAL_STOP_1_5,
102     CYGNUM_SERIAL_STOP_2
103 } cyg_serial_stop_bits_t;
104
105 // Parity modes
106 typedef enum {
107     CYGNUM_SERIAL_PARITY_NONE = 0,
108     CYGNUM_SERIAL_PARITY_EVEN,
109     CYGNUM_SERIAL_PARITY_ODD,
110     CYGNUM_SERIAL_PARITY_MARK,
111     CYGNUM_SERIAL_PARITY_SPACE
112 } cyg_serial_parity_t;
113
114 // Word length
115 typedef enum {
116     CYGNUM_SERIAL_WORD_LENGTH_5 = 5,
117     CYGNUM_SERIAL_WORD_LENGTH_6,
118     CYGNUM_SERIAL_WORD_LENGTH_7,
119     CYGNUM_SERIAL_WORD_LENGTH_8
120 } cyg_serial_word_length_t;
121
122 typedef struct {
123     cyg_serial_baud_rate_t   baud;
124     cyg_serial_stop_bits_t   stop;
125     cyg_serial_parity_t      parity;
126     cyg_serial_word_length_t word_length;
127     cyg_uint32               flags;
128 } cyg_serial_info_t;
129
130 // cyg_serial_info_t flags
131 #define CYGNUM_SERIAL_FLOW_NONE              (0)
132 // receive flow control, send xon/xoff when necessary:
133 #define CYGNUM_SERIAL_FLOW_XONXOFF_RX        (1<<0)  
134 // transmit flow control, act on received xon/xoff:
135 #define CYGNUM_SERIAL_FLOW_XONXOFF_TX        (1<<1)
136 // receive flow control, send RTS when necessary:
137 #define CYGNUM_SERIAL_FLOW_RTSCTS_RX         (1<<2)
138 // transmit flow control, act when not CTS:
139 #define CYGNUM_SERIAL_FLOW_RTSCTS_TX         (1<<3)
140 // receive flow control, send DTR when necessary:
141 #define CYGNUM_SERIAL_FLOW_DSRDTR_RX         (1<<4)
142 // transmit flow control, act when not DSR:
143 #define CYGNUM_SERIAL_FLOW_DSRDTR_TX         (1<<5)
144
145 // arguments for CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE
146 #define CYGNUM_SERIAL_FLOW_THROTTLE_RX       0
147 #define CYGNUM_SERIAL_FLOW_RESTART_RX        1
148 #define CYGNUM_SERIAL_FLOW_THROTTLE_TX       2
149 #define CYGNUM_SERIAL_FLOW_RESTART_TX        3
150
151 // arguments for CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE
152 #define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE     0
153 #define CYGNUM_SERIAL_FLOW_HW_THROTTLE       0
154 #define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE     0
155
156 typedef struct {  
157     cyg_int32 rx_bufsize;
158     cyg_int32 rx_count;
159     cyg_int32 tx_bufsize;
160     cyg_int32 tx_count;
161 } cyg_serial_buf_info_t;
162
163 #define CYG_SERIAL_INFO_INIT(_baud,_stop,_parity,_word_length,_flags) \
164   { _baud, _stop, _parity, _word_length, _flags}
165
166 #ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
167
168 # define CYGNUM_SERIAL_STATUS_FLOW          0
169 # define CYGNUM_SERIAL_STATUS_BREAK         1
170 # define CYGNUM_SERIAL_STATUS_FRAMEERR      2
171 # define CYGNUM_SERIAL_STATUS_PARITYERR     3
172 # define CYGNUM_SERIAL_STATUS_OVERRUNERR    4
173 # define CYGNUM_SERIAL_STATUS_CARRIERDETECT 5
174 # define CYGNUM_SERIAL_STATUS_RINGINDICATOR 6
175
176 typedef struct {
177     cyg_uint32 which;        // one of CYGNUM_SERIAL_STATUS_* above
178     cyg_uint32 value;        // and its value
179 } cyg_serial_line_status_t;
180
181 typedef void (*cyg_serial_line_status_callback_fn_t)(
182                                                  cyg_serial_line_status_t *s,
183                                                  CYG_ADDRWORD priv );
184 typedef struct {
185     cyg_serial_line_status_callback_fn_t fn;
186     CYG_ADDRWORD priv;
187 } cyg_serial_line_status_callback_t;
188
189 #endif // ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
190
191 // Default configuration
192 #define CYG_SERIAL_BAUD_DEFAULT        CYGNUM_SERIAL_BAUD_38400
193 #define CYG_SERIAL_STOP_DEFAULT        CYGNUM_SERIAL_STOP_1
194 #define CYG_SERIAL_PARITY_DEFAULT      CYGNUM_SERIAL_PARITY_NONE
195 #define CYG_SERIAL_WORD_LENGTH_DEFAULT CYGNUM_SERIAL_WORD_LENGTH_8
196
197 #ifdef CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_XONXOFF
198 # define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_XONXOFF_RX|CYGNUM_SERIAL_FLOW_XONXOFF_TX)
199 #elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_RTSCTS)
200 # define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX)
201 #elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_DSRDTR)
202 # define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_DSRDTR_RX|CYGNUM_SERIAL_FLOW_DSRDTR_TX)
203 #else 
204 # define CYG_SERIAL_FLAGS_DEFAULT      0
205 #endif
206
207 #ifdef __cplusplus
208 }
209 #endif
210
211 #endif  /* CYGONCE_SERIALIO_H */
212 /* EOF serialio.h */