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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libchip/] [serial/] [z85c30_p.h] - Blame information for rev 307

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *  This include file contains all private driver definitions for the
3
 *  Zilog z85c30.
4
 *
5
 *  COPYRIGHT (c) 1998 by Radstone Technology
6
 *
7
 *
8
 * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY
9
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
10
 * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
11
 * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU.
12
 *
13
 * You are hereby granted permission to use, copy, modify, and distribute
14
 * this file, provided that this notice, plus the above copyright notice
15
 * and disclaimer, appears in all copies. Radstone Technology will provide
16
 * no support for this code.
17
 *
18
 *  COPYRIGHT (c) 1989-1997.
19
 *  On-Line Applications Research Corporation (OAR).
20
 *  Copyright assigned to U.S. Government, 1994.
21
 *
22
 *  The license and distribution terms for this file may in
23
 *  the file LICENSE in this distribution or at
24
 *  http://www.OARcorp.com/rtems/license.html.
25
 *
26
 *  $Id: z85c30_p.h,v 1.2 2001-09-27 12:01:42 chris Exp $
27
 */
28
 
29
#ifndef __Z85C30_P_H
30
#define __Z85C30_P_H
31
 
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
 
36
/*
37
 *  Define Z85C30_STATIC to nothing while debugging so the entry points
38
 *  will show up in the symbol table.
39
 */
40
 
41
#define Z85C30_STATIC
42
 
43
/* #define Z85C30_STATIC static */
44
 
45
/* bit values for write register 0 */
46
/* command register */
47
 
48
#define SCC_WR0_SEL_WR0   0x00
49
#define SCC_WR0_SEL_WR1   0x01
50
#define SCC_WR0_SEL_WR2   0x02
51
#define SCC_WR0_SEL_WR3   0x03
52
#define SCC_WR0_SEL_WR4   0x04
53
#define SCC_WR0_SEL_WR5   0x05
54
#define SCC_WR0_SEL_WR6   0x06
55
#define SCC_WR0_SEL_WR7   0x07
56
#define SCC_WR0_SEL_WR8   0x08
57
#define SCC_WR0_SEL_WR9   0x09
58
#define SCC_WR0_SEL_WR10  0x0a
59
#define SCC_WR0_SEL_WR11  0x0b
60
#define SCC_WR0_SEL_WR12  0x0c
61
#define SCC_WR0_SEL_WR13  0x0d
62
#define SCC_WR0_SEL_WR14  0x0e
63
#define SCC_WR0_SEL_WR15  0x0f
64
#define SCC_WR0_SEL_RD0   0x00
65
#define SCC_WR0_SEL_RD1   0x01
66
#define SCC_WR0_SEL_RD2   0x02
67
#define SCC_WR0_SEL_RD3   0x03
68
#define SCC_WR0_SEL_RD4   0x04
69
#define SCC_WR0_SEL_RD5   0x05
70
#define SCC_WR0_SEL_RD6   0x06
71
#define SCC_WR0_SEL_RD7   0x07
72
#define SCC_WR0_SEL_RD8   0x08
73
#define SCC_WR0_SEL_RD9   0x09
74
#define SCC_WR0_SEL_RD10  0x0a
75
#define SCC_WR0_SEL_RD11  0x0b
76
#define SCC_WR0_SEL_RD12  0x0c
77
#define SCC_WR0_SEL_RD13  0x0d
78
#define SCC_WR0_SEL_RD14  0x0e
79
#define SCC_WR0_SEL_RD15  0x0f
80
#define SCC_WR0_NULL_CODE 0x00
81
#define SCC_WR0_RST_INT   0x10
82
#define SCC_WR0_SEND_ABORT  0x18
83
#define SCC_WR0_EN_INT_RX 0x20
84
#define SCC_WR0_RST_TX_INT  0x28
85
#define SCC_WR0_ERR_RST   0x30
86
#define SCC_WR0_RST_HI_IUS  0x38
87
#define SCC_WR0_RST_RX_CRC  0x40
88
#define SCC_WR0_RST_TX_CRC  0x80
89
#define SCC_WR0_RST_TX_UND  0xc0
90
 
91
/* write register 2 */
92
/* interrupt vector */
93
 
94
/* bit values for write register 1 */
95
/* tx/rx interrupt and data transfer mode definition */
96
 
97
#define SCC_WR1_EXT_INT_EN  0x01
98
#define SCC_WR1_TX_INT_EN   0x02
99
#define SCC_WR1_PARITY      0x04
100
#define SCC_WR1_RX_INT_DIS  0x00
101
#define SCC_WR1_RX_INT_FIR  0x08
102
#define SCC_WR1_INT_ALL_RX  0x10
103
#define SCC_WR1_RX_INT_SPE  0x18
104
#define SCC_WR1_RDMA_RECTR  0x20
105
#define SCC_WR1_RDMA_FUNC   0x40
106
#define SCC_WR1_RDMA_EN     0x80
107
 
108
#define SCC_ENABLE_ALL_INTR \
109
    (SCC_WR1_EXT_INT_EN | SCC_WR1_TX_INT_EN | SCC_WR1_INT_ALL_RX)
110
 
111
#define SCC_DISABLE_ALL_INTR 0x00
112
 
113
#define SCC_ENABLE_ALL_INTR_EXCEPT_TX \
114
    (SCC_WR1_EXT_INT_EN | SCC_WR1_INT_ALL_RX)
115
 
116
/* bit values for write register 3 */
117
/* receive parameters and control */
118
 
119
#define SCC_WR3_RX_EN   0x01
120
#define SCC_WR3_SYNC_CHAR 0x02
121
#define SCC_WR3_ADR_SEARCH  0x04
122
#define SCC_WR3_RX_CRC_EN 0x08
123
#define SCC_WR3_ENTER_HUNT  0x10
124
#define SCC_WR3_AUTO_EN   0x20
125
#define SCC_WR3_RX_5_BITS 0x00
126
#define SCC_WR3_RX_7_BITS 0x40
127
#define SCC_WR3_RX_6_BITS 0x80
128
#define SCC_WR3_RX_8_BITS 0xc0
129
 
130
/* bit values for write register 4 */
131
/* tx/rx misc parameters and modes */
132
 
133
#define SCC_WR4_PAR_EN    0x01
134
#define SCC_WR4_PAR_EVEN  0x02
135
#define SCC_WR4_SYNC_EN   0x00
136
#define SCC_WR4_1_STOP    0x04
137
#define SCC_WR4_2_STOP    0x0c
138
#define SCC_WR4_8_SYNC    0x00
139
#define SCC_WR4_16_SYNC   0x10
140
#define SCC_WR4_SDLC    0x20
141
#define SCC_WR4_EXT_SYNC  0x30
142
#define SCC_WR4_1_CLOCK   0x00
143
#define SCC_WR4_16_CLOCK  0x40
144
#define SCC_WR4_32_CLOCK  0x80
145
#define SCC_WR4_64_CLOCK  0xc0
146
 
147
/* bit values for write register 5 */
148
/* transmit parameter and controls */
149
 
150
#define SCC_WR5_TX_CRC_EN 0x01
151
#define SCC_WR5_RTS   0x02
152
#define SCC_WR5_SDLC    0x04
153
#define SCC_WR5_TX_EN   0x08
154
#define SCC_WR5_SEND_BRK  0x10
155
 
156
#define SCC_WR5_TX_5_BITS 0x00
157
#define SCC_WR5_TX_7_BITS 0x20
158
#define SCC_WR5_TX_6_BITS 0x40
159
#define SCC_WR5_TX_8_BITS 0x60
160
#define SCC_WR5_DTR   0x80
161
 
162
/* write register 6 */
163
/* sync chars or sdlc address field */
164
 
165
/* write register 7 */
166
/* sync char or sdlc flag */
167
 
168
/* write register 8 */
169
/* transmit buffer */
170
 
171
/* bit values for write register 9 */
172
/* master interrupt control */
173
 
174
#define SCC_WR9_VIS   0x01
175
#define SCC_WR9_NV    0x02
176
#define SCC_WR9_DLC   0x04
177
#define SCC_WR9_MIE   0x08
178
#define SCC_WR9_STATUS_HI 0x10
179
#define SCC_WR9_NO_RST    0x00
180
#define SCC_WR9_CH_B_RST  0x40
181
#define SCC_WR9_CH_A_RST  0x80
182
#define SCC_WR9_HDWR_RST  0xc0
183
 
184
/* bit values for write register 10 */
185
/* misc tx/rx control bits */
186
 
