⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lm3228.lst

📁 别人的C51菜单程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.08   LM3228                                                                06/30/2007 15:23:46 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE LM3228
OBJECT MODULE PLACED IN lm3228.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE lm3228.c LARGE OPTIMIZE(9,SPEED) DEBUG OBJECTEXTEND

line level    source

   1          #include <at89c51xd2.h>
   2          #include <absacc.h>
   3          #include <intrins.h>
   4          #include "common.h"
   5          
   6          #define SCREEN_WIDTH 0x20
   7          
   8          
   9          extern struct Pic *point_pic1;
  10          /********************************************************************************************/
  11          #define COMMAND_PORT XBYTE[0x8001] //定义命令端口地址
  12          #define DATA_PORT XBYTE[0x8000]    //定义数据端口地址
  13          #define CODESTATE 0x01 //定义检测位
  14          #define DATASTATE 0x02
  15          #define DATAAUTOREAD 0x04
  16          #define DATAAUTOWRITE 0x08
  17          #define CONTROLLER  0x20
  18          #define SCREENCOPY 0x40
  19          #define BLINKCONTITION 0x80
  20          
  21          /********************************************************************************************/
  22          //检查状态
  23          volatile bit check_state(uchar check_bit) 
  24          {
  25   1              uchar state;
  26   1              state=COMMAND_PORT;
  27   1              switch(check_bit)
  28   1              {
  29   2                      case CODESTATE:
  30   2                      {
  31   3                              if(state&0x01)
  32   3                              return 1;
  33   3                              else
  34   3                              return 0;
  35   3                      }
  36   2                      case DATASTATE:
  37   2                      {
  38   3                              if(state&0x02)
  39   3                              return 1;
  40   3                              else
  41   3                              return 0;
  42   3                      }                        
  43   2                      case DATAAUTOREAD:
  44   2                      {
  45   3                              if(state&0x04)
  46   3                              return 1;
  47   3                              else
  48   3                              return 0;
  49   3                      }
  50   2                      case DATAAUTOWRITE:
  51   2                      {
  52   3                              if(state&0x08)
  53   3                              return 1;
  54   3                              else
  55   3                              return 0;
C51 COMPILER V8.08   LM3228                                                                06/30/2007 15:23:46 PAGE 2   

  56   3                      }
  57   2                      case CONTROLLER:
  58   2                      {
  59   3                              if(state&0x02)
  60   3                              return 1;
  61   3                              else
  62   3                              return 0;
  63   3                      }
  64   2                      case SCREENCOPY:
  65   2                      {
  66   3                              if(state&0x40)
  67   3                              return 0;
  68   3                              else
  69   3                              return 1;
  70   3                      }
  71   2                      case BLINKCONTITION:
  72   2                      {
  73   3                              if(state&0x80)
  74   3                              return 1;
  75   3                              else
  76   3                              return 0;
  77   3                      }
  78   2                              
  79   2              }
  80   1      }
  81          /********************************************************************************************/
  82          //判断自动写
  83          void check_auto_write(void)     reentrant
  84          {
  85   1              while(!(check_state(DATAAUTOWRITE)));
  86   1      }
  87          /********************************************************************************************/
  88          volatile void check_code_data(void) reentrant
  89          {
  90   1              while(!(check_state(CODESTATE)));
  91   1              while(!(check_state(DATASTATE)));
  92   1      }
  93          /********************************************************************************************/
  94          //指针设置
  95          #define SET_CURSOR_POINTER 0x01         //设置光标位置
  96          #define SET_CGRAM_POINTER 0X02          //设置CGRAM
  97          #define SET_ADDRESS_POINTER 0x04
  98          void set_point(uchar i,uchar data dat1,uchar data dat2) //向外部输出的数要定义在 data  区中
  99          {
 100   1              check_code_data();      
 101   1              DATA_PORT=dat1;
 102   1              check_code_data();
 103   1              DATA_PORT=dat2;
 104   1              check_code_data();
 105   1              COMMAND_PORT=(0x20|i);
 106   1      }
 107          /********************************************************************************************/
 108          //设置显示模式
 109          #define LOGIC_OR 0x00
 110          #define LOGIC_XOR 0x01
 111          #define LOGIC_AND 0x02
 112          #define TEXT_CHAR 0x04
 113          void set_display_mode(uchar dat)
 114          {
 115   1              check_code_data();
 116   1              COMMAND_PORT=(0x80|dat);
 117   1      }
