RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sci.h
1/****************************************************************************
2* File: sci.h
3*
4* Desc: This is the include file for the serial communications interface.
5*
6* Note: See bsp.h,confdefs.h,system.h for installing drivers into RTEMS.
7*
8****************************************************************************/
9
10#ifndef _sci_h_
11#define _sci_h_
12
13/*******************************************************************************
14 IOCTL commands for the sci driver.
15 I'm still working on these...
16*******************************************************************************/
17
18#define SCI_IOCTL_PARITY_NONE 0x00 /* no parity bit after the data bits */
19#define SCI_IOCTL_PARITY_ODD 0x01 /* parity bit added after data bits */
20#define SCI_IOCTL_PARITY_EVEN 0x02 /* parity bit added after data bits */
21#define SCI_IOCTL_PARITY_MARK 0x03 /* parity bit is lo, -12 volts, logical 1 */
22#define SCI_IOCTL_PARITY_SPACE 0x04 /* parity bit is hi, +12 volts, logical 0 */
23#define SCI_IOCTL_PARITY_FORCED_ON 0x03 /* parity bit is forced hi or lo */
24#define SCI_IOCTL_PARITY_FORCED_OFF 0x04 /* parity bit is forced hi or lo */
25
26#define SCI_IOCTL_BAUD_RATE 0x20 /* set the baud rate, arg is baud */
27
28#define SCI_IOCTL_DATA_BITS 0x30 /* set the data bits, arg is # bits */
29
30#define SCI_IOCTL_STOP_BITS_1 0x40 /* 1 stop bit after char frame */
31#define SCI_IOCTL_STOP_BITS_2 0x41 /* 2 stop bit after char frame */
32
33#define SCI_IOCTL_MODE_NORMAL 0x50 /* normal operating mode */
34#define SCI_IOCTL_MODE_LOOP 0x51 /* internal loopback mode */
35
36#define SCI_IOCTL_FLOW_NONE 0x60 /* no flow control */
37#define SCI_IOCTL_FLOW_RTS_CTS 0x61 /* hardware flow control */
38
39#define SCI_IOCTL_SEND_BREAK 0x70 /* send an rs-232 break */
40
41#define SCI_IOCTL_MODE_1200 0x80 /* 1200,n,8,1 download mode */
42#define SCI_IOCTL_MODE_9600 0x81 /* 9600,n,8,1 download mode */
43#define SCI_IOCTL_MODE_9_BIT 0x82 /* 9600,forced,8,1 command mode */
44
45
46/*******************************************************************************
47 SCI Registers
48*******************************************************************************/
49
50/* SCI Control Register 0 (SCCR0) $FFFC08
51
52 8 4 2 1 - 8 4 2 1 - 8 4 2 1 - 8 4 2 1
53 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
54 | | | | | | | | | | | | | | | |
55 | | | | | | | | | | | | | | | +----- 0 baud rate divisor
56 | | | | | | | | | | | | | | +------- 1 baud rate divisor
57 | | | | | | | | | | | | | +--------- 2 baud rate divisor
58 | | | | | | | | | | | | +----------- 3 baud rate divisor
59 | | | | | | | | | | | |
60 | | | | | | | | | | | +--------------- 4 baud rate divisor
61 | | | | | | | | | | +----------------- 5 baud rate divisor
62 | | | | | | | | | +------------------- 6 baud rate divisor
63 | | | | | | | | +--------------------- 7 baud rate divisor
64 | | | | | | | |
65 | | | | | | | +------------------------- 8 baud rate divisor
66 | | | | | | +--------------------------- 9 baud rate divisor
67 | | | | | +----------------------------- 10 baud rate divisor
68 | | | | +------------------------------- 11 baud rate divisor
69 | | | |
70 | | | +----------------------------------- 12 baud rate divisor
71 | | +------------------------------------- 13 unused
72 | +--------------------------------------- 14 unused
73 +----------------------------------------- 15 unused
74
75 0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 1 0 0 reset value - (64k baud?)
76 */
77
78#define SCI_BAUD_57_6K 9
79#define SCI_BAUD_38_4K 14
80#define SCI_BAUD_19_2K 27
81#define SCI_BAUD_9600 55
82#define SCI_BAUD_4800 109
83#define SCI_BAUD_2400 218
84#define SCI_BAUD_1200 437
85
86
87/* SCI Control Register 1 (SCCR1) $FFFC0A
88
89 8 4 2 1 - 8 4 2 1 - 8 4 2 1 - 8 4 2 1
90 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
91 | | | | | | | | | | | | | | | |
92 | | | | | | | | | | | | | | | +----- 0 send a break
93 | | | | | | | | | | | | | | +------- 1 rcvr wakeup mode
94 | | | | | | | | | | | | | +--------- 2 rcvr enable
95 | | | | | | | | | | | | +----------- 3 xmtr enable
96 | | | | | | | | | | | |
97 | | | | | | | | | | | +--------------- 4 idle line intr enable
98 | | | | | | | | | | +----------------- 5 rcvr intr enable
99 | | | | | | | | | +------------------- 6 xmit complete intr enable
100 | | | | | | | | +--------------------- 7 xmtr intr enable
101 | | | | | | | |
102 | | | | | | | +------------------------- 8 wakeup on address mark
103 | | | | | | +--------------------------- 9 mode 1=9 bits, 0=8 bits
104 | | | | | +----------------------------- 10 parity enable 1=on, 0=off
105 | | | | +------------------------------- 11 parity type 1=odd, 0=even
106 | | | |
107 | | | +----------------------------------- 12 idle line select
108 | | +------------------------------------- 13 wired-or mode
109 | +--------------------------------------- 14 loop mode
110 +----------------------------------------- 15 unused
111
112 0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 0 0 0 reset value
113*/
114
115#define SCI_SEND_BREAK 0x0001 /* 0000-0000-0000-0001 */
116#define SCI_RCVR_WAKEUP 0x0002 /* 0000-0000-0000-0010 */
117#define SCI_ENABLE_RCVR 0x0004 /* 0000-0000-0000-0100 */
118#define SCI_ENABLE_XMTR 0x0008 /* 0000-0000-0000-1000 */
119
120#define SCI_DISABLE_RCVR 0xFFFB /* 1111-1111-1111-1011 */
121#define SCI_DISABLE_XMTR 0xFFF7 /* 1111-1111-1111-0111 */
122
123#define SCI_ENABLE_INT_IDLE 0x0010 /* 0000-0000-0001-0000 */
124#define SCI_ENABLE_INT_RX 0x0020 /* 0000-0000-0010-0000 */
125#define SCI_ENABLE_INT_TX_DONE 0x0040 /* 0000-0000-0100-0000 */
126#define SCI_ENABLE_INT_TX 0x0080 /* 0000-0000-1000-0000 */
127
128#define SCI_DISABLE_INT_ALL 0xFF00 /* 1111-1111-0000-0000 ??? */
129
130#define SCI_DISABLE_INT_RX 0xFFDF /* 1111-1111-1101-1111 */
131#define SCI_CLEAR_RX_INT 0xFFBF /* 1111-1111-1011-1111 */
132#define SCI_DISABLE_INT_TX 0xFF7F /* 1111-1111-0111-1111 */
133#define SCI_CLEAR_TDRE 0xFEFF /* 1111-1110-1111-1111 */
134
135#define SCI_RCVR_WAKE_ON_MARK 0x0100 /* 0000-0001-0000-0000 */
136#define SCI_9_DATA_BITS 0x0200 /* 0000-0010-0000-0000 */
137#define SCI_PARITY_ENABLE 0x0400 /* 0000-0100-0000-0000 */
138#define SCI_PARITY_ODD 0x0800 /* 0000-1000-0000-0000 */
139
140#define SCI_RCVR_WAKE_ON_IDLE 0xFEFF /* 1111-1110-1111-1111 */
141#define SCI_8_DATA_BITS 0xFDFF /* 1111-1101-1111-1111 */
142#define SCI_PARITY_DISABLE 0xFBFF /* 1111-1011-1111-1111 */
143#define SCI_PARITY_EVEN 0xF7FF /* 1111-0111-1111-1111 */
144
145#define SCI_PARITY_NONE 0xF3FF /* 1111-0011-1111-1111 */
146
147#define SCI_IDLE_LINE_LONG 0x1000 /* 0001-0000-0000-0000 */
148#define SCI_TXD_OPEN_DRAIN 0x2000 /* 0010-0000-0000-0000 */
149#define SCI_LOOPBACK_MODE 0x4000 /* 0100-0000-0000-0000 */
150#define SCI_SCCR1_UNUSED 0x8000 /* 1000-0000-0000-0000 */
151
152
153/* SCI Status Register (SCSR) $FFFC0C
154
155 8 4 2 1 - 8 4 2 1 - 8 4 2 1 - 8 4 2 1
156 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
157 | | | | | | | | | | | | | | | |
158 | | | | | | | | | | | | | | | +----- 0 PF - parity error
159 | | | | | | | | | | | | | | +------- 1 FE - framing error
160 | | | | | | | | | | | | | +--------- 2 NF - noise flag
161 | | | | | | | | | | | | +----------- 3 OR - overrun flag
162 | | | | | | | | | | | |
163 | | | | | | | | | | | +--------------- 4 IDLE - idle line detected
164 | | | | | | | | | | +----------------- 5 RAF - rcvr active flag
165 | | | | | | | | | +------------------- 6 RDRF - rcv data reg full
166 | | | | | | | | +--------------------- 7 TC - xmt complete flag
167 | | | | | | | |
168 | | | | | | | +------------------------- 8 TDRE - xmt data reg empty
169 | | | | | | +--------------------------- 9 always zero
170 | | | | | +----------------------------- 10 always zero
171 | | | | +------------------------------- 11 always zero
172 | | | |
173 | | | +----------------------------------- 12 always zero
174 | | +------------------------------------- 13 always zero
175 | +--------------------------------------- 14 always zero
176 +----------------------------------------- 15 always zero
177
178 0 0 0 0 - 0 0 0 1 - 1 0 0 0 - 0 0 0 0 reset value
179*/
180
181#define SCI_ERROR_PARITY 0x0001 /* 0000-0000-0000-0001 */
182#define SCI_ERROR_FRAMING 0x0002 /* 0000-0000-0000-0010 */
183#define SCI_ERROR_NOISE 0x0004 /* 0000-0000-0000-0100 */
184#define SCI_ERROR_OVERRUN 0x0008 /* 0000-0000-0000-1000 */
185
186#define SCI_IDLE_LINE 0x0010 /* 0000-0000-0001-0000 */
187#define SCI_RCVR_ACTIVE 0x0020 /* 0000-0000-0010-0000 */
188#define SCI_RCVR_READY 0x0040 /* 0000-0000-0100-0000 */
189#define SCI_XMTR_IDLE 0x0080 /* 0000-0000-1000-0000 */
190
191#define SCI_CLEAR_RX_INT 0xFFBF /* 1111-1111-1011-1111 */
192
193#define SCI_XMTR_READY 0x0100 /* 0000-0001-0000-0000 */
194
195#define SCI_CLEAR_TDRE 0xFEFF /* 1111-1110-1111-1111 */
196
197#define SCI_XMTR_AVAILABLE 0x0180 /* 0000-0001-1000-0000 */
198
199
200
201/*******************************************************************************
202 Function prototypes
203*******************************************************************************/
204
205#ifdef __cplusplus
206extern "C" {
207#endif
208
209/* look at console_open to see how this is called */
210
211const rtems_termios_callbacks * SciGetTermiosHandlers( int32_t polled );
212
213/* SCI interrupt */
214
215/*rtems_isr SciIsr( rtems_vector_number vector ); */
216
217/*int32_t SciOpenPolled ( int32_t major, int32_t minor, void *arg ); */
218/*int32_t SciOpenInterrupt ( int32_t major, int32_t minor, void *arg ); */
219
220/*int32_t SciClose ( int32_t major, int32_t minor, void *arg ); */
221
222/*int32_t SciWritePolled ( int32_t minor, const char *buf, int32_t len ); */
223/*int32_t SciWriteInterrupt( int32_t minor, const char *buf, int32_t len ); */
224
225/*int32_t SciReadPolled ( int32_t minor ); */
226
227/*int32_t SciSetAttributes ( int32_t minor, const struct termios *t ); */
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif /* _sci_h_ */
Definition: libio.h:1879