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