OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / lcd / testsuite / lcd-ex.c
1 // lcd-ex.cxx - description.  -*- C++ -*-
2
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
6
7 #include <stdio.h>
8
9 enum {
10   LCD_IR = 0,
11   LCD_AC = 0,
12   LCD_DR = 4
13 };
14
15 #define LCD_BASE        0x800040        // base address for LCD
16
17 char logo[] = { 0x3, 0x4, 0x9, 0xa, 0xa, 
18                 0xa, 0xa, 0x9, 0x4, 0x3, 0x0, 0x0, 0x0, 
19                 0x0, 0x0, 0x0, 0x18, 0x4, 0x13, 0x0b, 0x0, 
20                 0x0, 0xa, 0x13, 0x4, 0x18 };
21
22 int
23 main( int argc, char* argv[] ) {
24   int i;
25   volatile char *lcd = (volatile char*) LCD_BASE;
26   char *str = "cygnus";
27   char *p = str;
28
29   lcd[LCD_IR] = 0x38;           // 2-lines, 5X8 font
30   lcd[LCD_IR] = 1;              // clear display
31   lcd[LCD_IR] = 0x0c;           // enable display
32   lcd[LCD_IR] = 0x43;           // set AC to CGRAM char 0 line 3
33
34   for( i=0; i<26; i++ )         // create logo         
35     lcd[LCD_DR] = logo[i];
36
37   lcd[LCD_IR] = 0x80;           // select DDRAM address 0
38
39   lcd[LCD_DR] = 0;              // write first line
40   lcd[LCD_DR] = 2;
41
42   while( *p )
43     lcd[LCD_DR] = *p++;
44
45   lcd[LCD_IR] = 0xc0;           // select start of second line
46
47   lcd[LCD_DR] = 1;              // write second line
48   lcd[LCD_DR] = 3;
49
50   str = "rules!";
51   p = str;
52
53   while( *p )
54     lcd[LCD_DR] = *p++;
55
56   printf( "should see \"cygnus rules!\"\n" );
57   while( 1 );
58 }