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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [tx39/] [v2_0/] [src/] [hal_diag.c] - Blame information for rev 379

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*=============================================================================
2
//
3
//      hal_diag.c
4
//
5
//      HAL diagnostic output 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
//
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):   nickg
44
// Contributors:        nickg
45
// Date:        1998-03-02
46
// Purpose:     HAL diagnostic output
47
// Description: Implementations of HAL diagnostic output support.
48
//
49
//####DESCRIPTIONEND####
50
//
51
//===========================================================================*/
52
 
53
#include <pkgconf/hal.h>
54
 
55
#include <cyg/infra/cyg_type.h>         // base types
56
#include <cyg/infra/cyg_trac.h>         // tracing macros
57
#include <cyg/infra/cyg_ass.h>          // assertion macros
58
 
59
#include <cyg/hal/hal_arch.h>
60
#include <cyg/hal/hal_diag.h>
61
 
62
#include <cyg/hal/hal_intr.h>
63
 
64
#include <cyg/hal/hal_io.h>
65
 
66
/*---------------------------------------------------------------------------*/
67
 
68
//#define CYG_KERNEL_DIAG_LCD
69
#define CYG_KERNEL_DIAG_SERIAL0 // For ROM start but see immediately below:
70
 
71
#if defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon)
72
#undef CYG_KERNEL_DIAG_SERIAL0
73
#undef CYG_KERNEL_DIAG_LCD
74
#define CYG_KERNEL_DIAG_CYGMON
75
#define CYG_KERNEL_DIAG_GDB
76
 
77
#endif
78
 
79
/*---------------------------------------------------------------------------*/
80
 
81
static cyg_uint8 leds = 0;
82
 
83
void hal_diag_led(int x)
84
{
85
//    return;
86
    leds ^= x;
87
 
88
    HAL_WRITE_UINT8( 0xfffff504, leds);
89
 
90
#if 0
91
    {
92
        int i;
93
 
94
        for( i = 0; i < 0x00020000; i++ );
95
    }
96
#endif    
97
}
98
 
99
/*---------------------------------------------------------------------------*/
100
 
101
#if defined(CYG_KERNEL_DIAG_SERIAL0) || defined(CYG_KERNEL_DIAG_CYGMON)
102
 
103
#define DIAG_BASE       0xfffff300
104
#define DIAG_SLCR       (DIAG_BASE+0x00)
105
#define DIAG_SLSR       (DIAG_BASE+0x04)
106
#define DIAG_SLDICR     (DIAG_BASE+0x08)
107
#define DIAG_SLDISR     (DIAG_BASE+0x0C)
108
#define DIAG_SFCR       (DIAG_BASE+0x10)
109
#define DIAG_SBRG       (DIAG_BASE+0x14)
110
#define DIAG_TFIFO      (DIAG_BASE+0x20)
111
#define DIAG_RFIFO      (DIAG_BASE+0x30)
112
 
113
#define BRG_T0          0x0000
114
#define BRG_T2          0x0100
115
#define BRG_T4          0x0200
116
#define BRG_T5          0x0300
117
 
118
 
119
void hal_diag_init()
120
{
121
#if defined(CYGSEM_HAL_USE_ROM_MONITOR)
122
// If we are using the ROM monitor, it has already
123
// initialized the serial line.
124
#else
125
//hal_diag_led(0x10);    
126
    HAL_WRITE_UINT16( DIAG_SLCR , 0x0020 );
127
 
128
    HAL_WRITE_UINT16( DIAG_SLDICR , 0x0000 );
129
 
130
    HAL_WRITE_UINT16( DIAG_SFCR , 0x0000 );
131
 
132
#if CYGHWR_HAL_MIPS_CPU_FREQ == 50
133
//    HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 20 );    // 9600 bps
134
//    HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 10 );    // 19200 bps
135
    HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 5 );     // 38400 bps
136
#elif CYGHWR_HAL_MIPS_CPU_FREQ == 66
137
//    HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 27 );    // 9600 bps
138
//    HAL_WRITE_UINT16( DIAG_SBRG , BRG_T0 | 54 );    // 19200 bps
139
    HAL_WRITE_UINT16( DIAG_SBRG , BRG_T0 | 27 );    // 38400 bps
140
#else
141
#error Unsupported CPU frequency
142
#endif
143
//hal_diag_led(0x10);
144
#endif    
145
}
146
 
147
void hal_diag_write_char_serial0( char c)
148
{
149
    CYG_WORD16 disr;
150
 
151
//hal_diag_led(0x20);
152
 
153
    for(;;)
154
    {
155
        HAL_READ_UINT16( DIAG_SLDISR , disr );
156
 
157
        if( disr & 0x0002 ) break;
158
    }
159
 
160
    disr = disr & ~0x0002;
161
 
162
    HAL_WRITE_UINT8( DIAG_TFIFO, c );
163
 
164
    HAL_WRITE_UINT16( DIAG_SLDISR , disr );
165
 
166
//hal_diag_led(0x20);
167
}
168
 
169
void hal_diag_drain_serial0(void)
170
{
171
    CYG_WORD16 disr;
172
 
173
    for(;;)
174
    {
175
        HAL_READ_UINT16( DIAG_SLDISR , disr );
176
 
177
        if( disr & 0x0002 ) break;
178
    }
179
 
180
    disr = disr & ~0x0002;
181
 
182
    HAL_WRITE_UINT16( DIAG_SLDISR , disr );
183
}
184
 
185
void hal_diag_read_char_serial0(char *c)
186
{
187
    CYG_WORD16 disr;
188
 
189
//hal_diag_led(0x40);        
190
    for(;;)
191
    {
192
 
193
        HAL_READ_UINT16( DIAG_SLDISR , disr );
194
 
195
        if( disr & 0x0001 ) break;
196
    }
197
 
198
    disr = disr & ~0x0001;
199
 
200
    HAL_READ_UINT8( DIAG_RFIFO, *c );
201
 
202
    HAL_WRITE_UINT16( DIAG_SLDISR , disr );
203
 
204
//hal_diag_led(0x40);
205
}
206
 
207
 
208
#if defined(CYG_KERNEL_DIAG_CYGMON)
209
void hal_diag_dumb_write_char(char c)
210
#else
211
void hal_diag_write_char(char c)
212
#endif
213
{
214
#ifdef CYG_KERNEL_DIAG_GDB    
215
#if 0 //defined(CYGSEM_HAL_USE_ROM_MONITOR)
216
 
217
    typedef void rom_write_fn(char c);
218
    rom_write_fn *fn = ((rom_write_fn **)0x80000100)[63];
219
 
220
    fn(c);
221
 
222
#else    
223
    static char line[100];
224
    static int pos = 0;
225
//    register volatile cyg_uint16 *volatile tty_status = SERIAL1_SR;    
226
 
227
    // No need to send CRs
228
    if( c == '\r' ) return;
229
 
230
    line[pos++] = c;
231
 
232
    if( c == '\n' || pos == sizeof(line) )
233
    {
234
 
235
        // Disable interrupts. This prevents GDB trying to interrupt us
236
        // while we are in the middle of sending a packet. The serial
237
        // receive interrupt will be seen when we re-enable interrupts
238
        // later.
239
        CYG_INTERRUPT_STATE oldstate;
240
        HAL_DISABLE_INTERRUPTS(oldstate);
241
 
242
        while(1)
243
        {
244
            static char hex[] = "0123456789ABCDEF";
245
            cyg_uint8 csum = 0;
246
            int i;
247
            char c1;
248
 
249
            hal_diag_write_char_serial0('$');
250
            hal_diag_write_char_serial0('O');
251
            csum += 'O';
252
            for( i = 0; i < pos; i++ )
253
            {
254
                char ch = line[i];
255
                char h = hex[(ch>>4)&0xF];
256
                char l = hex[ch&0xF];
257
                hal_diag_write_char_serial0(h);
258
                hal_diag_write_char_serial0(l);
259
                csum += h;
260
                csum += l;
261
            }
262
            hal_diag_write_char_serial0('#');
263
            hal_diag_write_char_serial0(hex[(csum>>4)&0xF]);
264
            hal_diag_write_char_serial0(hex[csum&0xF]);
265
 
266
            hal_diag_read_char_serial0( &c1 );
267
 
268
            if( c1 == '+' ) break;
269
 
270
            {
271
                extern void cyg_hal_user_break(CYG_ADDRWORD *regs);
272
                extern cyg_bool cyg_hal_is_break(char *buf, int size);
273
                if( cyg_hal_is_break( &c1 , 1 ) )
274
                    cyg_hal_user_break( NULL );
275
            }
276
 
277
            break;
278
        }
279
 
280
        pos = 0;
281
 
282
        // Wait for all data from serial line to drain
283
        // and clear ready-to-send indication.
284
        hal_diag_drain_serial0();
285
 
286
        // And re-enable interrupts
287
        HAL_RESTORE_INTERRUPTS( oldstate );
288
 
289
    }
290
#endif    
291
#else
292
    hal_diag_write_char_serial0(c);
293
#endif    
294
}
295
 
296
 
297
void hal_diag_read_char(char *c)
298
{
299
    for(;;)
300
    {
301
#if defined(CYG_KERNEL_DIAG_GDB) && defined(CYGSEM_HAL_USE_ROM_MONITOR)
302
 
303
        typedef void rom_read_fn(char *c);
304
        rom_read_fn *fn = ((rom_read_fn **)0x80000100)[62];
305
 
306
        fn(c);
307
 
308
#else    
309
        hal_diag_read_char_serial0(c);
310
 
311
#endif    
312
 
313
#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
314
        if( *c == 3 )
315
        {
316
            // Ctrl-C: breakpoint.
317
            extern void breakpoint(void);
318
            breakpoint();
319
            continue;
320
        }
321
#elif defined(CYGSEM_HAL_USE_ROM_MONITOR)
322
        if( *c == 3 )
323
        {
324
            // Ctrl-C: breakpoint.
325
 
326
//                HAL_BREAKPOINT(_breakinst);
327
            typedef void bpt_fn(void);
328
            bpt_fn *bfn = ((bpt_fn **)0x80000100)[61];
329
 
330
            bfn();
331
            continue;
332
        }
333
#endif
334
 
335
        break;
336
    }
337
}
338
 
339
#endif // defined(CYG_KERNEL_DIAG_SERIAL0) || defined(CYG_KERNEL_DIAG_CYGMON)
340
 
341
 
342
#if defined(CYG_KERNEL_DIAG_CYGMON) // only
343
 
344
/* This code has been imported from the BSP module. The definitions have
345
 * been left as-is, even though there was scope for doing more, to avoid
346
 * too much drift from the original sources
347
 */
348
 
349
struct bsp_comm_procs {
350
    void *ch_data;
351
    void (*__write)(void *ch_data, const char *buf, int len);
352
    int  (*__read)(void *ch_data, char *buf, int len);
353
    void (*__putc)(void *ch_data, char ch);
354
    int  (*__getc)(void *ch_data);
355
    int  (*__control)(void *ch_data, int func, ...);
356
};
357
 
358
// This is pointed to by entry BSP_NOTVEC_BSP_COMM_PROCS:
359
typedef struct {
360
    int  version;       /* version number for future expansion */
361
    void *__ictrl_table;
362
    void *__exc_table;
363
    void *__dbg_vector;
364
    void *__kill_vector;
365
    struct bsp_comm_procs *__console_procs;
366
    struct bsp_comm_procs *__debug_procs;
367
    void *__flush_dcache;
368
    void *__flush_icache;
369
    void *__cpu_data;
370
    void *__board_data;
371
    void *__sysinfo;
372
    int  (*__set_debug_comm)(int __comm_id);
373
    int  (*__set_console_comm)(int __comm_id);
374
    int  (*__set_serial_baud)(int __comm_id, int baud);
375
    void *__dbg_data;
376
    void (*__reset)(void);
377
    int  __console_interrupt_flag;
378
} bsp_shared_t;
379
 
380
/*
381
 * Core Exception vectors.
382
 */
383
#define BSP_EXC_INT         0
384
#define BSP_EXC_TLBMOD      1
385
#define BSP_EXC_TLBL        2
386
#define BSP_EXC_TLBS        3
387
#define BSP_EXC_ADEL        4
388
#define BSP_EXC_ADES        5
389
#define BSP_EXC_IBE         6
390
#define BSP_EXC_DBE         7
391
#define BSP_EXC_SYSCALL     8
392
#define BSP_EXC_BREAK       9
393
#define BSP_EXC_ILL        10
394
#define BSP_EXC_CPU        11
395
#define BSP_EXC_OV         12
396
#define BSP_EXC_TRAP       13
397
#define BSP_EXC_VCEI       14
398
#define BSP_EXC_FPE        15
399
#define BSP_EXC_RSV16      16
400
#define BSP_EXC_RSV17      17
401
#define BSP_EXC_RSV18      18
402
#define BSP_EXC_RSV19      19
403
#define BSP_EXC_RSV20      20
404
#define BSP_EXC_RSV21      21
405
#define BSP_EXC_RSV22      22
406
#define BSP_EXC_WATCH      23
407
#define BSP_EXC_RSV24      24
408
#define BSP_EXC_RSV25      25
409
#define BSP_EXC_RSV26      26
410
#define BSP_EXC_RSV27      27
411
#define BSP_EXC_RSV28      28
412
#define BSP_EXC_RSV29      29
413
#define BSP_EXC_RSV30      30
414
#define BSP_EXC_VCED       31
415
/* tx39 debug exception */
416
#define BSP_EXC_DEBUG      32
417
#define BSP_EXC_TLB        33
418
#define BSP_EXC_NMI        34
419
/*
420
 * Hack for eCos on tx39 to set an async breakpoint.
421
 */
422
#define BSP_VEC_BP_HOOK    35
423
 
424
#define BSP_EXC_XTLB       36
425
#define BSP_EXC_CACHE      37
426
 
427
#define BSP_MAX_EXCEPTIONS 38
428
 
429
/*
430
 * Another hack for tx39 eCos compatibility.
431
 */
432
#if defined(__CPU_R3900__)
433
#define BSP_VEC_MT_DEBUG   15
434
#else
435
#define BSP_VEC_MT_DEBUG   38
436
#endif
437
 
438
#define BSP_VEC_STUB_ENTRY 39
439
#define BSP_VEC_BSPDATA    40
440
#define BSP_VEC_MAGIC      41
441
#define BSP_VEC_IRQ_CHECK  42
442
 
443
#define BSP_VEC_PAD        43
444
#define NUM_VTAB_ENTRIES   44
445
 
446
 
447
#define BSP_MAGIC_VAL      0x55aa4321
448
 
449
#define SYS_interrupt 1000
450
 
451
// These vectors should be called with:
452
//
453
//  k0 - Exception Number
454
 
455
#define CYGMON_VECTOR_TABLE_BASE 0x80000100
456
#define CYGMON_VECTOR_TABLE ((CYG_ADDRESS *)CYGMON_VECTOR_TABLE_BASE)
457
 
458
#if 0 // UNUSED
459
static int
460
hal_bsp_set_debug_comm(int arg)
461
{
462
    bsp_shared_t *shared;
463
 
464
    shared = (bsp_shared_t *)
465
        (CYGMON_VECTOR_TABLE[ BSP_VEC_BSPDATA ]);
466
 
467
    if (0 != shared->__set_debug_comm) {
468
        return (*(shared->__set_debug_comm))(arg);
469
    }
470
    return 0;
471
}
472
 
473
static int
474
hal_bsp_set_console_comm(int arg)
475
{
476
    bsp_shared_t *shared;
477
 
478
    shared = (bsp_shared_t *)
479
        (CYGMON_VECTOR_TABLE[ BSP_VEC_BSPDATA ]);
480
 
481
    if (0 != shared->__set_console_comm) {
482
        return (*(shared->__set_console_comm))(arg);
483
    }
484
    return 0;
485
}
486
#endif // 0 UNUSED
487
 
488
static void bsp_trap(int trap_num);
489
 
490
static int
491
hal_bsp_console_write(const void *p, int len)
492
{
493
    bsp_shared_t *shared;
494
    struct bsp_comm_procs *com;
495
    int  magic;
496
 
497
    /*hal_bsp_set_console_comm(0);*/
498
 
499
    /* If this is not a BSP-based CygMon, return 0 */
500
    magic = (int)(CYGMON_VECTOR_TABLE[ BSP_VEC_MAGIC ]);
501
    if (magic != BSP_MAGIC_VAL)
502
        return 0;
503
 
504
    shared = (bsp_shared_t *)
505
        (CYGMON_VECTOR_TABLE[ BSP_VEC_BSPDATA ]);
506
 
507
    com = shared->__console_procs;
508
 
509
    if (0 != com) {
510
        shared->__console_interrupt_flag = 0;
511
        com->__write(com->ch_data, p, len);
512
        if (shared->__console_interrupt_flag) {
513
            /* debug interrupt; stop here */
514
            bsp_trap(SYS_interrupt);
515
        }
516
 
517
        return 1;
518
    }
519
    return 0;
520
}
521
 