C51 COMPILER V8.08   LM3228                                                                06/30/2007 15:23:46 PAGE 3   

 118          /********************************************************************************************/
 119          //显示区域设置
 120          #define TEXT_ADDRESS 0x00                               //设置文本区首址
 121          #define TEXT_WIDTH 0x01                                 //设置文本区宽度
 122          #define GRAPHIC_ADDRESS 0x02                    //设置图形区首址
 123          #define GRAPHIC_WIDTH 0x03                              //设置图形区宽度
 124          void set_display_area(uchar i,uchar dat1,uchar dat2)
 125          {
 126   1              if((i==0x01)||(i==0x03))
 127   1                      dat2=0;
 128   1              check_code_data();
 129   1              DATA_PORT=dat1;
 130   1              check_code_data();
 131   1              DATA_PORT=dat2;
 132   1              check_code_data();
 133   1              COMMAND_PORT=(0x40|i);
 134   1      }
 135          /********************************************************************************************/
 136          //显示开关设置
 137          #define CURSORBLINK 0x01
 138          #define CURSORON 0x02
 139          #define TEXTON 0x04
 140          #define GRAPHICON 0x08
 141          
 142          void set_display(uchar displaymode)
 143          {
 144   1              check_code_data();
 145   1              COMMAND_PORT=(displaymode|0x90);
 146   1      }
 147          /********************************************************************************************/
 148          //光标形状设置
 149          //参数0-7
 150          void set_cursor(uchar i)
 151          {
 152   1              check_code_data();
 153   1              COMMAND_PORT=(0xa0|i);
 154   1      }
 155          /********************************************************************************************/
 156          //自动读写定义
 157          #define AUTOWRITE 0x00
 158          #define AUTOREAD 0x01
 159          #define AUTOSTOP 0x02
 160          void set_autoreadwrite(uchar i) //reentrant
 161          {
 162   1              check_code_data();
 163   1              COMMAND_PORT=(0xb0|i);
 164   1      }
 165          /********************************************************************************************/
 166          //一次读写定义
 167          #define write_address_add 0x00
 168          #define read_address_add 0x01
 169          #define write_address_sub 0x02
 170          #define read_address_sub 0x03
 171          #define write_address_nochange 0x04
 172          #define read_address_nochange 0x05
 173          /*&void set_once_read_write(uchar i,uchar letter)
 174          {
 175                  check_code_data();
 176                  DATA_PORT=letter;
 177                  check_code_data();
 178                  COMMAND_PORT=(0xc0|i);
 179          }*/
C51 COMPILER V8.08   LM3228                                                                06/30/2007 15:23:46 PAGE 4   

 180          
 181          /********************************************************************************************/
 182          //屏读
 183          /*void screen_read(void)
 184          {
 185                  check_code_data();
 186                   COMMAND_PORT=0xe0;
 187          }*/
 188          
 189          /********************************************************************************************/
 190          //屏拷贝
 191          /*void screen_copy(void)
 192          {
 193                  check_code_data();
 194                  COMMAND_PORT=0xe8;
 195          }*/
 196          /********************************************************************************************/
 197          //位操作
 198          //#define set_bit 0x08
 199          //#define clear_bit 0x00
 200          /*void bit_operation(uchar op,uchar i)
 201          {
 202                  check_code_data();
 203                  COMMAND_PORT=(0xf0|op|i);
 204          }*/
 205          /********************************************************************************************/
 206          /*void print_lcd(uchar str,uchar x,uchar y)
 207          {
 208                  unsigned int addr;
 209                  addr=y*16+x;
 210          
 211                  check_code_data();
 212                  DATA_PORT=addr;
 213                  check_code_data();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -