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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [hal/] [mips/] [atlas/] [v2_0/] [src/] [ser16c550c.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1254 phoenix
//=============================================================================
2
//
3
//      ser16c550c.c
4
//
5
//      Simple driver for the 16c550c serial controllers on the Atlas board
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
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//=============================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):   dmoseley
44
// Contributors:dmoseley
45
// Date:        2000-07-06
46
// Description: Simple driver for the 16c550c serial controller
47
//
48
//####DESCRIPTIONEND####
49
//
50
//=============================================================================
51
 
52
#include <pkgconf/hal.h>
53
#include <pkgconf/system.h>
54
#include CYGBLD_HAL_PLATFORM_H
55
 
56
#include <cyg/hal/hal_arch.h>           // SAVE/RESTORE GP macros
57
#include <cyg/hal/hal_io.h>             // IO macros
58
#include <cyg/hal/hal_if.h>             // interface API
59
#include <cyg/hal/hal_intr.h>           // HAL_ENABLE/MASK/UNMASK_INTERRUPTS
60
#include <cyg/hal/hal_misc.h>           // Helper functions
61
#include <cyg/hal/drv_api.h>            // CYG_ISR_HANDLED
62
 
63
//-----------------------------------------------------------------------------
64
// There is only one port.
65
#define ATLAS_SER_16550_BASE      0xBF000900
66
 
67
//-----------------------------------------------------------------------------
68
// Define the serial registers. The Atlas board is equipped with a 16550C
69
// serial chip.
70
#define SER_16550_RBR 0x00   // receiver buffer register, read, dlab = 0
71
#define SER_16550_THR 0x00   // transmitter holding register, write, dlab = 0
72
#define SER_16550_DLL 0x00   // divisor latch (LS), read/write, dlab = 1
73
#define SER_16550_IER 0x08   // interrupt enable register, read/write, dlab = 0
74
#define SER_16550_DLM 0x08   // divisor latch (MS), read/write, dlab = 1
75
#define SER_16550_IIR 0x10   // interrupt identification reg, read, dlab = 0
76
#define SER_16550_FCR 0x10   // fifo control register, write, dlab = 0
77
#define SER_16550_AFR 0x10   // alternate function reg, read/write, dlab = 1
78
#define SER_16550_LCR 0x18   // line control register, read/write
79
#define SER_16550_MCR 0x20   // modem control register, read/write
80
#define SER_16550_LSR 0x28   // line status register, read
81
#define SER_16550_MSR 0x30   // modem status register, read
82
#define SER_16550_SCR 0x38   // scratch pad register
83
 
84
// The interrupt enable register bits.
85
#define SIO_IER_ERDAI   0x01            // enable received data available irq
86
#define SIO_IER_ETHREI  0x02            // enable THR empty interrupt
87
#define SIO_IER_ELSI    0x04            // enable receiver line status irq
88
#define SIO_IER_EMSI    0x08            // enable modem status interrupt
89
 
90
// The interrupt identification register bits.
91
#define SIO_IIR_IP      0x01            // 0 if interrupt pending
92
#define SIO_IIR_ID_MASK 0x0e            // mask for interrupt ID bits
93
 
94
// The line status register bits.
95
#define SIO_LSR_DR      0x01            // data ready
96
#define SIO_LSR_OE      0x02            // overrun error
97
#define SIO_LSR_PE      0x04            // parity error
98
#define SIO_LSR_FE      0x08            // framing error
99
#define SIO_LSR_BI      0x10            // break interrupt
100
#define SIO_LSR_THRE    0x20            // transmitter holding register empty
101
#define SIO_LSR_TEMT    0x40            // transmitter register empty
102
#define SIO_LSR_ERR     0x80            // any error condition
103
 
104
// The modem status register bits.
105
#define SIO_MSR_DCTS  0x01              // delta clear to send
106
#define SIO_MSR_DDSR  0x02              // delta data set ready
107
#define SIO_MSR_TERI  0x04              // trailing edge ring indicator
108
#define SIO_MSR_DDCD  0x08              // delta data carrier detect
109
#define SIO_MSR_CTS   0x10              // clear to send
110
#define SIO_MSR_DSR   0x20              // data set ready
111
#define SIO_MSR_RI    0x40              // ring indicator
112
#define SIO_MSR_DCD   0x80              // data carrier detect
113
 
114
// The line control register bits.
115
#define SIO_LCR_WLS0   0x01             // word length select bit 0
116
#define SIO_LCR_WLS1   0x02             // word length select bit 1
117
#define SIO_LCR_STB    0x04             // number of stop bits
118
#define SIO_LCR_PEN    0x08             // parity enable
119
#define SIO_LCR_EPS    0x10             // even parity select
120
#define SIO_LCR_SP     0x20             // stick parity
121
#define SIO_LCR_SB     0x40             // set break
122
#define SIO_LCR_DLAB   0x80             // divisor latch access bit
123
 
124
// The FIFO control register
125
#define SIO_FCR_FCR0   0x01             // enable xmit and rcvr fifos
126
#define SIO_FCR_FCR1   0x02             // clear RCVR FIFO
127
#define SIO_FCR_FCR2   0x04             // clear XMIT FIFO
128
 
129
/////////////////////////////////////////
130
// Interrupt Enable Register
131
#define IER_RCV 0x01
132
#define IER_XMT 0x02
133
#define IER_LS  0x04
134
#define IER_MS  0x08
135
 
136
// Line Control Register
137
#define LCR_WL5 0x00    // Word length
138
#define LCR_WL6 0x01
139
#define LCR_WL7 0x02
140
#define LCR_WL8 0x03
141
#define LCR_SB1 0x00    // Number of stop bits
142
#define LCR_SB1_5 0x04  // 1.5 -> only valid with 5 bit words
143
#define LCR_SB2 0x04
144
#define LCR_PN  0x00    // Parity mode - none
145
#define LCR_PE  0x0C    // Parity mode - even
146
#define LCR_PO  0x08    // Parity mode - odd
147
#define LCR_PM  0x28    // Forced "mark" parity
148
#define LCR_PS  0x38    // Forced "space" parity
149
#define LCR_DL  0x80    // Enable baud rate latch
150
 
151
// Line Status Register
152
#define LSR_RSR 0x01
153
#define LSR_THE 0x20
154
 
155
// Modem Control Register
156
#define MCR_DTR 0x01
157
#define MCR_RTS 0x02
158
#define MCR_INT 0x08   // Enable interrupts
159
 
160
// Interrupt status register
161
#define ISR_None             0x01
162
#define ISR_Rx_Line_Status   0x06
163
#define ISR_Rx_Avail         0x04
164
#define ISR_Rx_Char_Timeout  0x0C
165
#define ISR_Tx_Empty         0x02
166
#define IRS_Modem_Status     0x00
167
 
168
// FIFO control register
169
#define FCR_ENABLE     0x01
170
#define FCR_CLEAR_RCVR 0x02
171
#define FCR_CLEAR_XMIT 0x04
172
 
173
// The Atlas board has a 3.6864 MHz crystal
174
#define BAUD_110           2094
175
#define BAUD_150           1536
176
#define BAUD_300           768
177
#define BAUD_600           384
178
#define BAUD_1200          192
179
#define BAUD_2400          96
180
#define BAUD_4800          48
181
#define BAUD_7200          32
182
#define BAUD_9600          24
183
#define BAUD_14400         16
184
#define BAUD_19200         12
185
#define BAUD_38400         6
186
#define BAUD_57600         4
187
#define BAUD_115200        2
188
#define BAUD_230400        1
189
 
190
#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD==9600
191
#define CYG_DEV_SERIAL_BAUD_DIVISOR    BAUD_9600
192
#endif
193
#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD==19200
194
#define CYG_DEV_SERIAL_BAUD_DIVISOR    BAUD_19200
195
#endif
196
#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD==38400
197
#define CYG_DEV_SERIAL_BAUD_DIVISOR    BAUD_38400
198
#endif
199
#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD==57600
200
#define CYG_DEV_SERIAL_BAUD_DIVISOR    BAUD_57600
201
#endif
202
#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD==115200
203
#define CYG_DEV_SERIAL_BAUD_DIVISOR    BAUD_115200
204
#endif
205
 
206
#ifndef CYG_DEV_SERIAL_BAUD_DIVISOR
207
#error Missing/incorrect serial baud rate defined - CDL error?
208
#endif
209
 
210
 
211
//-----------------------------------------------------------------------------
212
typedef struct {
213
    cyg_uint8* base;
214
    cyg_int32 msec_timeout;
215
    int isr_vector;
216
} channel_data_t;
217
 
218
static channel_data_t channels[1] = {
219
    { (cyg_uint8*)ATLAS_SER_16550_BASE, 1000, CYGNUM_HAL_INTERRUPT_DEBUG_UART}
220
};
221
 
222
//-----------------------------------------------------------------------------
223
// Set the baud rate
224
 
225
static void
226
cyg_hal_plf_serial_set_baud(cyg_uint8* port, cyg_uint16 baud_divisor)
227
{
228
    cyg_uint8 _lcr;
229
 
230
    HAL_READ_UINT8(port+SER_16550_LCR, _lcr);
231
    _lcr |= LCR_DL;
232
    HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
233
 
234
    HAL_WRITE_UINT8(port+SER_16550_DLM, baud_divisor >> 8);
235
    HAL_WRITE_UINT8(port+SER_16550_DLL, baud_divisor & 0xff);
236
 
237
    _lcr &= ~LCR_DL;
238
    HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
239
}
240
 
241
//-----------------------------------------------------------------------------
242
// The minimal init, get and put functions. All by polling.
243
 
244
void
245
cyg_hal_plf_serial_init_channel(void* __ch_data)
246
{
247
    cyg_uint8* port;
248
    cyg_uint8 _lcr;
249
 
250
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
251
    // Go ahead and assume it is channels[0].
252
    if (__ch_data == 0)
253
      __ch_data = (void*)&channels[0];
254
 
255
    port = ((channel_data_t*)__ch_data)->base;
256
 
257
    // Disable port interrupts while changing hardware
258
    HAL_WRITE_UINT8(port+SER_16550_IER, 0);
259
 
260
    // Set databits, stopbits and parity.
261
    _lcr = LCR_WL8 | LCR_SB1 | LCR_PN;
262
    HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
263
 
264
    // Set baud rate.
265
    cyg_hal_plf_serial_set_baud(port, CYG_DEV_SERIAL_BAUD_DIVISOR);
266
 
267
    // Enable and clear FIFO
268
    HAL_WRITE_UINT8(port+SER_16550_FCR, (FCR_ENABLE | FCR_CLEAR_RCVR | FCR_CLEAR_XMIT));
269
 
270
    // enable RTS to keep host side happy
271
    HAL_WRITE_UINT8( port+SER_16550_MCR, MCR_RTS );
272
 
273
    // Don't allow interrupts.
274
    HAL_WRITE_UINT8(port+SER_16550_IER, 0);
275
}
276
 
277
void
278
cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 __ch)
279
{
280
    cyg_uint8* port;
281
    cyg_uint8 _lsr;
282
 
283
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
284
    // Go ahead and assume it is channels[0].
285
    if (__ch_data == 0)
286
      __ch_data = (void*)&channels[0];
287
 
288
    port = ((channel_data_t*)__ch_data)->base;
289
 
290
    CYGARC_HAL_SAVE_GP();
291
 
292
    do {
293
        HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
294
    } while ((_lsr & SIO_LSR_THRE) == 0);
295
 
296
    // Now, the transmit buffer is empty
297
    HAL_WRITE_UINT8(port+SER_16550_THR, __ch);
298
 
299
    // Hang around until the character has been safely sent.
300
    do {
301
        HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
302
    } while ((_lsr & SIO_LSR_THRE) == 0);
303
 
304
    CYGARC_HAL_RESTORE_GP();
305
}
306
 