522
static void
523
bsp_trap(int trap_num)
524
{
525
    asm("syscall\n");
526
}
527
 
528
 
529
static void
530
hal_dumb_serial_write(const char *p, int len)
531
{
532
    int i;
533
    for ( i = 0 ; i < len; i++ ) {
534
        hal_diag_dumb_write_char(p[i]);
535
    }
536
}
537
 
538
void hal_diag_write_char(char c)
539
{
540
    static char line[100];
541
    static int pos = 0;
542
 
543
    // No need to send CRs
544
    if( c == '\r' ) return;
545
 
546
    line[pos++] = c;
547
 
548
    if( c == '\n' || pos == sizeof(line) ) {
549
        CYG_INTERRUPT_STATE old;
550
 
551
        // Disable interrupts. This prevents GDB trying to interrupt us
552
        // while we are in the middle of sending a packet. The serial
553
        // receive interrupt will be seen when we re-enable interrupts
554
        // later.
555
 
556
        HAL_DISABLE_INTERRUPTS(old);
557
 
558
        if ( ! hal_bsp_console_write( line, pos ) )
559
            // then there is no function registered, just spew it out serial
560
            hal_dumb_serial_write( line, pos );
561
 
562
        pos = 0;
563
 
564
        // And re-enable interrupts
565
        HAL_RESTORE_INTERRUPTS(old);
566
 
567
    }
568
}
569
 
570
int
571
hal_diag_irq_check(int vector)
572
{
573
    typedef int irq_check_fn(int irq_nr);
574
    irq_check_fn *fn = (irq_check_fn *)(CYGMON_VECTOR_TABLE[ BSP_VEC_IRQ_CHECK ]);
575
    int  magic;
576
 
577
 
578
    /* If this is not a BSP-based CygMon, return 0 */
579
    magic = (int)(CYGMON_VECTOR_TABLE[ BSP_VEC_MAGIC ]);
580
    if (magic != BSP_MAGIC_VAL)
581
        return 0;
582
 
583
#if defined(CYGPKG_HAL_MIPS_TX3904)
584
    /* convert vector to BSP irq number */
585
    if (vector == 16)
586
        vector = 2;
587
    else
588
        vector += 3;
589
#endif
590
 
591
    return fn(vector);
592
}
593
 
594
#endif // defined(CYG_KERNEL_DIAG_CYGMON) *only*
595
 
596
/*---------------------------------------------------------------------------*/
597
 
598
#if defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && defined(CYG_KERNEL_DIAG_LCD)
599
 
600
/* ----------------------------------------------------------- */
601
#define ISA_BASE 0xA0000000
602
#define LCD_DATA *(volatile unsigned char*)(0x13400000+ISA_BASE)
603
#define LCD_CMD *(volatile unsigned char*)(0x13000000+ISA_BASE)
604
 
605
#define DISPCLR 0x01   /* Display Clear */
606
#define ECURINC 0x06   /* Cursor Increment */
607
#define DISPCONT 0x08   /* Display Control */
608
#define BLINK 0x01   /* Blink */
609
#define CURON 0x02   /* Cursor ON */
610
#define DISPON 0x04   /* Display ON */
611
#define INITCMD 0x38   /* Initial Command */
612
#define DDRAM 0x80   /* DDRAM address */
613
#define LCDBUSY 0x80   /* Busy */
614
 
615
/* ----------------------------------------------------------- */
616
 
617
/*                                          */
618
/* JMZ-LCD202 LCD Display Unit              */
619
/*     - Sample Program (for JMR-TX3904) -  */
620
/*                                          */
621
 
622
static void readyLCD(){
623
    while(LCD_CMD & LCDBUSY);
624
}
625
 
626
static void outLCD(unsigned char d){
627
    readyLCD();
628
    LCD_DATA = d;
629
}
630
 
631
static void outLCD_CMD(unsigned char d){
632
    readyLCD();
633
    LCD_CMD = d;
634
}
635
 
