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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [tx39/] [current/] [src/] [hal_diag.c] - Blame information for rev 786

Details | Compare with Previous | View Log

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