187
#define SCC_WR10_6_BIT_SYNC 0x01
188
#define SCC_WR10_LOOP_MODE  0x02
189
#define SCC_WR10_ABORT_UND  0x04
190
#define SCC_WR10_MARK_IDLE  0x08
191
#define SCC_WR10_ACT_POLL 0x10
192
#define SCC_WR10_NRZ    0x00
193
#define SCC_WR10_NRZI   0x20
194
#define SCC_WR10_FM1    0x40
195
#define SCC_WR10_FM0    0x60
196
#define SCC_WR10_CRC_PRESET 0x80
197
 
198
/* bit values for write register 11 */
199
/* clock mode control */
200
 
201
#define SCC_WR11_OUT_XTAL 0x00
202
#define SCC_WR11_OUT_TX_CLK 0x01
203
#define SCC_WR11_OUT_BR_GEN 0x02
204
#define SCC_WR11_OUT_DPLL 0x03
205
#define SCC_WR11_TRXC_OI  0x04
206
#define SCC_WR11_TX_RTXC  0x00
207
#define SCC_WR11_TX_TRXC  0x08
208
#define SCC_WR11_TX_BR_GEN  0x10
209
#define SCC_WR11_TX_DPLL  0x18
210
#define SCC_WR11_RX_RTXC  0x00
211
#define SCC_WR11_RX_TRXC  0x20
212
#define SCC_WR11_RX_BR_GEN  0x40
213
#define SCC_WR11_RX_DPLL  0x60
214
#define SCC_WR11_RTXC_XTAL  0x80
215
 
216
/* write register 12 */
217
/* lower byte of baud rate generator time constant */
218
 
219
/* write register 13 */
220
/* upper byte of baud rate generator time constant */
221
 
222
/* bit values for write register 14 */
223
/* misc control bits */
224
 
225
#define SCC_WR14_BR_EN    0x01
226
#define SCC_WR14_BR_SRC   0x02
227
#define SCC_WR14_DTR_FUNC 0x04
228
#define SCC_WR14_AUTO_ECHO  0x08
229
#define SCC_WR14_LCL_LOOP 0x10
230
#define SCC_WR14_NULL   0x00
231
#define SCC_WR14_SEARCH   0x20
232
#define SCC_WR14_RST_CLK  0x40
233
#define SCC_WR14_DIS_DPLL 0x60
234
#define SCC_WR14_SRC_BR   0x80
235
#define SCC_WR14_SRC_RTXC 0xa0
236
#define SCC_WR14_FM_MODE  0xc0
237
#define SCC_WR14_NRZI   0xe0
238
 
239
/* bit values for write register 15 */
240
/* external/status interrupt control */
241
 
242
#define SCC_WR15_ZERO_CNT 0x02
243
#define SCC_WR15_CD_IE    0x08
244
#define SCC_WR15_SYNC_IE  0x10
245
#define SCC_WR15_CTS_IE   0x20
246
#define SCC_WR15_TX_UND_IE  0x40
247
#define SCC_WR15_BREAK_IE 0x80
248
 
249
/* bit values for read register 0 */
250
/* tx/rx buffer status and external status  */
251
 
252
#define SCC_RR0_RX_AVAIL  0x01
253
#define SCC_RR0_ZERO_CNT  0x02
254
#define SCC_RR0_TX_EMPTY  0x04
255
#define SCC_RR0_CD    0x08
256
#define SCC_RR0_SYNC    0x10
257
#define SCC_RR0_CTS   0x20
258
#define SCC_RR0_TX_UND    0x40
259
#define SCC_RR0_BREAK   0x80
260
 
261
/* bit values for read register 1 */
262
 
263
#define SCC_RR1_ALL_SENT  0x01
264
#define SCC_RR1_RES_CD_2  0x02
265
#define SCC_RR1_RES_CD_1  0x01
266
#define SCC_RR1_RES_CD_0  0x08
267
#define SCC_RR1_PAR_ERR   0x10
268
#define SCC_RR1_RX_OV_ERR 0x20
269
#define SCC_RR1_CRC_ERR   0x40
270
#define SCC_RR1_END_FRAME 0x80
271
 
272
/* read register 2 */
273
/* interrupt vector */
274
 
275
/* bit values for read register 3 */
276
/* interrupt pending register */
277
 
