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