OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / demos / voice-pager / lcd-driver.h
1 // lcd-driver.h - 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 #ifndef LCD_DRIVER_DEFH
8 #define LCD_DRIVER_DEFH
9
10 class lcd_driver 
11  {
12
13  private:
14     volatile unsigned char* const DATA_REG;
15     volatile unsigned char* const CMD_REG;
16     volatile unsigned char* const STATUS_REG;
17
18    enum lcd_status
19     {           // status byte
20       STA0      = 0x1,  // set if ready to take next command
21       STA1      = 0x2,  // set if memory ready
22       STA2      = 0x4,  // set if auto read
23       STA3      = 0x8,  // set if auto write
24       STA6      = 0x40, // set if peek/poke error
25       STA7      = 0x80, // set if display on
26     };
27     
28     enum lcd_size 
29      {
30        NCOLS = 32,
31        NROWS =  6
32      };
33
34  public: 
35    enum lcd_cmds 
36     {
37       SET_CURSOR        = 0x21,
38       SET_OFFSET        = 0x22,
39       SET_ADP           = 0x24,
40       SET_TXT_HOME      = 0x40,
41       SET_TXT_AREA      = 0x41,
42       SET_GRX_HOME      = 0x42,
43       SET_GRX_AREA      = 0x43,
44       SET_AWRITE        = 0xb0,
45       SET_AREAD         = 0xb1,
46       CLR_AUTO_RW       = 0xb2,
47       DWRITE_INC        = 0xc0,
48       DREAD_INC         = 0xc1,
49       DWRITE_DEC        = 0xc2,
50       DREAD_DEC         = 0xc3,
51       DWRITE            = 0xc4,
52       DREAD             = 0xc5
53    };
54
55    lcd_driver();
56    bool send_cmd( unsigned char cmd );
57
58    bool auto_write( unsigned char data );
59    bool auto_read( unsigned char& data );
60    bool reset_auto( unsigned char mode );
61
62    bool write_mem( unsigned char cmd, unsigned char data );
63    bool read_mem( unsigned char cmd, unsigned char& data );
64
65    bool set_word_reg( unsigned char cmd, unsigned char lo, unsigned char hi );
66    void mem_set( unsigned char val, unsigned addr, int len );
67    unsigned get_numcols() { return NCOLS;}
68    unsigned get_numrows() { return NROWS;}
69    //   void initialize_lcd();
70
71
72  private:
73    bool check_status( unsigned char what );
74    bool send_data( unsigned char data );
75    bool get_data ( unsigned char& data );
76
77  };
78
79 #endif // LCD_DRIVER_DEFH