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

📄 uart_dv.lst

📁 small pannel driver using MXIC s 88LV462,this sample code including the function IIC with 8051,IR,OS
💻 LST
📖 第 1 页 / 共 3 页
字号:
 339   1              send_length = 0;
 340   1              PrepareSendBuf(sendtemp, 0, 0, ACK);
 341   1              switch(rx_pack->cmd)    //parse COMMAND
 342   1              {
 343   2                      case GETDEV:
 344   2                              for (i=0; i<16; i++)
 345   2                                      sendtemp[i+16] = DEV_Inf[i];    
 346   2                                              //--- Pack the Resopnd Cmd and Data ---
 347   2                              PrepareSendBuf(&sendtemp[8], rx_pack->addr, 16, DEVICEINF);
 348   2                              send_length = UART_PACK_SIZE + 16;
 349   2                              break;
 350   2      
 351   2                      case MEMRD:
 352   2                              ExtMemPtr = Rx_Buf[0];
 353   2                              for (i=0; i<rx_pack->length; i++)
 354   2                                      sendtemp[i+16] = *(ExtMemPtr+rx_pack->addr+i);
 355   2                                              //--- Pack the Resopnd Cmd and Data ---
 356   2                              PrepareSendBuf(&sendtemp[8], rx_pack->addr, rx_pack->length, MEMRP);
 357   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 358   2                              break;
 359   2                              
 360   2                      case MEMWR:
 361   2                              ExtMemPtr = Rx_Buf[0];
 362   2                              for (i=0; i<rx_pack->length; i++)
 363   2                                      *(ExtMemPtr+rx_pack->addr+i)= Rx_Buf[buf_index][i+8];
 364   2                              break;  
C51 COMPILER V7.01  UART_DV                                                                07/14/2005 15:18:37 PAGE 7   

 365   2                              
 366   2                      case REGRD15xx:         
 367   2                                              //--- Pack the Resopnd Cmd and Data ---                                 
 368   2                              I2C_Read(L44_WRID, rx_pack->addr, rx_pack->length, &sendtemp[16]);              
 369   2                              PrepareSendBuf(&sendtemp[8],rx_pack->addr,rx_pack->length,rx_pack->cmd|0x40);
 370   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 371   2                              break;
 372   2                              
 373   2                      case REGWR15xx:         //Read data from 15xx Reg.
 374   2                              I2C_WriteByte(L44_WRID, rx_pack->addr, Rx_Buf[buf_index][8]);
 375   2                              break;
 376   2                              
 377   2                      case RDEEPROM:          //Read data from EEPROM
 378   2                              i = (BYTE)((rx_pack->addr>>7) & 0x000E);        
 379   2                              I2C_Read(EEPROM_WRID|i, rx_pack->addr, rx_pack->length, &sendtemp[16]);         
 380   2                              PrepareSendBuf(&sendtemp[8],rx_pack->addr,rx_pack->length,rx_pack->cmd|0x40);
 381   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 382   2                              break;
 383   2                              
 384   2                      case WREEPROM:          //Write data to EEPROM
 385   2                              i = (BYTE)((rx_pack->addr>>7) & 0x000E);
 386   2                              I2C_WriteByte(EEPROM_WRID|i, rx_pack->addr, Rx_Buf[buf_index][8]);
 387   2                              break;
 388   2                              
 389   2                      case RDGAMMA:           //Read 768bytes data from Gamma port and Respond to PC
 390   2                              if (rx_pack->addr == 0) 
 391   2                                      I2C_WriteByte(L44_WRID, 0x11, 0xF6);    //Enable Gamma correction and access
 392   2                              
 393   2                              for (i=0; i<rx_pack->length; i++)                               
 394   2                                      sendtemp[i+16] = I2C_ReadByte(L44_WRID, 0x1B);
 395   2                              PrepareSendBuf(&sendtemp[8],rx_pack->addr,rx_pack->length,rx_pack->cmd|0x40);
 396   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 397   2                              
 398   2                              if (rx_pack->addr >= 0x2F0)     
 399   2                                      I2C_WriteByte(L44_WRID, 0x11, 0xFA);    //disable Gamma correction and access
 400   2                              break;
 401   2                              
 402   2                      case WRGAMMA:           //Write 768bytes data to Gamma port from PC     
 403   2                              if (rx_pack->addr == 0)
 404   2                                      I2C_WriteByte(L44_WRID, 0x11, 0xF6);    //Enable Gamma correction and access
 405   2                                      
 406   2                              for (i=0; i<rx_pack->length; i++)       
 407   2                                      I2C_WriteByte(L44_WRID, 0x1B, Rx_Buf[buf_index][8+i]);
 408   2                                      
 409   2                              if (rx_pack->addr >= 0x2F0)     
 410   2                                      I2C_WriteByte(L44_WRID, 0x11, 0xFA);    //disable Gamma correction and access
 411   2                              break;
 412   2                              
 413   2                                              // **********************
 414   2                                              // ***--- Indirect ---***
 415   2                                              // **********************
 416   2                      case REGRDOSDCtrl:              //respond the OSD Control Reg. from rx_pack->addr
 417   2                              Read_OSDReg(&sendtemp[16], 0x00, rx_pack->length, rx_pack->addr);
 418   2                                              //--- Pack the Resopnd Cmd and Data ---
 419   2                              PrepareSendBuf(&sendtemp[8],rx_pack->addr,rx_pack->length,rx_pack->cmd|0x40);
 420   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 421   2                              break;
 422   2                              
 423   2                      case REGRDOSDCode:              //respond the OSD Code Reg. from rx_pack->addr
 424   2                              Read_OSDReg(&sendtemp[16], 0x02, rx_pack->length, rx_pack->addr);
 425   2                                              //--- Pack the Resopnd Cmd and Data ---
 426   2                              PrepareSendBuf(&sendtemp[8],rx_pack->addr,rx_pack->length,rx_pack->cmd|0x40);
C51 COMPILER V7.01  UART_DV                                                                07/14/2005 15:18:37 PAGE 8   

 427   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 428   2                              break;
 429   2                              
 430   2                      case REGRDOSDAttr:              //respond the OSD Attr. Reg. from rx_pack->addr
 431   2                              Read_OSDReg(&sendtemp[16], 0x03, rx_pack->length, rx_pack->addr);
 432   2                                              //--- Pack the Resopnd Cmd and Data ---
 433   2                              PrepareSendBuf(&sendtemp[8],rx_pack->addr,rx_pack->length,rx_pack->cmd|0x40);
 434   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 435   2                              break;
 436   2      
 437   2                      case REGRDTVDecoder:    //respond the TV Decoder Reg. from rx_pack->addr
 438   2                              for (i=0; i<rx_pack->length; i++)
 439   2                                      sendtemp[i+16] = CVD1_ReadWrite(0x00, rx_pack->addr+i, 0x00);
 440   2      //                      I2C_Read(TVP5146_WRID, rx_pack->addr, rx_pack->length, &sendtemp[16]);
 441   2                                              //--- Pack the Resopnd Cmd and Data ---
 442   2                              PrepareSendBuf(&sendtemp[8], rx_pack->addr, rx_pack->length, REGRPTVDecoder);
 443   2                              send_length = UART_PACK_SIZE + rx_pack->length;
 444   2                              break;
 445   2      /*
 446   2                      case REGRDTVTuner:
 447   2                              for (i=0; i<(rx_pack->length); i++)
 448   2                              {
 449   2                                      sendtemp[i+UART_PACK_SIZE]
 450   2                                                              =       rd_HXT5G01A();
 451   2                              }
 452   2                              PrepareSendBuf(sendtemp, 0, 0, ACK);
 453   2                              PrepareSendBuf(&sendtemp[8], rx_pack->addr, rx_pack->length, REGRPTVTuner);
 454   2                              UART_SendOut(sendtemp, 16+rx_pack->length);
 455   2                              break;
 456   2      */
 457   2                      case REGWROSDCtrl:              //write data to OSD Control Reg.
 458   2                              Write_OSDReg(&Rx_Buf[buf_index][8], 0x00, 0x01, rx_pack->addr);
 459   2                              break;
 460   2                      case REGWROSDCode:              //write data to OSD Code Reg.
 461   2                              Write_OSDReg(&Rx_Buf[buf_index][8], 0x02, 0x01, rx_pack->addr);
 462   2                              break;          
 463   2                      case REGWROSDAttr:              //write data to OSD Attr. Reg.
 464   2                              Write_OSDReg(&Rx_Buf[buf_index][8], 0x03, 0x01, rx_pack->addr);
 465   2                              break;
 466   2                              
 467   2                      case REGWRTVDecoder:    //write data to TV Decoder Reg.
 468   2                              CVD1_ReadWrite(0x01, rx_pack->addr, Rx_Buf[buf_index][8]);
 469   2                              break;
 470   2      /*
 471   2                      case REGWRTVTuner:
 472   2                              PrepareSendBuf(sendtemp, 0, 0, ACK);
 473   2                              UART_SendOut( sendtemp, UART_PACK_SIZE);
 474   2                              wr_HXT5G01A(1);                                                 // int i--> index
 475   2                              P1=~(REGWRTVTuner);
 476   2                              break;
 477   2      */
 478   2                      case NACK:
 479   2                              UARTFlag |= TX_FLAG;                    //set flag for send
 480   2      /*
 481   2                              for (i=0; i<ReTx_Length; i++)   //copy send data to TX buffer
 482   2                                      Tx_Buf[i] = ReTx_Buf[i];
 483   2                              Tx_Length = ReTx_Length;                //copy sending data length
 484   2      */
 485   2                              Tx_Index = 1;
 486   2                              SBUF=Tx_Buf[0];
 487   2                              return;
 488   2      
C51 COMPILER V7.01  UART_DV                                                                07/14/2005 15:18:37 PAGE 9   

 489   2                      default:                                        //not define command will reset flag
 490   2                              UARTFlag = 0;
 491   2                              Rx_Index = 0;
 492   2                              P1=~(0xFF);
 493   2                              return;
 494   2              }       
 495   1              UART_SendOut(sendtemp, UART_PACK_SIZE+send_length);     
 496   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2905    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      4      57
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   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 + -