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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [serial/] [current/] [include/] [serialio.h] - Blame information for rev 834

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

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

powered by: WebSVN 2.1.0

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