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