307
static cyg_bool
308
cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)
309
{
310
    cyg_uint8* port;
311
    cyg_uint8 _lsr;
312
 
313
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
314
    // Go ahead and assume it is channels[0].
315
    if (__ch_data == 0)
316
      __ch_data = (void*)&channels[0];
317
 
318
    port = ((channel_data_t*)__ch_data)->base;
319
 
320
    HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
321
    if ((_lsr & SIO_LSR_DR) == 0)
322
        return false;
323
 
324
    HAL_READ_UINT8(port+SER_16550_RBR, *ch);
325
 
326
    return true;
327
}
328
 
329
cyg_uint8
330
cyg_hal_plf_serial_getc(void* __ch_data)
331
{
332
    cyg_uint8 ch;
333
    CYGARC_HAL_SAVE_GP();
334
 
335
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
336
    // Go ahead and assume it is channels[0].
337
    if (__ch_data == 0)
338
      __ch_data = (void*)&channels[0];
339
 
340
    while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch));
341
 
342
    CYGARC_HAL_RESTORE_GP();
343
    return ch;
344
}
345
 
346
static void
347
cyg_hal_plf_serial_write(void* __ch_data, const cyg_uint8* __buf,
348
                         cyg_uint32 __len)
349
{
350
    CYGARC_HAL_SAVE_GP();
351
 
352
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
353
    // Go ahead and assume it is channels[0].
354
    if (__ch_data == 0)
355
      __ch_data = (void*)&channels[0];
356
 
357
    while(__len-- > 0)
358
        cyg_hal_plf_serial_putc(__ch_data, *__buf++);
359
 
360
    CYGARC_HAL_RESTORE_GP();
361
}
362
 
