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

📄 lcd_io.lst

📁 ST公司的upsd34XX评估板固定源程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 221   5                          LCD_index = 0;
 222   5                      }
 223   4                              }
 224   3                  else if (*chr_ptr == 'x') 
 225   3                  {
 226   4                      // Display 1 byte hex 00-FF
 227   4                                      chr_ptr++;
 228   4      
 229   4                      var = *var_ptr++;
 230   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 231   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_hi(var);
 232   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 233   4                      {
 234   5                          LCD_index = 0;
 235   5                      }
 236   4                      BusyCheck();
 237   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 238   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_lo(var);
 239   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 240   4                      {
 241   5                          LCD_index = 0;
C51 COMPILER V7.06   LCD_IO                                                                10/10/2004 20:51:47 PAGE 5   

 242   5                      }
 243   4                              }
 244   3                              else if (*chr_ptr == 'w') 
 245   3                  {           
 246   4                      // Display 1 word hex 0000-FFFF
 247   4                                      chr_ptr++;
 248   4      
 249   4                      var = *var_ptr++;
 250   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 251   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_hi(var);
 252   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 253   4                      {
 254   5                          LCD_index = 0;
 255   5                      }
 256   4                      BusyCheck();
 257   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 258   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_lo(var);
 259   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 260   4                      {
 261   5                          LCD_index = 0;
 262   5                      }
 263   4      
 264   4                      BusyCheck();
 265   4                      
 266   4                      var = *var_ptr++;
 267   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 268   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_hi(var);
 269   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 270   4                      {
 271   5                          LCD_index = 0;
 272   5                      }
 273   4                      BusyCheck();
 274   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 275   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_lo(var);
 276   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 277   4                      {
 278   5                          LCD_index = 0;
 279   5                      }
 280   4                              }
 281   3                              else 
 282   3                  {
 283   4                      // Out character to LCD Display RAM                
 284   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = *chr_ptr++;
 285   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 286   4                      {
 287   5                          LCD_index = 0;
 288   5                      }
 289   4                      }
 290   3                      }
 291   2                      else
 292   2                      {
 293   3                  // Out character to LCD Display RAM                         
 294   3                  LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = *chr_ptr++;
 295   3                  if (LCD_index >= LCD_BUFFER_SIZE)
 296   3                  {
 297   4                      LCD_index = 0;
 298   4                  }
 299   3                      }
 300   2              }
 301   1      }
 302          
 303          //  These are the LCD functions.
C51 COMPILER V7.06   LCD_IO                                                                10/10/2004 20:51:47 PAGE 6   

 304          /*
 305          void lcd_clear(void)                    // clear all characters from display   
 306                  {
 307                  BusyCheck();
 308                  LCD_reg.LCD_CMD_WR = 0x01;
 309                  Cursor_LCD = DD_ADDR;
 310                  }
 311          
 312          void lcd_string_display(row,col,string)         
 313                                          // send string to LCD   
 314                                          // row = 0 is top row   
 315                                          // row = 1 is bottom    
 316                                          // col = 0 to 15            
 317                                          // length = string length   
 318                                          // string points to char array   
 319          uchar row;
 320          uchar col;
 321          uchar *string;
 322                  {
 323                  char k;
 324                  k = 0;
 325                  lcd_cursor_set(row,col);        // position cursor   
 326                  while (k < LCD_LINE_LENGTH+1 && *string)        // truncate string to 16 
 327                                                  // or end of string   
 328                          {
 329                          BusyCheck();
 330                          LCD_reg.LCD_RAM_WR = *string++; // send character   
 331                          k++;
 332                          }
 333                  }
 334          
 335          
 336          void lcd_char_display(row,col,ch)       // send single char to LCD   
 337                                                  // row = 0 is top row   
 338                                                  // row = 1 is bottom    
 339                                                  // col = 0 to 15            
 340          uchar row;
 341          uchar col;
 342          char ch;
 343                  {
 344                  lcd_cursor_set(row,col);        // position cursor   
 345                  BusyCheck();
 346                  LCD_reg.LCD_RAM_WR = ch;                        // send character   
 347                  }
 348          
 349                  
 350          void lcd_cursor_set(row,col)    // move cursor to desired position   
 351          uchar row;
 352          uchar col;
 353                  
 354                  {
 355                  BusyCheck();
 356                  switch(row)
 357                          {
 358                          case 0:
 359                                  LCD_reg.LCD_CMD_WR = (0x80 + col);
 360                                  break;
 361                                  
 362                          case 1:
 363                                  LCD_reg.LCD_CMD_WR = (0xC0 + col);
 364                                  break;
 365                          }
C51 COMPILER V7.06   LCD_IO                                                                10/10/2004 20:51:47 PAGE 7   

 366                  }
 367          */
 368          
 369          
 370          // this is a collection of conversion routines used in conjunction with the LCD display
 371          /*
 372          static char Bin2Hex(char temp) {
 373          
 374                  if (temp <= 9) temp += '0'; else temp=(temp-10)+'A';
 375                  return (temp);
 376          }
 377          */
 378          
 379          static char htoa_lo(byte)        // converts low nibble of unsigned byte
 380                                                                   // (0-F hex) to ascii   
 381          uchar byte;
 382                  {
 383   1              byte = byte & 0x0F;     // keep lower nibble only   
 384   1              if (byte <= 0x09)
 385   1                      return(byte + 0x30);
 386   1              else
 387   1                      return (byte + 0x37);
 388   1              }
 389          
 390          /*
 391          static char lhtoa_lo(word)       // converts 2nd nibble of unsigned int
 392                                                                   // (0-F hex) to ascii   
 393          unsigned int word;
 394                  {
 395                  word = word >> 8;
 396                  word = word & 0x000F;
 397                  if (word <= 0x0009)
 398                          return((char)word + 0x30);
 399                  else
 400                          return ((char)word + 0x37);
 401                  }
 402          */
 403          
 404          static char htoa_hi(byte)        // converts hi nibble of unsigned byte
 405                                                                   // (0-F hex) to ascii   
 406          uchar byte;
 407                  {
 408   1              byte = byte & 0xF0;     // keep upper nibble only   
 409   1              byte = byte >> 4;
 410   1              if (byte <= 0x09)
 411   1                      return(byte + 0x30);
 412   1              else
 413   1                      return (byte + 0x37);
 414   1              }
 415          
 416          /*
 417          static char lhtoa_hi(word)       // converts 1st nibble of unsigned int
 418                                                                   // (0-F hex) to ascii   
 419          unsigned int word;
 420                  {
 421                  word = word >> 12;
 422                  word = word & 0x000F;
 423                  if (word <= 0x0009)
 424                          return((char)word + 0x30);
 425                  else
 426                          return ((char)word + 0x37);
 427                  }
C51 COMPILER V7.06   LCD_IO                                                                10/10/2004 20:51:47 PAGE 8   

 428          */
 429          
 430          
 431          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1025    ----
   CONSTANT SIZE    =     57    ----
   XDATA SIZE       =     38      50
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =      1    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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