|
472
|
1 //============================================================================= |
|
|
2 // |
|
|
3 // hal_diag.c |
|
|
4 // |
|
|
5 // HAL diagnostic I/O code |
|
|
6 // |
|
|
7 //============================================================================= |
|
|
8 //####ECOSGPLCOPYRIGHTBEGIN#### |
|
|
9 // ------------------------------------------- |
|
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
|
|
12 // Copyright (C) 2002 Gary Thomas |
|
|
13 // |
|
|
14 // eCos is free software; you can redistribute it and/or modify it under |
|
|
15 // the terms of the GNU General Public License as published by the Free |
|
|
16 // Software Foundation; either version 2 or (at your option) any later version. |
|
|
17 // |
|
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
|
|
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
|
21 // for more details. |
|
|
22 // |
|
|
23 // You should have received a copy of the GNU General Public License along |
|
|
24 // with eCos; if not, write to the Free Software Foundation, Inc., |
|
|
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
|
26 // |
|
|
27 // As a special exception, if other files instantiate templates or use macros |
|
|
28 // or inline functions from this file, or you compile this file and link it |
|
|
29 // with other works to produce a work based on this file, this file does not |
|
|
30 // by itself cause the resulting work to be covered by the GNU General Public |
|
|
31 // License. However the source code for this file must still be made available |
|
|
32 // in accordance with section (3) of the GNU General Public License. |
|
|
33 // |
|
|
34 // This exception does not invalidate any other reasons why a work based on |
|
|
35 // this file might be covered by the GNU General Public License. |
|
|
36 // |
|
|
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
|
|
38 // at http://sources.redhat.com/ecos/ecos-license/ |
|
|
39 // ------------------------------------------- |
|
|
40 //####ECOSGPLCOPYRIGHTEND#### |
|
|
41 //============================================================================= |
|
|
42 //#####DESCRIPTIONBEGIN#### |
|
|
43 // |
|
|
44 // Author(s): hmt |
|
|
45 // Contributors:hmt, gthomas |
|
|
46 // Date: 1999-06-08 |
|
|
47 // Purpose: HAL diagnostic output |
|
|
48 // Description: Implementations of HAL diagnostic I/O support. |
|
|
49 // |
|
|
50 //####DESCRIPTIONEND#### |
|
|
51 // |
|
|
52 //============================================================================= |
|
|
53 |
|
|
54 #include <pkgconf/hal.h> |
|
|
55 |
|
|
56 #include <cyg/infra/cyg_type.h> // base types |
|
|
57 #include <cyg/infra/cyg_trac.h> // tracing macros |
|
|
58 #include <cyg/infra/cyg_ass.h> // assertion macros |
|
|
59 |
|
|
60 #include <cyg/hal/hal_io.h> // IO macros |
|
|
61 #include <cyg/hal/hal_diag.h> |
|
|
62 #include <cyg/hal/hal_intr.h> // Interrupt macros |
|
|
63 #include <cyg/hal/drv_api.h> |
|
|
64 |
|
|
65 #if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) |
|
|
66 #include <cyg/hal/hal_stub.h> // hal_output_gdb_string |
|
|
67 #endif |
|
|
68 |
|
|
69 #include <cyg/hal/ppc_regs.h> |
|
|
70 |
|
|
71 //============================================================================= |
|
|
72 // Serial driver |
|
|
73 //============================================================================= |
|
|
74 |
|
|
75 //----------------------------------------------------------------------------- |
|
|
76 // There are two serial ports. |
|
|
77 #define CYG_DEV_SERIAL_BASE_A 0xF0004500 // port A |
|
|
78 #define CYG_DEV_SERIAL_BASE_B 0xF0004600 // port B |
|
|
79 |
|
|
80 //----------------------------------------------------------------------------- |
|
|
81 // Default baud rate is 38400 |
|
|
82 #define _MEMCLK (CYGHWR_HAL_POWERPC_MEM_SPEED*1000000) |
|
|
83 #define _BAUD CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD |
|
|
84 #define CYG_DEV_SERIAL_RS232_T1_VALUE_B38400 (((_MEMCLK/16)/_BAUD) >> 8) |
|
|
85 #define CYG_DEV_SERIAL_RS232_T2_VALUE_B38400 (((_MEMCLK/16)/_BAUD) & 0xFF) |
|
|
86 |
|
|
87 //----------------------------------------------------------------------------- |
|
|
88 // Define the serial registers. The 8245 has a 16552 UART builtin. |
|
|
89 // |
|
|
90 #define CYG_DEV_SERIAL_RBR 0x00 // receiver buffer register, read, dlab = 0 |
|
|
91 #define CYG_DEV_SERIAL_THR 0x00 // transmitter holding register, write, dlab = 0 |
|
|
92 #define CYG_DEV_SERIAL_DLL 0x00 // divisor latch (LS), read/write, dlab = 1 |
|
|
93 #define CYG_DEV_SERIAL_IER 0x01 // interrupt enable register, read/write, dlab = 0 |
|
|
94 #define CYG_DEV_SERIAL_DLM 0x01 // divisor latch (MS), read/write, dlab = 1 |
|
|
95 #define CYG_DEV_SERIAL_IIR 0x02 // interrupt identification register, read, dlab = 0 |
|
|
96 #define CYG_DEV_SERIAL_FCR 0x02 // fifo control register, write, dlab = 0 |
|
|
97 #define CYG_DEV_SERIAL_AFR 0x02 // alternate function register, read/write, dlab = 1 |
|
|
98 #define CYG_DEV_SERIAL_LCR 0x03 // line control register, read/write |
|
|
99 #define CYG_DEV_SERIAL_MCR 0x04 |
|
|
100 #define CYG_DEV_SERIAL_MCR_A 0x04 |
|
|
101 #define CYG_DEV_SERIAL_MCR_B 0x04 |
|
|
102 #define CYG_DEV_SERIAL_LSR 0x05 // line status register, read |
|
|
103 #define CYG_DEV_SERIAL_MSR 0x06 // modem status register, read |
|
|
104 #define CYG_DEV_SERIAL_SCR 0x07 // scratch pad register |
|
|
105 |
|
|
106 // The interrupt enable register bits. |
|
|
107 #define SIO_IER_ERDAI 0x01 // enable received data available irq |
|
|
108 #define SIO_IER_ETHREI 0x02 // enable THR empty interrupt |
|
|
109 #define SIO_IER_ELSI 0x04 // enable receiver line status irq |
|
|
110 #define SIO_IER_EMSI 0x08 // enable modem status interrupt |
|
|
111 |
|
|
112 // The interrupt identification register bits. |
|
|
113 #define SIO_IIR_IP 0x01 // 0 if interrupt pending |
|
|
114 #define SIO_IIR_ID_MASK 0x0e // mask for interrupt ID bits |
|
|
115 #define ISR_Tx 0x02 |
|
|
116 #define ISR_Rx 0x04 |
|
|
117 |
|
|
118 // The line status register bits. |
|
|
119 #define SIO_LSR_DR 0x01 // data ready |
|
|
120 #define SIO_LSR_OE 0x02 // overrun error |
|
|
121 #define SIO_LSR_PE 0x04 // parity error |
|
|
122 #define SIO_LSR_FE 0x08 // framing error |
|
|
123 #define SIO_LSR_BI 0x10 // break interrupt |
|
|
124 #define SIO_LSR_THRE 0x20 // transmitter holding register empty |
|
|
125 #define SIO_LSR_TEMT 0x40 // transmitter register empty |
|
|
126 #define SIO_LSR_ERR 0x80 // any error condition |
|
|
127 |
|
|
128 // The modem status register bits. |
|
|
129 #define SIO_MSR_DCTS 0x01 // delta clear to send |
|
|
130 #define SIO_MSR_DDSR 0x02 // delta data set ready |
|
|
131 #define SIO_MSR_TERI 0x04 // trailing edge ring indicator |
|
|
132 #define SIO_MSR_DDCD 0x08 // delta data carrier detect |
|
|
133 #define SIO_MSR_CTS 0x10 // clear to send |
|
|
134 #define SIO_MSR_DSR 0x20 // data set ready |
|
|
135 #define SIO_MSR_RI 0x40 // ring indicator |
|
|
136 #define SIO_MSR_DCD 0x80 // data carrier detect |
|
|
137 |
|
|
138 // The line control register bits. |
|
|
139 #define SIO_LCR_WLS0 0x01 // word length select bit 0 |
|
|
140 #define SIO_LCR_WLS1 0x02 // word length select bit 1 |
|
|
141 #define SIO_LCR_STB 0x04 // number of stop bits |
|
|
142 #define SIO_LCR_PEN 0x08 // parity enable |
|
|
143 #define SIO_LCR_EPS 0x10 // even parity select |
|
|
144 #define SIO_LCR_SP 0x20 // stick parity |
|
|
145 #define SIO_LCR_SB 0x40 // set break |
|
|
146 #define SIO_LCR_DLAB 0x80 // divisor latch access bit |
|
|
147 |
|
|
148 // The FIFO control register |
|
|
149 #define SIO_FCR_FCR0 0x01 // enable xmit and rcvr fifos |
|
|
150 #define SIO_FCR_FCR1 0x02 // clear RCVR FIFO |
|
|
151 #define SIO_FCR_FCR2 0x04 // clear XMIT FIFO |
|
|
152 |
|
|
153 |
|
|
154 //----------------------------------------------------------------------------- |
|
|
155 typedef struct { |
|
|
156 cyg_uint8* base; |
|
|
157 cyg_int32 msec_timeout; |
|
|
158 int isr_vector; |
|
|
159 } channel_data_t; |
|
|
160 |
|
|
161 //----------------------------------------------------------------------------- |
|
|
162 static void |
|
|
163 init_serial_channel(const channel_data_t* __ch_data) |
|
|
164 { |
|
|
165 cyg_uint8* base = __ch_data->base; |
|
|
166 cyg_uint8 lcr; |
|
|
167 |
|
|
168 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_IER, 0); |
|
|
169 |
|
|
170 // Disable and clear FIFOs (need to enable to clear). |
|
|
171 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_FCR, |
|
|
172 (SIO_FCR_FCR0 | SIO_FCR_FCR1 | SIO_FCR_FCR2)); |
|
|
173 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_FCR, 0); |
|
|
174 |
|
|
175 // 8-1-no parity. |
|
|
176 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_LCR, SIO_LCR_WLS0 | SIO_LCR_WLS1); |
|
|
177 |
|
|
178 // Set speed to 38400. |
|
|
179 HAL_READ_UINT8(base+CYG_DEV_SERIAL_LCR, lcr); |
|
|
180 lcr |= SIO_LCR_DLAB; |
|
|
181 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_LCR, lcr); |
|
|
182 |
|
|
183 |
|
|
184 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_DLL, |
|
|
185 CYG_DEV_SERIAL_RS232_T2_VALUE_B38400); |
|
|
186 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_DLM, |
|
|
187 CYG_DEV_SERIAL_RS232_T1_VALUE_B38400); |
|
|
188 lcr &= ~SIO_LCR_DLAB; |
|
|
189 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_LCR, lcr); |
|
|
190 |
|
|
191 #if 0 // Necessary? |
|
|
192 { |
|
|
193 // Special initialization for ST16C552 on CMA102 |
|
|
194 cyg_uint8 mcr; |
|
|
195 |
|
|
196 HAL_READ_UINT8(base+CYG_DEV_SERIAL_MCR_A, mcr); |
|
|
197 mcr |= 8; |
|
|
198 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_MCR_A, mcr); |
|
|
199 |
|
|
200 HAL_READ_UINT8(base+CYG_DEV_SERIAL_MCR_B, mcr); |
|
|
201 mcr |= 8; |
|
|
202 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_MCR_B, mcr); |
|
|
203 } |
|
|
204 #endif |
|
|
205 |
|
|
206 // Enable FIFOs (and clear them). |
|
|
207 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_FCR, |
|
|
208 (SIO_FCR_FCR0 | SIO_FCR_FCR1 | SIO_FCR_FCR2)); |
|
|
209 } |
|
|
210 |
|
|
211 static cyg_bool |
|
|
212 cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch) |
|
|
213 { |
|
|
214 cyg_uint8* base = ((channel_data_t*)__ch_data)->base; |
|
|
215 cyg_uint8 lsr; |
|
|
216 |
|
|
217 HAL_READ_UINT8(base+CYG_DEV_SERIAL_LSR, lsr); |
|
|
218 if ((lsr & SIO_LSR_DR) == 0) |
|
|
219 return false; |
|
|
220 |
|
|
221 HAL_READ_UINT8(base+CYG_DEV_SERIAL_RBR, *ch); |
|
|
222 |
|
|
223 return true; |
|
|
224 } |
|
|
225 |
|
|
226 |
|
|
227 cyg_uint8 |
|
|
228 cyg_hal_plf_serial_getc(void* __ch_data) |
|
|
229 { |
|
|
230 cyg_uint8 ch; |
|
|
231 CYGARC_HAL_SAVE_GP(); |
|
|
232 |
|
|
233 while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)); |
|
|
234 |
|
|
235 CYGARC_HAL_RESTORE_GP(); |
|
|
236 return ch; |
|
|
237 } |
|
|
238 |
|
|
239 void |
|
|
240 cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 c) |
|
|
241 { |
|
|
242 cyg_uint8* base = ((channel_data_t*)__ch_data)->base; |
|
|
243 cyg_uint8 lsr; |
|
|
244 CYGARC_HAL_SAVE_GP(); |
|
|
245 |
|
|
246 do { |
|
|
247 HAL_READ_UINT8(base+CYG_DEV_SERIAL_LSR, lsr); |
|
|
248 } while ((lsr & SIO_LSR_THRE) == 0); |
|
|
249 |
|
|
250 HAL_WRITE_UINT8(base+CYG_DEV_SERIAL_THR, c); |
|
|
251 |
|
|
252 // Hang around until the character has been safely sent. |
|
|
253 do { |
|
|
254 HAL_READ_UINT8(base+CYG_DEV_SERIAL_LSR, lsr); |
|
|
255 } while ((lsr & SIO_LSR_THRE) == 0); |
|
|
256 |
|
|
257 CYGARC_HAL_RESTORE_GP(); |
|
|
258 } |
|
|
259 |
|
|
260 static const channel_data_t channels[2] = { |
|
|
261 { (cyg_uint8*)CYG_DEV_SERIAL_BASE_A, 1000, CYGNUM_HAL_INTERRUPT_UART0}, |
|
|
262 #if (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS > 1) |
|
|
263 { (cyg_uint8*)CYG_DEV_SERIAL_BASE_B, 1000, CYGNUM_HAL_INTERRUPT_UART1}, |
|
|
264 #endif |
|
|
265 }; |
|
|
266 |
|
|
267 static void |
|
|
268 cyg_hal_plf_serial_write(void* __ch_data, const cyg_uint8* __buf, |
|
|
269 cyg_uint32 __len) |
|
|
270 { |
|
|
271 CYGARC_HAL_SAVE_GP(); |
|
|
272 |
|
|
273 while(__len-- > 0) |
|
|
274 cyg_hal_plf_serial_putc(__ch_data, *__buf++); |
|
|
275 |
|
|
276 CYGARC_HAL_RESTORE_GP(); |
|
|
277 } |
|
|
278 |
|
|
279 static void |
|
|
280 cyg_hal_plf_serial_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len) |
|
|
281 { |
|
|
282 CYGARC_HAL_SAVE_GP(); |
|
|
283 |
|
|
284 while(__len-- > 0) |
|
|
285 *__buf++ = cyg_hal_plf_serial_getc(__ch_data); |
|
|
286 |
|
|
287 CYGARC_HAL_RESTORE_GP(); |
|
|
288 } |
|
|
289 |
|
|
290 cyg_bool |
|
|
291 cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch) |
|
|
292 { |
|
|
293 int delay_count; |
|
|
294 channel_data_t* chan = (channel_data_t*)__ch_data; |
|
|
295 cyg_bool res; |
|
|
296 CYGARC_HAL_SAVE_GP(); |
|
|
297 |
|
|
298 delay_count = chan->msec_timeout * 10; // delay in .1 ms steps |
|
|
299 for(;;) { |
|
|
300 res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch); |
|
|
301 if (res || 0 == delay_count--) |
|
|
302 break; |
|
|
303 |
|
|
304 CYGACC_CALL_IF_DELAY_US(100); |
|
|
305 } |
|
|
306 |
|
|
307 CYGARC_HAL_RESTORE_GP(); |
|
|
308 return res; |
|
|
309 } |
|
|
310 |
|
|
311 static int |
|
|
312 cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...) |
|
|
313 { |
|
|
314 static int irq_state = 0; |
|
|
315 channel_data_t* chan = (channel_data_t*)__ch_data; |
|
|
316 cyg_uint8 ier; |
|
|
317 int ret = 0; |
|
|
318 CYGARC_HAL_SAVE_GP(); |
|
|
319 |
|
|
320 switch (__func) { |
|
|
321 case __COMMCTL_IRQ_ENABLE: |
|
|
322 HAL_INTERRUPT_UNMASK(chan->isr_vector); |
|
|
323 HAL_INTERRUPT_SET_LEVEL(chan->isr_vector, 1); |
|
|
324 HAL_READ_UINT8(chan->base+CYG_DEV_SERIAL_IER, ier); |
|
|
325 ier |= SIO_IER_ERDAI; |
|
|
326 HAL_WRITE_UINT8(chan->base+CYG_DEV_SERIAL_IER, ier); |
|
|
327 irq_state = 1; |
|
|
328 break; |
|
|
329 case __COMMCTL_IRQ_DISABLE: |
|
|
330 ret = irq_state; |
|
|
331 irq_state = 0; |
|
|
332 HAL_INTERRUPT_MASK(chan->isr_vector); |
|
|
333 HAL_READ_UINT8(chan->base+CYG_DEV_SERIAL_IER, ier); |
|
|
334 ier &= ~SIO_IER_ERDAI; |
|
|
335 HAL_WRITE_UINT8(chan->base+CYG_DEV_SERIAL_IER, ier); |
|
|
336 break; |
|
|
337 case __COMMCTL_DBG_ISR_VECTOR: |
|
|
338 ret = chan->isr_vector; |
|
|
339 break; |
|
|
340 case __COMMCTL_SET_TIMEOUT: |
|
|
341 { |
|
|
342 va_list ap; |
|
|
343 |
|
|
344 va_start(ap, __func); |
|
|
345 |
|
|
346 ret = chan->msec_timeout; |
|
|
347 chan->msec_timeout = va_arg(ap, cyg_uint32); |
|
|
348 |
|
|
349 va_end(ap); |
|
|
350 } |
|
|
351 default: |
|
|
352 break; |
|
|
353 } |
|
|
354 CYGARC_HAL_RESTORE_GP(); |
|
|
355 return ret; |
|
|
356 } |
|
|
357 |
|
|
358 static int |
|
|
359 cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc, |
|
|
360 CYG_ADDRWORD __vector, CYG_ADDRWORD __data) |
|
|
361 { |
|
|
362 channel_data_t* chan = (channel_data_t*)__ch_data; |
|
|
363 cyg_uint8 _iir; |
|
|
364 int res = 0; |
|
|
365 CYGARC_HAL_SAVE_GP(); |
|
|
366 |
|
|
367 HAL_READ_UINT8(chan->base+CYG_DEV_SERIAL_IIR, _iir); |
|
|
368 _iir &= SIO_IIR_ID_MASK; |
|
|
369 |
|
|
370 *__ctrlc = 0; |
|
|
371 if ( ISR_Rx == _iir ) { |
|
|
372 cyg_uint8 c, lsr; |
|
|
373 HAL_READ_UINT8(chan->base+CYG_DEV_SERIAL_LSR, lsr); |
|
|
374 if (lsr & SIO_LSR_DR) { |
|
|
375 |
|
|
376 HAL_READ_UINT8(chan->base+CYG_DEV_SERIAL_RBR, c); |
|
|
377 |
|
|
378 if( cyg_hal_is_break( &c , 1 ) ) |
|
|
379 *__ctrlc = 1; |
|
|
380 } |
|
|
381 |
|
|
382 // Acknowledge the interrupt |
|
|
383 HAL_INTERRUPT_ACKNOWLEDGE(chan->isr_vector); |
|
|
384 res = CYG_ISR_HANDLED; |
|
|
385 } |
|
|
386 |
|
|
387 CYGARC_HAL_RESTORE_GP(); |
|
|
388 return res; |
|
|
389 } |
|
|
390 |
|
|
391 static void |
|
|
392 cyg_hal_plf_serial_init(void) |
|
|
393 { |
|
|
394 hal_virtual_comm_table_t* comm; |
|
|
395 int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT); |
|
|
396 |
|
|
397 // Disable interrupts. |
|
|
398 HAL_INTERRUPT_MASK(channels[0].isr_vector); |
|
|
399 #if (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS > 1) |
|
|
400 HAL_INTERRUPT_MASK(channels[1].isr_vector); |
|
|
401 #endif |
|
|
402 |
|
|
403 // Init channels |
|
|
404 init_serial_channel(&channels[0]); |
|
|
405 #if (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS > 1) |
|
|
406 init_serial_channel(&channels[1]); |
|
|
407 #endif |
|
|
408 |
|
|
409 // Setup procs in the vector table |
|
|
410 |
|
|
411 // Set channel 0 |
|
|
412 CYGACC_CALL_IF_SET_CONSOLE_COMM(0); |
|
|
413 comm = CYGACC_CALL_IF_CONSOLE_PROCS(); |
|
|
414 CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[0]); |
|
|
415 CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write); |
|
|
416 CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read); |
|
|
417 CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc); |
|
|
418 CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc); |
|
|
419 CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control); |
|
|
420 CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr); |
|
|
421 CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout); |
|
|
422 |
|
|
423 #if (CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS > 1) |
|
|
424 // Set channel 1 |
|
|
425 CYGACC_CALL_IF_SET_CONSOLE_COMM(1); |
|
|
426 comm = CYGACC_CALL_IF_CONSOLE_PROCS(); |
|
|
427 CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[1]); |
|
|
428 CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write); |
|
|
429 CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read); |
|
|
430 CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc); |
|
|
431 CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc); |
|
|
432 CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control); |
|
|
433 CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr); |
|
|
434 CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout); |
|
|
435 #endif |
|
|
436 |
|
|
437 // Restore original console |
|
|
438 CYGACC_CALL_IF_SET_CONSOLE_COMM(cur); |
|
|
439 } |
|
|
440 |
|
|
441 void |
|
|
442 cyg_hal_plf_comms_init(void) |
|
|
443 { |
|
|
444 static int initialized = 0; |
|
|
445 |
|
|
446 if (initialized) |
|
|
447 return; |
|
|
448 initialized = 1; |
|
|
449 |
|
|
450 cyg_hal_plf_serial_init(); |
|
|
451 } |
|
|
452 |
|
|
453 // EOF hal_diag.c |