363
static void
364
cyg_hal_plf_serial_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len)
365
{
366
    CYGARC_HAL_SAVE_GP();
367
 
368
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
369
    // Go ahead and assume it is channels[0].
370
    if (__ch_data == 0)
371
      __ch_data = (void*)&channels[0];
372
 
373
    while(__len-- > 0)
374
        *__buf++ = cyg_hal_plf_serial_getc(__ch_data);
375
 
376
    CYGARC_HAL_RESTORE_GP();
377
}
378
 
379
 
380
cyg_bool
381
cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch)
382
{
383
    int delay_count;
384
    channel_data_t* chan;
385
    cyg_bool res;
386
    CYGARC_HAL_SAVE_GP();
387
 
388
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
389
    // Go ahead and assume it is channels[0].
390
    if (__ch_data == 0)
391
      __ch_data = (void*)&channels[0];
392
 
393
    chan = (channel_data_t*)__ch_data;
394
 
395
    delay_count = chan->msec_timeout * 10; // delay in .1 ms steps
396
 
397
    for(;;) {
398
        res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch);
399
        if (res || 0 == delay_count--)
400
            break;
401
        CYGACC_CALL_IF_DELAY_US(100);
402
    }
403
 
404
    CYGARC_HAL_RESTORE_GP();