636
static void INIT_LCD(){
637
    outLCD_CMD(INITCMD);
638
    outLCD_CMD(DISPCONT);
639
    outLCD_CMD(DISPCLR);
640
    outLCD_CMD(ECURINC);
641
    outLCD_CMD(DISPCONT|BLINK|CURON|DISPON);
642
}
643
 
644
#if 0
645
static void MAIN(){
646
    int     i;
647
    static  char   c[]="JMZ-LCD202 LCD UNIT";
648
    static  char   d[]="Display Test Sample";
649
 
650
    INIT_LCD();
651
    outLCD_CMD(DDRAM);
652
        for (i=0;i<20;i++) outLCD(c[i]);
653
    outLCD_CMD(DDRAM+0x40);
654
        for (i=0;i<20;i++) outLCD(d[i]);
655
}
656
#endif
657
 
658
#define LCD_LINE0       0x00
659
#define LCD_LINE1       0x40
660
 
661
#define LCD_LINE_LENGTH 20
662
 
663
static char lcd_line0[LCD_LINE_LENGTH+1];
664
static char lcd_line1[LCD_LINE_LENGTH+1];
665
static char *lcd_line[2] = { lcd_line0, lcd_line1 };
666
static int lcd_curline = 0;
667
static int lcd_linepos = 0;
668
 
669
static void lcd_dis(int add, char *string);
670
 
671
void hal_diag_init()
672
{
673
    int i;
674
//hal_diag_led(0x10);    
675
 
676
    INIT_LCD();
677
 
678
    lcd_curline = 0;
679
    lcd_linepos = 0;
680
 
681
    for( i = 0; i < LCD_LINE_LENGTH; i++ )
682
        lcd_line[0][i] = lcd_line[1][i] = ' ';
683
 
684
    lcd_line[0][LCD_LINE_LENGTH] = lcd_line[1][LCD_LINE_LENGTH] = 0;
685
 
686
    lcd_dis( LCD_LINE0, lcd_line[0] );
687
    lcd_dis( LCD_LINE1, lcd_line[1] );
688
 
689
#if 0    
690
    {
691
        int     i;
692
        static  char   c[]="JMZ-LCD202 LCD UNIT";
693
        static  char   d[]="Display Test Sample";
694
 
695
        outLCD_CMD(DDRAM);
696
        for (i=0;i<20;i++) outLCD(c[i]);
697
        outLCD_CMD(DDRAM+0x40);
698
        for (i=0;i<20;i++) outLCD(d[i]);
699
    }
700
#endif
701
 
702
//hal_diag_led(0x10);
703
}
704
 
705
/* this routine writes the string to the LCD */
706
/* display after setting the address to add */
707
static void lcd_dis(int add, char *string)
708
{
709
    int i;
710
 
711
    outLCD_CMD(DDRAM+add);
712
 
713
    for (i=0 ; i<LCD_LINE_LENGTH ; i++) outLCD(string[i]);
714
}
715
 
716
void hal_diag_write_char( char c)
717
{
718
    int i;
719
 
720
//hal_diag_led(0x20);
721
 
722
    // Truncate long lines
723
    if( lcd_linepos >= LCD_LINE_LENGTH ) return;
724
 
725
    // ignore CR
726
    if( c == '\r' ) return;
727
 
728
    if( c == '\n' )
729
    {
730
        lcd_dis( LCD_LINE0, &lcd_line[lcd_curline^1][0] );
731
        lcd_dis( LCD_LINE1, &lcd_line[lcd_curline][0] );
732
 
733
        // Do a line feed
734
        lcd_curline ^= 1;
735
        lcd_linepos = 0;
736
 
737
        for( i = 0; i < LCD_LINE_LENGTH; i++ )
738
            lcd_line[lcd_curline][i] = ' ';
739
 
740
        return;
741
    }
742
 
743
    lcd_line[lcd_curline][lcd_linepos++] = c;
744
 
745
//hal_diag_led(0x20);
746
}
747
 
748
void hal_diag_read_char(char *c)
749
{
750
//hal_diag_led(0x40);        
751
 
752
//hal_diag_led(0x40);
753
}
754
 
755
 
756
#endif
757
 
758
 
759
/*---------------------------------------------------------------------------*/
760
/* End of hal_diag.c */

powered by: WebSVN 2.1.0

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