278
#define SCC_RR3_B_EXT_IP  0x01
279
#define SCC_RR3_B_TX_IP   0x02
280
#define SCC_RR3_B_RX_IP   0x04
281
#define SCC_RR3_A_EXT_IP  0x08
282
#define SCC_RR3_A_TX_IP   0x10
283
#define SCC_RR3_A_RX_IP   0x20
284
 
285
/* read register 8 */
286
/* receive data register */
287
 
288
/* bit values for read register 10 */
289
/* misc status bits */
290
 
291
#define SCC_RR10_ON_LOOP  0x02
292
#define SCC_RR10_LOOP_SEND  0x10
293
#define SCC_RR10_2_CLK_MIS  0x40
294
#define SCC_RR10_1_CLK_MIS  0x80
295
 
296
/* read register 12 */
297
/* lower byte of time constant */
298
 
299
/* read register 13 */
300
/* upper byte of time constant */
301
 
302
/* bit values for read register 15 */
303
/* external/status ie bits */
304
 
305
#define SCC_RR15_ZERO_CNT 0x02
306
#define SCC_RR15_CD_IE    0x08
307
#define SCC_RR15_SYNC_IE  0x10
308
#define SCC_RR15_CTS_IE   0x20
309
#define SCC_RR15_TX_UND_IE  0x40
310
#define SCC_RR15_BREAK_IE 0x80
311
 
312
typedef struct _z85c30_context
313
{
314
  unsigned8 ucModemCtrl;
315
} z85c30_context;
316
 
317
/*
318
 * The following macro calculates the Baud constant. For the Z85C30 chip.
319
 *
320
 * Note: baud constant = ((clock frequency / Clock_X) / (2 * Baud Rate)) - 2
321
 *       eg ((10,000,000 / 16) / (2 * Baud Rate)) - 2
322
 */
323
 
324
#define Z85C30_Baud( _clock, _baud_rate  )   \
325
  ( ((_clock) /(  16 * 2 * _baud_rate))  - 2)
326
 
327
#define Z85C30_Status_Is_RX_character_available(_status) \
328
  ((_status) & SCC_RR0_RX_AVAIL)
329
 
330
#define Z85C30_Status_Is_TX_buffer_empty(_status) \
331
  ((_status) & SCC_RR0_TX_EMPTY)
332
 
333
#define Z85C30_Status_Is_CTS_asserted(_status) \
334
  ((_status) & SCC_RR0_CTS)
335
 
336
#define Z85C30_Status_Is_break_abort(_status) \
337
  ((_status) & SCC_RR0_BREAK)
338
 
339
/*
340
 * Private routines
341
 */
342
 
343
Z85C30_STATIC void z85c30_init(int minor);
344
 
345
Z85C30_STATIC int z85c30_set_attributes(
346
  int                   minor,
347
  const struct termios *t
348
);
349
 
350
Z85C30_STATIC int z85c30_open(
351
  int major,
352
  int minor,
353
  void  * arg
354
);
355
 
356
Z85C30_STATIC int z85c30_close(
357
  int major,
358
  int minor,
359
  void  * arg
360
);
361
 
362
Z85C30_STATIC void z85c30_write_polled(
363
  int   minor,
364
  char  cChar
365
);
366
 
367
Z85C30_STATIC int z85c30_assert_RTS(
368
  int minor
369
);
370
 
371
Z85C30_STATIC int z85c30_negate_RTS(
372
  int minor
373
);
374
 
375
Z85C30_STATIC int z85c30_assert_DTR(
376
  int minor
377
);
378
 
379
Z85C30_STATIC int z85c30_negate_DTR(
380
  int minor
381
);
382
 
383
Z85C30_STATIC void z85c30_initialize_interrupts(int minor);
384
 
385
Z85C30_STATIC int z85c30_write_support_int(
386
  int   minor,
387
  const char *buf,
388
  int   len
389
);
390
 
391
Z85C30_STATIC int z85c30_write_support_polled(
392
  int   minor,
393
  const char *buf,
394
  int   len
395
);
396
 
397
Z85C30_STATIC int z85c30_inbyte_nonblocking_polled(
398
  int minor
399
);
400
 
401
Z85C30_STATIC void z85c30_enable_interrupts(
402
  int minor,
403
  int interrupt_mask
404
);
405
 
406
#ifdef __cplusplus
407
}
408
#endif
409
 
410
#endif

powered by: WebSVN 2.1.0

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