405
    return res;
406
}
407
 
408
static int
409
cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)
410
{
411
    static int irq_state = 0;
412
    channel_data_t* chan;
413
    cyg_uint8 ier;
414
    int ret = 0;
415
    CYGARC_HAL_SAVE_GP();
416
 
417
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
418
    // Go ahead and assume it is channels[0].
419
    if (__ch_data == 0)
420
      __ch_data = (void*)&channels[0];
421
 
422
    chan = (channel_data_t*)__ch_data;
423
 
424
    switch (__func) {
425
    case __COMMCTL_IRQ_ENABLE:
426
        irq_state = 1;
427
 
428
        HAL_READ_UINT8(chan->base + SER_16550_IER, ier);
429
        ier |= SIO_IER_ERDAI;
430
        HAL_WRITE_UINT8(chan->base + SER_16550_IER, ier);
431
 
432
        HAL_INTERRUPT_SET_LEVEL(chan->isr_vector, 1);
433
        HAL_INTERRUPT_UNMASK(chan->isr_vector);
434
        break;
435
    case __COMMCTL_IRQ_DISABLE:
436
        ret = irq_state;
437
        irq_state = 0;
438
 
439
        HAL_READ_UINT8(chan->base + SER_16550_IER, ier);
440
        ier &= ~SIO_IER_ERDAI;
441
        HAL_WRITE_UINT8(chan->base + SER_16550_IER, ier);
442
 
443
        HAL_INTERRUPT_MASK(chan->isr_vector);
444
        break;
445
    case __COMMCTL_DBG_ISR_VECTOR:
446
        ret = chan->isr_vector;
447
        break;
448
    case __COMMCTL_SET_TIMEOUT:
449
    {
450
        va_list ap;
451
 
452
        va_start(ap, __func);
453
 
454
        ret = chan->msec_timeout;
455
        chan->msec_timeout = va_arg(ap, cyg_uint32);
456
 
457
        va_end(ap);
458
    }
459
    break;
460
    case __COMMCTL_SETBAUD:
461
    {
462
        cyg_uint32 baud_rate;
463
        cyg_uint16 baud_divisor;
464
        cyg_uint8* port = chan->base;
465
        va_list ap;
466
 
467
        va_start(ap, __func);
468
        baud_rate = va_arg(ap, cyg_uint32);
469
        va_end(ap);
470
 
471
        switch (baud_rate)
472
        {
473
        case 110:    baud_divisor = BAUD_110;    break;
474
        case 150:    baud_divisor = BAUD_150;    break;
475
        case 300:    baud_divisor = BAUD_300;    break;
476
        case 600:    baud_divisor = BAUD_600;    break;
477
        case 1200:   baud_divisor = BAUD_1200;   break;
478
        case 2400:   baud_divisor = BAUD_2400;   break;
479
        case 4800:   baud_divisor = BAUD_4800;   break;
480
        case 7200:   baud_divisor = BAUD_7200;   break;
481
        case 9600:   baud_divisor = BAUD_9600;   break;
482
        case 14400:  baud_divisor = BAUD_14400;  break;
483
        case 19200:  baud_divisor = BAUD_19200;  break;
484
        case 38400:  baud_divisor = BAUD_38400;  break;
485
        case 57600:  baud_divisor = BAUD_57600;  break;
486
        case 115200: baud_divisor = BAUD_115200; break;
487
        case 230400: baud_divisor = BAUD_230400; break;
488
        default:     return -1;                  break; // Invalid baud rate selected
489
        }
490
 
491
        //
492
        // We may need to increase the timeout before causing a break reset.
493
        // According to the Atlas Users Manual (Document MD00005) The BRKRES
494
        // register will need to be programmed with a value larger that 0xA (the default)
495
        // if we are going to use a baud rate lower than 2400.
496
        //
497
        if (baud_rate <= 2400)
498
        {
499
            // For now, just disable the break reset entirely.
500
            HAL_WRITE_UINT32(HAL_ATLAS_BRKRES, 0);
501
        } else {
502
            // Put the break reset state back to the default
503
            HAL_WRITE_UINT32(HAL_ATLAS_BRKRES, HAL_ATLAS_BRKRES_DEFAULT_VALUE);
504
        }
505
 
506
        // Disable port interrupts while changing hardware
507
        HAL_READ_UINT8(port+SER_16550_IER, ier);
508
        HAL_WRITE_UINT8(port+SER_16550_IER, 0);
509
 
510
        // Set baud rate.
511
        cyg_hal_plf_serial_set_baud(port, baud_divisor);
512
 
513
        // Reenable interrupts if necessary
514
        HAL_WRITE_UINT8(port+SER_16550_IER, ier);
515
    }
516
    break;
517
 
518
    case __COMMCTL_GETBAUD:
519
        break;
520
    default:
521
        break;
522
    }
523
    CYGARC_HAL_RESTORE_GP();
524
    return ret;
525
}
526
 
