OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [io/] [serial/] [v2_0/] [include/] [serialio.h] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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/hal.h>
58
#include <cyg/infra/cyg_type.h>
59
#include <cyg/io/config_keys.h>
60
 
61
#ifdef __cplusplus
62
extern "C" {
63
#endif
64
 
65
// Supported baud rates
66
typedef enum {
67
    CYGNUM_SERIAL_BAUD_50 = 1,
68
    CYGNUM_SERIAL_BAUD_75,
69
    CYGNUM_SERIAL_BAUD_110,
70
    CYGNUM_SERIAL_BAUD_134_5,
71
    CYGNUM_SERIAL_BAUD_150,
72
    CYGNUM_SERIAL_BAUD_200,
73
    CYGNUM_SERIAL_BAUD_300,
74
    CYGNUM_SERIAL_BAUD_600,
75
    CYGNUM_SERIAL_BAUD_1200,
76
    CYGNUM_SERIAL_BAUD_1800,
77
    CYGNUM_SERIAL_BAUD_2400,
78
    CYGNUM_SERIAL_BAUD_3600,
79
    CYGNUM_SERIAL_BAUD_4800,
80
    CYGNUM_SERIAL_BAUD_7200,
81
    CYGNUM_SERIAL_BAUD_9600,
82
    CYGNUM_SERIAL_BAUD_14400,
83
    CYGNUM_SERIAL_BAUD_19200,
84
    CYGNUM_SERIAL_BAUD_38400,
85
    CYGNUM_SERIAL_BAUD_57600,
86
    CYGNUM_SERIAL_BAUD_115200,
87
    CYGNUM_SERIAL_BAUD_230400
88
} cyg_serial_baud_rate_t;
89
#define CYGNUM_SERIAL_BAUD_MIN CYGNUM_SERIAL_BAUD_50 
90
#define CYGNUM_SERIAL_BAUD_MAX CYGNUM_SERIAL_BAUD_230400
91
 
92
// Note: two levels of macro are required to get proper expansion.
93
#define _CYG_SERIAL_BAUD_RATE(n) CYGNUM_SERIAL_BAUD_##n
94
#define CYG_SERIAL_BAUD_RATE(n) _CYG_SERIAL_BAUD_RATE(n)
95
 
96
// Stop bit selections
97
typedef enum {
98
    CYGNUM_SERIAL_STOP_1 = 1,
99
    CYGNUM_SERIAL_STOP_1_5,
100
    CYGNUM_SERIAL_STOP_2
101
} cyg_serial_stop_bits_t;
102
 
103
// Parity modes
104
typedef enum {
105
    CYGNUM_SERIAL_PARITY_NONE = 0,
106
    CYGNUM_SERIAL_PARITY_EVEN,
107
    CYGNUM_SERIAL_PARITY_ODD,
108
    CYGNUM_SERIAL_PARITY_MARK,
109
    CYGNUM_SERIAL_PARITY_SPACE
110
} cyg_serial_parity_t;
111
 
112
// Word length
113
typedef enum {
114
    CYGNUM_SERIAL_WORD_LENGTH_5 = 5,
115
    CYGNUM_SERIAL_WORD_LENGTH_6,
116
    CYGNUM_SERIAL_WORD_LENGTH_7,
117
    CYGNUM_SERIAL_WORD_LENGTH_8
118
} cyg_serial_word_length_t;
119
 
120
typedef struct {
121
    cyg_serial_baud_rate_t   baud;
122
    cyg_serial_stop_bits_t   stop;
123
    cyg_serial_parity_t      parity;
124
    cyg_serial_word_length_t word_length;
125
    cyg_uint32               flags;
126
} cyg_serial_info_t;
127
 
128
// cyg_serial_info_t flags
129
#define CYGNUM_SERIAL_FLOW_NONE              (0)
130
// receive flow control, send xon/xoff when necessary:
131
#define CYGNUM_SERIAL_FLOW_XONXOFF_RX        (1<<0)  
132
// transmit flow control, act on received xon/xoff:
133
#define CYGNUM_SERIAL_FLOW_XONXOFF_TX        (1<<1)
134
// receive flow control, send RTS when necessary:
135
#define CYGNUM_SERIAL_FLOW_RTSCTS_RX         (1<<2)
136
// transmit flow control, act when not CTS:
137
#define CYGNUM_SERIAL_FLOW_RTSCTS_TX         (1<<3)
138
// receive flow control, send DTR when necessary:
139
#define CYGNUM_SERIAL_FLOW_DSRDTR_RX         (1<<4)
140
// transmit flow control, act when not DSR:
141
#define CYGNUM_SERIAL_FLOW_DSRDTR_TX         (1<<5)
142
 
143
// arguments for CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE
144
#define CYGNUM_SERIAL_FLOW_THROTTLE_RX       0
145
#define CYGNUM_SERIAL_FLOW_RESTART_RX        1
146
#define CYGNUM_SERIAL_FLOW_THROTTLE_TX       2
147
#define CYGNUM_SERIAL_FLOW_RESTART_TX        3
148
 
149
// arguments for CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE
150
#define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE     0
151
#define CYGNUM_SERIAL_FLOW_HW_THROTTLE       0
152
#define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE     0
153
 
154
typedef struct {
155
    cyg_int32 rx_bufsize;
156
    cyg_int32 rx_count;
157
    cyg_int32 tx_bufsize;
158
    cyg_int32 tx_count;
159
} cyg_serial_buf_info_t;
160
 
161
#define CYG_SERIAL_INFO_INIT(_baud,_stop,_parity,_word_length,_flags) \
162
  { _baud, _stop, _parity, _word_length, _flags}
163
 
164
#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
165
 
166
# define CYGNUM_SERIAL_STATUS_FLOW          0
167
# define CYGNUM_SERIAL_STATUS_BREAK         1
168
# define CYGNUM_SERIAL_STATUS_FRAMEERR      2
169
# define CYGNUM_SERIAL_STATUS_PARITYERR     3
170
# define CYGNUM_SERIAL_STATUS_OVERRUNERR    4
171
# define CYGNUM_SERIAL_STATUS_CARRIERDETECT 5
172
# define CYGNUM_SERIAL_STATUS_RINGINDICATOR 6
173
 
174
typedef struct {
175
    cyg_uint32 which;        // one of CYGNUM_SERIAL_STATUS_* above
176
    cyg_uint32 value;        // and its value
177
} cyg_serial_line_status_t;
178
 
179
typedef void (*cyg_serial_line_status_callback_fn_t)(
180
                                                 cyg_serial_line_status_t *s,
181
                                                 CYG_ADDRWORD priv );
182
typedef struct {
183
    cyg_serial_line_status_callback_fn_t fn;
184
    CYG_ADDRWORD priv;
185
} cyg_serial_line_status_callback_t;
186
 
187
#endif // ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS
188
 
189
// Default configuration
190
#define CYG_SERIAL_BAUD_DEFAULT        CYGNUM_SERIAL_BAUD_38400
191
#define CYG_SERIAL_STOP_DEFAULT        CYGNUM_SERIAL_STOP_1
192
#define CYG_SERIAL_PARITY_DEFAULT      CYGNUM_SERIAL_PARITY_NONE
193
#define CYG_SERIAL_WORD_LENGTH_DEFAULT CYGNUM_SERIAL_WORD_LENGTH_8
194
 
195
#ifdef CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_XONXOFF
196
# define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_XONXOFF_RX|CYGNUM_SERIAL_FLOW_XONXOFF_TX)
197
#elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_RTSCTS)
198
# define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX)
199
#elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_DSRDTR)
200
# define CYG_SERIAL_FLAGS_DEFAULT      (CYGNUM_SERIAL_FLOW_DSRDTR_RX|CYGNUM_SERIAL_FLOW_DSRDTR_TX)
201
#else 
202
# define CYG_SERIAL_FLAGS_DEFAULT      0
203
#endif
204
 
205
#ifdef __cplusplus
206
}
207
#endif
208
 
209
#endif  /* CYGONCE_SERIALIO_H */
210
/* EOF serialio.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.