527
static int
528
cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc,
529
                       CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
530
{
531
    int res = 0;
532
    cyg_uint8 _iir, c;
533
    channel_data_t* chan;
534
    CYGARC_HAL_SAVE_GP();
535
 
536
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
537
    // Go ahead and assume it is channels[0].
538
    if (__ch_data == 0)
539
      __ch_data = (void*)&channels[0];
540
 
541
    chan = (channel_data_t*)__ch_data;
542
 
543
    HAL_INTERRUPT_ACKNOWLEDGE(chan->isr_vector);
544
 
545
    HAL_READ_UINT8(chan->base + SER_16550_IIR, _iir);
546
    _iir &= SIO_IIR_ID_MASK;
547
 
548
    *__ctrlc = 0;
549
    if ((_iir == ISR_Rx_Avail) || (_iir == ISR_Rx_Char_Timeout)) {
550
 
551
        HAL_READ_UINT8(chan->base + SER_16550_RBR, c);
552
 
553
        if( cyg_hal_is_break( &c , 1 ) )
554
            *__ctrlc = 1;
555
 
556
        res = CYG_ISR_HANDLED;
557
    }
558
 
559
    CYGARC_HAL_RESTORE_GP();
560
    return res;
561
}
562
 
563
static void
564
cyg_hal_plf_serial_init(void)
565
{
566
    hal_virtual_comm_table_t* comm;
567
    int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
568
 
569
    // Disable interrupts.
570
    HAL_INTERRUPT_MASK(channels[0].isr_vector);
571
 
572
    // Init channels
573
    cyg_hal_plf_serial_init_channel((void*)&channels[0]);
574
 
575
    // Setup procs in the vector table
576
 
577
    // Set channel 0
578
    CYGACC_CALL_IF_SET_CONSOLE_COMM(0);
579
    comm = CYGACC_CALL_IF_CONSOLE_PROCS();
580
    CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[0]);
581
    CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
582
    CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
583
    CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
584
    CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
585
    CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
586
    CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr);
587
    CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
588
 
589
    // Restore original console
590
    CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
591
}
592
 
593
void
594
cyg_hal_plf_comms_init(void)
595
{
596
    static int initialized = 0;
597
 
598
    if (initialized)
599
        return;
600
 
601
    initialized = 1;
602
 
603
    cyg_hal_plf_serial_init();
604
}
605
 
606
//-----------------------------------------------------------------------------
607
// end of ser16c550c.c
608
 

powered by: WebSVN 2.1.0

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