找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5731|回复: 5
打印 上一主题 下一主题
收起左侧

用STM32单片机开发2.8寸LCD模块ILI9341资料代码分享

[复制链接]
跳转到指定楼层
楼主
里面包含了LCD模块底层代码与原理图等,方便大家进行开发

所有资料51hei提供下载:
15,2.8寸TFT LCD模块资料(ILI9341).7z (7.94 MB, 下载次数: 188)


单片机源程序如下:
  1. #include "lcd.h"
  2. #include "stdlib.h"
  3. #include "font.h"
  4. #include "usart.h"         
  5. #include "delay.h"          

  6. //V1.2修改说明
  7. //支持了SPFD5408的驱动,另外把液晶ID直接打印成HEX格式.方便查看LCD驱动IC.
  8. //V1.3
  9. //加入了快速IO的支持
  10. //修改了背光控制的极性(适用于V1.8及以后的开发板版本)
  11. //对于1.8版本之前(不包括1.8)的液晶模块,请修改LCD_Init函数的LCD_LED=1;为LCD_LED=1;
  12. //V1.4
  13. //修改了LCD_ShowChar函数,使用画点功能画字符。
  14. //加入了横竖屏显示的支持
  15. //V1.5 20110730
  16. //1,修改了B505液晶读颜色有误的bug.
  17. //2,修改了快速IO及横竖屏的设置方式.
  18. //V1.6 20111116
  19. //1,加入对LGDP4535液晶的驱动支持
  20. //V1.7 20120713
  21. //1,增加LCD_RD_DATA函数
  22. //2,增加对ILI9341的支持
  23. //3,增加ILI9325的独立驱动代码
  24. //4,增加LCD_Scan_Dir函数(慎重使用)          
  25. //6,另外修改了部分原来的函数,以适应9341的操作
  26. //V1.8 20120905
  27. //1,加入LCD重要参数设置结构体lcddev
  28. //2,加入LCD_Display_Dir函数,支持在线横竖屏切换
  29. //V1.9 20120911
  30. //1,新增RM68042驱动(ID:6804),但是6804不支持横屏显示!!原因:改变扫描方式,
  31. //导致6804坐标设置失效,试过很多方法都不行,暂时无解。
  32. //V2.0 20120924
  33. //在不硬件复位的情况下,ILI9341的ID读取会被误读成9300,修改LCD_Init,将无法识别
  34. //的情况(读到ID为9300/非法ID),强制指定驱动IC为ILI9341,执行9341的初始化。
  35. //V2.1 20120930
  36. //修正ILI9325读颜色的bug。
  37. //V2.2 20121007
  38. //修正LCD_Scan_Dir的bug。
  39. //V2.3 20130120
  40. //新增6804支持横屏显示
  41. //V2.4 20131120
  42. //1,新增NT35310(ID:5310)驱动器的支持
  43. //2,新增LCD_Set_Window函数,用于设置窗口,对快速填充,比较有用,但是该函数在横屏时,不支持6804.
  44. //V2.5 20140211
  45. //1,新增NT35510(ID:5510)驱动器的支持
  46. //V2.6 20140504
  47. //1,新增ASCII 24*24字体的支持(更多字体用户可以自行添加)  
  48. //2,修改部分函数参数,以支持MDK -O2优化
  49. //3,针对9341/35310/35510,写时间设置为最快,尽可能的提高速度
  50. //4,去掉了SSD1289的支持,因为1289实在是太慢了,读周期要1us...简直奇葩.不适合F4使用
  51. //5,修正68042及C505等IC的读颜色函数的bug.
  52. //V2.7 20140710
  53. //1,修正LCD_Color_Fill函数的一个bug.
  54. //2,修正LCD_Scan_Dir函数的一个bug.
  55. //V2.8 20140721
  56. //1,解决MDK使用-O2优化时LCD_ReadPoint函数读点失效的问题.
  57. //2,修正LCD_Scan_Dir横屏时设置的扫描方式显示不全的bug.
  58. //V2.9 20141130
  59. //1,新增对SSD1963 LCD的支持.
  60. //2,新增LCD_SSD_BackLightSet函数
  61. //3,取消ILI93XX的Rxx寄存器定义
  62. //////////////////////////////////////////////////////////////////////////////////         

  63. //LCD的画笔颜色和背景色          
  64. u16 POINT_COLOR=0x0000;        //画笔颜色
  65. u16 BACK_COLOR=0xFFFF;  //背景色
  66.   
  67. //管理LCD重要参数
  68. //默认为竖屏
  69. _lcd_dev lcddev;
  70.          
  71. //写寄存器函数
  72. //regval:寄存器值
  73. void LCD_WR_REG(u16 regval)
  74. {   
  75.         LCD->LCD_REG=regval;//写入要写的寄存器序号         
  76. }
  77. //写LCD数据
  78. //data:要写入的值
  79. void LCD_WR_DATA(u16 data)
  80. {         
  81.         LCD->LCD_RAM=data;                 
  82. }
  83. //读LCD数据
  84. //返回值:读到的值
  85. u16 LCD_RD_DATA(void)
  86. {
  87.         vu16 ram;                        //防止被优化
  88.         ram=LCD->LCD_RAM;       
  89.         return ram;         
  90. }                                          
  91. //写寄存器
  92. //LCD_Reg:寄存器地址
  93. //LCD_RegValue:要写入的数据
  94. void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
  95. {       
  96.         LCD->LCD_REG = LCD_Reg;                //写入要写的寄存器序号         
  97.         LCD->LCD_RAM = LCD_RegValue;//写入数据                             
  98. }          
  99. //读寄存器
  100. //LCD_Reg:寄存器地址
  101. //返回值:读到的数据
  102. u16 LCD_ReadReg(u16 LCD_Reg)
  103. {                                                                                  
  104.         LCD_WR_REG(LCD_Reg);                //写入要读的寄存器序号
  105.         delay_us(5);                  
  106.         return LCD_RD_DATA();                //返回读到的值
  107. }   
  108. //开始写GRAM
  109. void LCD_WriteRAM_Prepare(void)
  110. {
  111.         LCD->LCD_REG=lcddev.wramcmd;          
  112. }         
  113. //LCD写GRAM
  114. //RGB_Code:颜色值
  115. void LCD_WriteRAM(u16 RGB_Code)
  116. {                                                            
  117.         LCD->LCD_RAM = RGB_Code;//写十六位GRAM
  118. }
  119. //从ILI93xx读出的数据为GBR格式,而我们写入的时候为RGB格式。
  120. //通过该函数转换
  121. //c:GBR格式的颜色值
  122. //返回值:RGB格式的颜色值
  123. u16 LCD_BGR2RGB(u16 c)
  124. {
  125.         u16  r,g,b,rgb;   
  126.         b=(c>>0)&0x1f;
  127.         g=(c>>5)&0x3f;
  128.         r=(c>>11)&0x1f;         
  129.         rgb=(b<<11)+(g<<5)+(r<<0);                 
  130.         return(rgb);
  131. }
  132. //当mdk -O1时间优化时需要设置
  133. //延时i
  134. void opt_delay(u8 i)
  135. {
  136.         while(i--);
  137. }
  138. //读取个某点的颜色值         
  139. //x,y:坐标
  140. //返回值:此点的颜色
  141. u16 LCD_ReadPoint(u16 x,u16 y)
  142. {
  143.         u16 r=0,g=0,b=0;
  144.         if(x>=lcddev.width||y>=lcddev.height)return 0;        //超过了范围,直接返回                  
  145.         LCD_SetCursor(x,y);            
  146.         if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X2E);//9341/6804/3510/1963 发送读GRAM指令
  147.         else if(lcddev.id==0X5510)LCD_WR_REG(0X2E00);        //5510 发送读GRAM指令
  148.         else LCD_WR_REG(0X22);                                               //其他IC发送读GRAM指令
  149.         if(lcddev.id==0X9320)opt_delay(2);                                //FOR 9320,延时2us            
  150.         r=LCD_RD_DATA();                                                                //dummy Read          
  151.         if(lcddev.id==0X1963)return r;                                        //1963直接读就可以
  152.         opt_delay(2);          
  153.         r=LCD_RD_DATA();                                                                    //实际坐标颜色
  154.         if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X5510)                //9341/NT35310/NT35510要分2次读出
  155.         {
  156.                 opt_delay(2);          
  157.                 b=LCD_RD_DATA();
  158.                 g=r&0XFF;                //对于9341/5310/5510,第一次读取的是RG的值,R在前,G在后,各占8位
  159.                 g<<=8;
  160.         }
  161.         if(lcddev.id==0X9325||lcddev.id==0X4535||lcddev.id==0X4531||lcddev.id==0XB505||lcddev.id==0XC505)return r;        //这几种IC直接返回颜色值
  162.         else if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X5510)return (((r>>11)<<11)|((g>>10)<<5)|(b>>11));//ILI9341/NT35310/NT35510需要公式转换一下
  163.         else return LCD_BGR2RGB(r);                                                //其他IC
  164. }                         
  165. //LCD开启显示
  166. void LCD_DisplayOn(void)
  167. {                                          
  168.         if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X29);        //开启显示
  169.         else if(lcddev.id==0X5510)LCD_WR_REG(0X2900);        //开启显示
  170.         else LCD_WriteReg(0X07,0x0173);                                          //开启显示
  171. }         
  172. //LCD关闭显示
  173. void LCD_DisplayOff(void)
  174. {          
  175.         if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X28);        //关闭显示
  176.         else if(lcddev.id==0X5510)LCD_WR_REG(0X2800);        //关闭显示
  177.         else LCD_WriteReg(0X07,0x0);//关闭显示
  178. }   
  179. //设置光标位置
  180. //Xpos:横坐标
  181. //Ypos:纵坐标
  182. void LCD_SetCursor(u16 Xpos, u16 Ypos)
  183. {         
  184.         if(lcddev.id==0X9341||lcddev.id==0X5310)
  185.         {                    
  186.                 LCD_WR_REG(lcddev.setxcmd);
  187.                 LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);                          
  188.                 LCD_WR_REG(lcddev.setycmd);
  189.                 LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);                
  190.         }else if(lcddev.id==0X6804)
  191.         {
  192.                 if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;//横屏时处理
  193.                 LCD_WR_REG(lcddev.setxcmd);
  194.                 LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
  195.                 LCD_WR_REG(lcddev.setycmd);
  196.                 LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);
  197.         }else if(lcddev.id==0X1963)
  198.         {                                          
  199.                 if(lcddev.dir==0)//x坐标需要变换
  200.                 {
  201.                         Xpos=lcddev.width-1-Xpos;
  202.                         LCD_WR_REG(lcddev.setxcmd);
  203.                         LCD_WR_DATA(0);LCD_WR_DATA(0);                
  204.                         LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);                          
  205.                 }else
  206.                 {
  207.                         LCD_WR_REG(lcddev.setxcmd);
  208.                         LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);                
  209.                         LCD_WR_DATA((lcddev.width-1)>>8);LCD_WR_DATA((lcddev.width-1)&0XFF);                                                 
  210.                 }       
  211.                 LCD_WR_REG(lcddev.setycmd);
  212.                 LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);                
  213.                 LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-1)&0XFF);                                         
  214.                
  215.         }else if(lcddev.id==0X5510)
  216.         {
  217.                 LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(Xpos>>8);                
  218.                 LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(Xpos&0XFF);                         
  219.                 LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(Ypos>>8);                 
  220.                 LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(Ypos&0XFF);                       
  221.         }else
  222.         {
  223.                 if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;//横屏其实就是调转x,y坐标
  224.                 LCD_WriteReg(lcddev.setxcmd, Xpos);
  225.                 LCD_WriteReg(lcddev.setycmd, Ypos);
  226.         }         
  227. }                  
  228. //设置LCD的自动扫描方向
  229. //注意:其他函数可能会受到此函数设置的影响(尤其是9341/6804这两个奇葩),
  230. //所以,一般设置为L2R_U2D即可,如果设置为其他扫描方式,可能导致显示不正常.
  231. //dir:0~7,代表8个方向(具体定义见lcd.h)
  232. //9320/9325/9328/4531/4535/1505/b505/5408/9341/5310/5510/1963等IC已经实际测试                     
  233. void LCD_Scan_Dir(u8 dir)
  234. {
  235.         u16 regval=0;
  236.         u16 dirreg=0;
  237.         u16 temp;  
  238.         if((lcddev.dir==1&&lcddev.id!=0X6804&&lcddev.id!=0X1963)||(lcddev.dir==0&&lcddev.id==0X1963))//横屏时,对6804和1963不改变扫描方向!竖屏时1963改变方向
  239.         {                          
  240.                 switch(dir)//方向转换
  241.                 {
  242.                         case 0:dir=6;break;
  243.                         case 1:dir=7;break;
  244.                         case 2:dir=4;break;
  245.                         case 3:dir=5;break;
  246.                         case 4:dir=1;break;
  247.                         case 5:dir=0;break;
  248.                         case 6:dir=3;break;
  249.                         case 7:dir=2;break;             
  250.                 }
  251.         }
  252.         if(lcddev.id==0x9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510||lcddev.id==0X1963)//9341/6804/5310/5510/1963,特殊处理
  253.         {
  254.                 switch(dir)
  255.                 {
  256.                         case L2R_U2D://从左到右,从上到下
  257.                                 regval|=(0<<7)|(0<<6)|(0<<5);
  258.                                 break;
  259.                         case L2R_D2U://从左到右,从下到上
  260.                                 regval|=(1<<7)|(0<<6)|(0<<5);
  261.                                 break;
  262.                         case R2L_U2D://从右到左,从上到下
  263.                                 regval|=(0<<7)|(1<<6)|(0<<5);
  264.                                 break;
  265.                         case R2L_D2U://从右到左,从下到上
  266.                                 regval|=(1<<7)|(1<<6)|(0<<5);
  267.                                 break;         
  268.                         case U2D_L2R://从上到下,从左到右
  269.                                 regval|=(0<<7)|(0<<6)|(1<<5);
  270.                                 break;
  271.                         case U2D_R2L://从上到下,从右到左
  272.                                 regval|=(0<<7)|(1<<6)|(1<<5);
  273.                                 break;
  274.                         case D2U_L2R://从下到上,从左到右
  275.                                 regval|=(1<<7)|(0<<6)|(1<<5);
  276.                                 break;
  277.                         case D2U_R2L://从下到上,从右到左
  278.                                 regval|=(1<<7)|(1<<6)|(1<<5);
  279.                                 break;         
  280.                 }
  281.                 if(lcddev.id==0X5510)dirreg=0X3600;
  282.                 else dirreg=0X36;
  283.                 if((lcddev.id!=0X5310)&&(lcddev.id!=0X5510)&&(lcddev.id!=0X1963))regval|=0X08;//5310/5510/1963不需要BGR   
  284.                 if(lcddev.id==0X6804)regval|=0x02;//6804的BIT6和9341的反了          
  285.                 LCD_WriteReg(dirreg,regval);
  286.                 if(lcddev.id!=0X1963)//1963不做坐标处理
  287.                 {
  288.                         if(regval&0X20)
  289.                         {
  290.                                 if(lcddev.width<lcddev.height)//交换X,Y
  291.                                 {
  292.                                         temp=lcddev.width;
  293.                                         lcddev.width=lcddev.height;
  294.                                         lcddev.height=temp;
  295.                                 }
  296.                         }else  
  297.                         {
  298.                                 if(lcddev.width>lcddev.height)//交换X,Y
  299.                                 {
  300.                                         temp=lcddev.width;
  301.                                         lcddev.width=lcddev.height;
  302.                                         lcddev.height=temp;
  303.                                 }
  304.                         }  
  305.                 }
  306.                 if(lcddev.id==0X5510)
  307.                 {
  308.                         LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(0);
  309.                         LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(0);
  310.                         LCD_WR_REG(lcddev.setxcmd+2);LCD_WR_DATA((lcddev.width-1)>>8);
  311.                         LCD_WR_REG(lcddev.setxcmd+3);LCD_WR_DATA((lcddev.width-1)&0XFF);
  312.                         LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(0);
  313.                         LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(0);
  314.                         LCD_WR_REG(lcddev.setycmd+2);LCD_WR_DATA((lcddev.height-1)>>8);
  315.                         LCD_WR_REG(lcddev.setycmd+3);LCD_WR_DATA((lcddev.height-1)&0XFF);
  316.                 }else
  317.                 {
  318.                         LCD_WR_REG(lcddev.setxcmd);
  319.                         LCD_WR_DATA(0);LCD_WR_DATA(0);
  320.                         LCD_WR_DATA((lcddev.width-1)>>8);LCD_WR_DATA((lcddev.width-1)&0XFF);
  321.                         LCD_WR_REG(lcddev.setycmd);
  322.                         LCD_WR_DATA(0);LCD_WR_DATA(0);
  323.                         LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-1)&0XFF);  
  324.                 }
  325.           }else
  326.         {
  327.                 switch(dir)
  328.                 {
  329.                         case L2R_U2D://从左到右,从上到下
  330.                                 regval|=(1<<5)|(1<<4)|(0<<3);
  331.                                 break;
  332.                         case L2R_D2U://从左到右,从下到上
  333.                                 regval|=(0<<5)|(1<<4)|(0<<3);
  334.                                 break;
  335.                         case R2L_U2D://从右到左,从上到下
  336.                                 regval|=(1<<5)|(0<<4)|(0<<3);
  337.                                 break;
  338.                         case R2L_D2U://从右到左,从下到上
  339.                                 regval|=(0<<5)|(0<<4)|(0<<3);
  340.                                 break;         
  341.                         case U2D_L2R://从上到下,从左到右
  342.                                 regval|=(1<<5)|(1<<4)|(1<<3);
  343.                                 break;
  344.                         case U2D_R2L://从上到下,从右到左
  345.                                 regval|=(1<<5)|(0<<4)|(1<<3);
  346.                                 break;
  347.                         case D2U_L2R://从下到上,从左到右
  348.                                 regval|=(0<<5)|(1<<4)|(1<<3);
  349.                                 break;
  350.                         case D2U_R2L://从下到上,从右到左
  351.                                 regval|=(0<<5)|(0<<4)|(1<<3);
  352.                                 break;         
  353.                 }
  354.                 dirreg=0X03;
  355.                 regval|=1<<12;
  356.                 LCD_WriteReg(dirreg,regval);
  357.         }
  358. }     
  359. //画点
  360. //x,y:坐标
  361. //POINT_COLOR:此点的颜色
  362. void LCD_DrawPoint(u16 x,u16 y)
  363. {
  364.         LCD_SetCursor(x,y);                //设置光标位置
  365.         LCD_WriteRAM_Prepare();        //开始写入GRAM
  366.         LCD->LCD_RAM=POINT_COLOR;
  367. }
  368. //快速画点
  369. //x,y:坐标
  370. //color:颜色
  371. void LCD_Fast_DrawPoint(u16 x,u16 y,u16 color)
  372. {          
  373.         if(lcddev.id==0X9341||lcddev.id==0X5310)
  374.         {
  375.                 LCD_WR_REG(lcddev.setxcmd);
  376.                 LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);                           
  377.                 LCD_WR_REG(lcddev.setycmd);
  378.                 LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);                           
  379.         }else if(lcddev.id==0X5510)
  380.         {
  381.                 LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(x>>8);  
  382.                 LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(x&0XFF);          
  383.                 LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(y>>8);  
  384.                 LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(y&0XFF);
  385.         }else if(lcddev.id==0X1963)
  386.         {
  387.                 if(lcddev.dir==0)x=lcddev.width-1-x;
  388.                 LCD_WR_REG(lcddev.setxcmd);
  389.                 LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);                
  390.                 LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);                
  391.                 LCD_WR_REG(lcddev.setycmd);
  392.                 LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);                
  393.                 LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);                
  394.         }else if(lcddev.id==0X6804)
  395.         {                    
  396.                 if(lcddev.dir==1)x=lcddev.width-1-x;//横屏时处理
  397.                 LCD_WR_REG(lcddev.setxcmd);
  398.                 LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);                         
  399.                 LCD_WR_REG(lcddev.setycmd);
  400.                 LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);                
  401.         }else
  402.         {
  403.                 if(lcddev.dir==1)x=lcddev.width-1-x;//横屏其实就是调转x,y坐标
  404.                 LCD_WriteReg(lcddev.setxcmd,x);
  405.                 LCD_WriteReg(lcddev.setycmd,y);
  406.         }                         
  407.         LCD->LCD_REG=lcddev.wramcmd;
  408.         LCD->LCD_RAM=color;
  409. }         
  410. //SSD1963 背光设置
  411. //pwm:背光等级,0~100.越大越亮.
  412. void LCD_SSD_BackLightSet(u8 pwm)
  413. {       
  414.         LCD_WR_REG(0xBE);        //配置PWM输出
  415.         LCD_WR_DATA(0x05);        //1设置PWM频率
  416.         LCD_WR_DATA(pwm*2.55);//2设置PWM占空比
  417.         LCD_WR_DATA(0x01);        //3设置C
  418.         LCD_WR_DATA(0xFF);        //4设置D
  419.         LCD_WR_DATA(0x00);        //5设置E
  420.         LCD_WR_DATA(0x00);        //6设置F
  421. }

  422. //设置LCD显示方向
  423. //dir:0,竖屏;1,横屏
  424. void LCD_Display_Dir(u8 dir)
  425. {
  426.         if(dir==0)                        //竖屏
  427.         {
  428.                 lcddev.dir=0;        //竖屏
  429.                 lcddev.width=240;
  430.                 lcddev.height=320;
  431.                 if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310)
  432.                 {
  433.                         lcddev.wramcmd=0X2C;
  434.                          lcddev.setxcmd=0X2A;
  435.                         lcddev.setycmd=0X2B;           
  436.                         if(lcddev.id==0X6804||lcddev.id==0X5310)
  437.                         {
  438.                                 lcddev.width=320;
  439.                                 lcddev.height=480;
  440.                         }
  441.                 }else if(lcddev.id==0x5510)
  442.                 {
  443.                         lcddev.wramcmd=0X2C00;
  444.                          lcddev.setxcmd=0X2A00;
  445.                         lcddev.setycmd=0X2B00;
  446.                         lcddev.width=480;
  447.                         lcddev.height=800;
  448.                 }else if(lcddev.id==0X1963)
  449.                 {
  450.                         lcddev.wramcmd=0X2C;        //设置写入GRAM的指令
  451.                         lcddev.setxcmd=0X2B;        //设置写X坐标指令
  452.                         lcddev.setycmd=0X2A;        //设置写Y坐标指令
  453.                         lcddev.width=480;                //设置宽度480
  454.                         lcddev.height=800;                //设置高度800  
  455.                 }else
  456.                 {
  457.                         lcddev.wramcmd=0X22;
  458.                          lcddev.setxcmd=0X20;
  459.                         lcddev.setycmd=0X21;  
  460.                 }
  461.         }else                                 //横屏
  462.         {                                         
  463.                 lcddev.dir=1;        //横屏
  464.                 lcddev.width=320;
  465.                 lcddev.height=240;
  466.                 if(lcddev.id==0X9341||lcddev.id==0X5310)
  467.                 {
  468.                         lcddev.wramcmd=0X2C;
  469.                          lcddev.setxcmd=0X2A;
  470.                         lcddev.setycmd=0X2B;           
  471.                 }else if(lcddev.id==0X6804)         
  472.                 {
  473.                         lcddev.wramcmd=0X2C;
  474.                          lcddev.setxcmd=0X2B;
  475.                         lcddev.setycmd=0X2A;
  476.                 }else if(lcddev.id==0x5510)
  477.                 {
  478.                         lcddev.wramcmd=0X2C00;
  479.                          lcddev.setxcmd=0X2A00;
  480.                         lcddev.setycmd=0X2B00;
  481.                         lcddev.width=800;
  482.                         lcddev.height=480;
  483.                 }else if(lcddev.id==0X1963)
  484.                 {
  485.                         lcddev.wramcmd=0X2C;        //设置写入GRAM的指令
  486.                         lcddev.setxcmd=0X2A;        //设置写X坐标指令
  487.                         lcddev.setycmd=0X2B;        //设置写Y坐标指令
  488.                         lcddev.width=800;                //设置宽度800
  489.                         lcddev.height=480;                //设置高度480  
  490.                 }else
  491.                 {
  492.                         lcddev.wramcmd=0X22;
  493.                          lcddev.setxcmd=0X21;
  494.                         lcddev.setycmd=0X20;  
  495.                 }
  496.                 if(lcddev.id==0X6804||lcddev.id==0X5310)
  497.                 {          
  498.                         lcddev.width=480;
  499.                         lcddev.height=320;                        
  500.                 }
  501.         }
  502.         LCD_Scan_Dir(DFT_SCAN_DIR);        //默认扫描方向
  503. }         
  504. //设置窗口,并自动设置画点坐标到窗口左上角(sx,sy).
  505. //sx,sy:窗口起始坐标(左上角)
  506. //width,height:窗口宽度和高度,必须大于0!!
  507. //窗体大小:width*height.
  508. void LCD_Set_Window(u16 sx,u16 sy,u16 width,u16 height)
  509. {   
  510.         u8 hsareg,heareg,vsareg,veareg;
  511.         u16 hsaval,heaval,vsaval,veaval;
  512.         u16 twidth,theight;
  513.         twidth=sx+width-1;
  514.         theight=sy+height-1;
  515.         if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X6804||(lcddev.dir==1&&lcddev.id==0X1963))
  516.         {
  517.                 LCD_WR_REG(lcddev.setxcmd);
  518.                 LCD_WR_DATA(sx>>8);
  519.                 LCD_WR_DATA(sx&0XFF);         
  520.                 LCD_WR_DATA(twidth>>8);
  521.                 LCD_WR_DATA(twidth&0XFF);  
  522.                 LCD_WR_REG(lcddev.setycmd);
  523.                 LCD_WR_DATA(sy>>8);
  524.                 LCD_WR_DATA(sy&0XFF);
  525.                 LCD_WR_DATA(theight>>8);
  526.                 LCD_WR_DATA(theight&0XFF);
  527.         }else if(lcddev.id==0X1963)//1963竖屏特殊处理
  528.         {
  529.                 sx=lcddev.width-width-sx;
  530.                 height=sy+height-1;
  531.                 LCD_WR_REG(lcddev.setxcmd);
  532.                 LCD_WR_DATA(sx>>8);
  533.                 LCD_WR_DATA(sx&0XFF);         
  534.                 LCD_WR_DATA((sx+width-1)>>8);
  535.                 LCD_WR_DATA((sx+width-1)&0XFF);  
  536.                 LCD_WR_REG(lcddev.setycmd);
  537.                 LCD_WR_DATA(sy>>8);
  538.                 LCD_WR_DATA(sy&0XFF);
  539.                 LCD_WR_DATA(height>>8);
  540.                 LCD_WR_DATA(height&0XFF);                
  541.         }else if(lcddev.id==0X5510)
  542.         {
  543.                 LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(sx>>8);  
  544.                 LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(sx&0XFF);          
  545.                 LCD_WR_REG(lcddev.setxcmd+2);LCD_WR_DATA(twidth>>8);   
  546.                 LCD_WR_REG(lcddev.setxcmd+3);LCD_WR_DATA(twidth&0XFF);   
  547.                 LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(sy>>8);   
  548.                 LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(sy&0XFF);  
  549.                 LCD_WR_REG(lcddev.setycmd+2);LCD_WR_DATA(theight>>8);   
  550.                 LCD_WR_REG(lcddev.setycmd+3);LCD_WR_DATA(theight&0XFF);  
  551.         }else        //其他驱动IC
  552.         {
  553.                 if(lcddev.dir==1)//横屏
  554.                 {
  555.                         //窗口值
  556.                         hsaval=sy;                               
  557.                         heaval=theight;
  558.                         vsaval=lcddev.width-twidth-1;
  559.                         veaval=lcddev.width-sx-1;                               
  560.                 }else
  561.                 {
  562.                         hsaval=sx;                               
  563.                         heaval=twidth;
  564.                         vsaval=sy;
  565.                         veaval=theight;
  566.                 }
  567.                 hsareg=0X50;heareg=0X51;//水平方向窗口寄存器
  568.                 vsareg=0X52;veareg=0X53;//垂直方向窗口寄存器                                                                     
  569.                 //设置寄存器值
  570.                 LCD_WriteReg(hsareg,hsaval);
  571.                 LCD_WriteReg(heareg,heaval);
  572.                 LCD_WriteReg(vsareg,vsaval);
  573.                 LCD_WriteReg(veareg,veaval);               
  574.                 LCD_SetCursor(sx,sy);        //设置光标位置
  575.         }
  576. }
  577. //初始化lcd
  578. //该初始化函数可以初始化各种ILI93XX液晶,但是其他函数是基于ILI9320的!!!
  579. //在其他型号的驱动芯片上没有测试!
  580. void LCD_Init(void)
  581. {                                        
  582.         GPIO_InitTypeDef GPIO_InitStructure;
  583.         FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
  584.   FSMC_NORSRAMTimingInitTypeDef  readWriteTiming;
  585.         FSMC_NORSRAMTimingInitTypeDef  writeTiming;
  586.        
  587.   RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE);        //使能FSMC时钟
  588.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOG,ENABLE);//使能PORTB,D,E,G以及AFIO复用功能时钟


  589.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;                                 //PB0 推挽输出 背光
  590.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                  //推挽输出
  591.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  592.         GPIO_Init(GPIOB, &GPIO_InitStructure);
  593.        
  594.         //PORTD复用推挽输出  
  595.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_14|GPIO_Pin_15;                                 //        //PORTD复用推挽输出  
  596.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;                  //复用推挽输出   
  597.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  598.         GPIO_Init(GPIOD, &GPIO_InitStructure);
  599.            
  600.         //PORTE复用推挽输出  
  601.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;                                 //        //PORTD复用推挽输出  
  602.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;                  //复用推挽输出   
  603.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  604.         GPIO_Init(GPIOE, &GPIO_InitStructure);                                                                                                                  

  605.            //        //PORTG12复用推挽输出 A0       
  606.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_12;         //        //PORTD复用推挽输出  
  607.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;                  //复用推挽输出   
  608.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  609.         GPIO_Init(GPIOG, &GPIO_InitStructure);

  610.         readWriteTiming.FSMC_AddressSetupTime = 0x01;         //地址建立时间(ADDSET)为2个HCLK 1/36M=27ns
  611.   readWriteTiming.FSMC_AddressHoldTime = 0x00;         //地址保持时间(ADDHLD)模式A未用到       
  612.   readWriteTiming.FSMC_DataSetupTime = 0x0f;                 // 数据保存时间为16个HCLK,因为液晶驱动IC的读数据的时候,速度不能太快,尤其对1289这个IC。
  613.   readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
  614.   readWriteTiming.FSMC_CLKDivision = 0x00;
  615.   readWriteTiming.FSMC_DataLatency = 0x00;
  616.   readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;         //模式A
  617.    

  618.         writeTiming.FSMC_AddressSetupTime = 0x00;         //地址建立时间(ADDSET)为1个HCLK  
  619.   writeTiming.FSMC_AddressHoldTime = 0x00;         //地址保持时间(A               
  620.   writeTiming.FSMC_DataSetupTime = 0x03;                 ////数据保存时间为4个HCLK       
  621.   writeTiming.FSMC_BusTurnAroundDuration = 0x00;
  622.   writeTiming.FSMC_CLKDivision = 0x00;
  623.   writeTiming.FSMC_DataLatency = 0x00;
  624.   writeTiming.FSMC_AccessMode = FSMC_AccessMode_A;         //模式A


  625.   FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;//  这里我们使用NE4 ,也就对应BTCR[6],[7]。
  626.   FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 不复用数据地址
  627.   FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM;  //SRAM   
  628.   FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//存储器数据宽度为16bit   
  629.   FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
  630.   FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  631.         FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
  632.   FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;   
  633.   FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;  
  634.   FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;        //  存储器写使能
  635.   FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;   
  636.   FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // 读写使用不同的时序
  637.   FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  638.   FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //读写时序
  639.   FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming;  //写时序

  640.   FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  //初始化FSMC配置

  641.         FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);  // 使能BANK1
  642.                

  643.         delay_ms(50);                                         // delay 50 ms
  644.           lcddev.id=LCD_ReadReg(0x0000);        //读ID(9320/9325/9328/4531/4535等IC)   
  645.           if(lcddev.id<0XFF||lcddev.id==0XFFFF||lcddev.id==0X9300)//读到ID不正确,新增lcddev.id==0X9300判断,因为9341在未被复位的情况下会被读成9300
  646.         {       
  647.                 //尝试9341 ID的读取               
  648.                 LCD_WR_REG(0XD3);                                  
  649.                 lcddev.id=LCD_RD_DATA();        //dummy read        
  650.                 lcddev.id=LCD_RD_DATA();        //读到0X00
  651.                   lcddev.id=LCD_RD_DATA();           //读取93                                                                  
  652.                 lcddev.id<<=8;
  653.                 lcddev.id|=LCD_RD_DATA();          //读取41                                      
  654.                 if(lcddev.id!=0X9341)                //非9341,尝试是不是6804
  655.                 {       
  656.                         LCD_WR_REG(0XBF);                                  
  657.                         lcddev.id=LCD_RD_DATA();         //dummy read          
  658.                          lcddev.id=LCD_RD_DATA();           //读回0X01                          
  659.                          lcddev.id=LCD_RD_DATA();         //读回0XD0                                  
  660.                           lcddev.id=LCD_RD_DATA();        //这里读回0X68
  661.                         lcddev.id<<=8;
  662.                           lcddev.id|=LCD_RD_DATA();        //这里读回0X04          
  663.                         if(lcddev.id!=0X6804)                //也不是6804,尝试看看是不是NT35310
  664.                         {
  665.                                 LCD_WR_REG(0XD4);                                  
  666.                                 lcddev.id=LCD_RD_DATA();//dummy read  
  667.                                 lcddev.id=LCD_RD_DATA();//读回0X01         
  668.                                 lcddev.id=LCD_RD_DATA();//读回0X53       
  669.                                 lcddev.id<<=8;         
  670.                                 lcddev.id|=LCD_RD_DATA();        //这里读回0X10         
  671.                                 if(lcddev.id!=0X5310)                //也不是NT35310,尝试看看是不是NT35510
  672.                                 {
  673.                                         LCD_WR_REG(0XDA00);       
  674.                                         lcddev.id=LCD_RD_DATA();                //读回0X00         
  675.                                         LCD_WR_REG(0XDB00);       
  676.                                         lcddev.id=LCD_RD_DATA();                //读回0X80
  677.                                         lcddev.id<<=8;       
  678.                                         LCD_WR_REG(0XDC00);       
  679.                                         lcddev.id|=LCD_RD_DATA();                //读回0X00               
  680.                                         if(lcddev.id==0x8000)lcddev.id=0x5510;//NT35510读回的ID是8000H,为方便区分,我们强制设置为5510
  681.                                         if(lcddev.id!=0X5510)                        //也不是NT5510,尝试看看是不是SSD1963
  682.                                         {
  683.                                                 LCD_WR_REG(0XA1);
  684.                                                 lcddev.id=LCD_RD_DATA();
  685.                                                 lcddev.id=LCD_RD_DATA();        //读回0X57
  686.                                                 lcddev.id<<=8;         
  687.                                                 lcddev.id|=LCD_RD_DATA();        //读回0X61       
  688.                                                 if(lcddev.id==0X5761)lcddev.id=0X1963;//SSD1963读回的ID是5761H,为方便区分,我们强制设置为1963
  689.                                         }
  690.                                 }
  691.                         }
  692.                 }         
  693.         }
  694.         printf(" LCD ID:%x\r\n",lcddev.id); //打印LCD ID   
  695.         if(lcddev.id==0X9341)        //9341初始化
  696.         {         
  697.                 LCD_WR_REG(0xCF);  
  698.                 LCD_WR_DATA(0x00);
  699.                 LCD_WR_DATA(0xC1);
  700.                 LCD_WR_DATA(0X30);
  701.                 LCD_WR_REG(0xED);  
  702.                 LCD_WR_DATA(0x64);
  703.                 LCD_WR_DATA(0x03);
  704.                 LCD_WR_DATA(0X12);
  705.                 LCD_WR_DATA(0X81);
  706.                 LCD_WR_REG(0xE8);  
  707.                 LCD_WR_DATA(0x85);
  708.                 LCD_WR_DATA(0x10);
  709.                 LCD_WR_DATA(0x7A);
  710.                 LCD_WR_REG(0xCB);  
  711.                 LCD_WR_DATA(0x39);
  712.                 LCD_WR_DATA(0x2C);
  713.                 LCD_WR_DATA(0x00);
  714.                 LCD_WR_DATA(0x34);
  715.                 LCD_WR_DATA(0x02);
  716.                 LCD_WR_REG(0xF7);  
  717.                 LCD_WR_DATA(0x20);
  718.                 LCD_WR_REG(0xEA);  
  719.                 LCD_WR_DATA(0x00);
  720.                 LCD_WR_DATA(0x00);
  721.                 LCD_WR_REG(0xC0);    //Power control
  722.                 LCD_WR_DATA(0x1B);   //VRH[5:0]
  723.                 LCD_WR_REG(0xC1);    //Power control
  724.                 LCD_WR_DATA(0x01);   //SAP[2:0];BT[3:0]
  725.                 LCD_WR_REG(0xC5);    //VCM control
  726.                 LCD_WR_DATA(0x30);          //3F
  727.                 LCD_WR_DATA(0x30);          //3C
  728.                 LCD_WR_REG(0xC7);    //VCM control2
  729.                 LCD_WR_DATA(0XB7);
  730.                 LCD_WR_REG(0x36);    // Memory Access Control
  731.                 LCD_WR_DATA(0x48);
  732.                 LCD_WR_REG(0x3A);   
  733.                 LCD_WR_DATA(0x55);
  734.                 LCD_WR_REG(0xB1);   
  735.                 LCD_WR_DATA(0x00);   
  736.                 LCD_WR_DATA(0x1A);
  737.                 LCD_WR_REG(0xB6);    // Display Function Control
  738.                 LCD_WR_DATA(0x0A);
  739.                 LCD_WR_DATA(0xA2);
  740.                 LCD_WR_REG(0xF2);    // 3Gamma Function Disable
  741.                 LCD_WR_DATA(0x00);
  742.                 LCD_WR_REG(0x26);    //Gamma curve selected
  743.                 LCD_WR_DATA(0x01);
  744.                 LCD_WR_REG(0xE0);    //Set Gamma
  745.                 LCD_WR_DATA(0x0F);
  746.                 LCD_WR_DATA(0x2A);
  747.                 LCD_WR_DATA(0x28);
  748.                 LCD_WR_DATA(0x08);
  749.                 LCD_WR_DATA(0x0E);
  750.                 LCD_WR_DATA(0x08);
  751.                 LCD_WR_DATA(0x54);
  752.                 LCD_WR_DATA(0XA9);
  753.                 LCD_WR_DATA(0x43);
  754.                 LCD_WR_DATA(0x0A);
  755.                 LCD_WR_DATA(0x0F);
  756.                 LCD_WR_DATA(0x00);
  757.                 LCD_WR_DATA(0x00);
  758.                 LCD_WR_DATA(0x00);
  759.                 LCD_WR_DATA(0x00);                  
  760.                 LCD_WR_REG(0XE1);    //Set Gamma
  761.                 LCD_WR_DATA(0x00);
  762.                 LCD_WR_DATA(0x15);
  763.                 LCD_WR_DATA(0x17);
  764.                 LCD_WR_DATA(0x07);
  765.                 LCD_WR_DATA(0x11);
  766.                 LCD_WR_DATA(0x06);
  767.                 LCD_WR_DATA(0x2B);
  768.                 LCD_WR_DATA(0x56);
  769.                 LCD_WR_DATA(0x3C);
  770.                 LCD_WR_DATA(0x05);
  771.                 LCD_WR_DATA(0x10);
  772.                 LCD_WR_DATA(0x0F);
  773.                 LCD_WR_DATA(0x3F);
  774.                 LCD_WR_DATA(0x3F);
  775.                 LCD_WR_DATA(0x0F);
  776.                 LCD_WR_REG(0x2B);
  777.                 LCD_WR_DATA(0x00);
  778.                 LCD_WR_DATA(0x00);
  779.                 LCD_WR_DATA(0x01);
  780.                 LCD_WR_DATA(0x3f);
  781.                 LCD_WR_REG(0x2A);
  782.                 LCD_WR_DATA(0x00);
  783.                 LCD_WR_DATA(0x00);
  784.                 LCD_WR_DATA(0x00);
  785.                 LCD_WR_DATA(0xef);         
  786.                 LCD_WR_REG(0x11); //Exit Sleep
  787.                 delay_ms(120);
  788.                 LCD_WR_REG(0x29); //display on       
  789.         }else if(lcddev.id==0x6804) //6804初始化
  790.         {
  791.                 LCD_WR_REG(0X11);
  792.                 delay_ms(20);
  793.                 LCD_WR_REG(0XD0);//VCI1  VCL  VGH  VGL DDVDH VREG1OUT power amplitude setting
  794.                 LCD_WR_DATA(0X07);
  795.                 LCD_WR_DATA(0X42);
  796.                 LCD_WR_DATA(0X1D);
  797.                 LCD_WR_REG(0XD1);//VCOMH VCOM_AC amplitude setting
  798.                 LCD_WR_DATA(0X00);
  799.                 LCD_WR_DATA(0X1a);
  800.                 LCD_WR_DATA(0X09);
  801.                 LCD_WR_REG(0XD2);//Operational Amplifier Circuit Constant Current Adjust , charge pump frequency setting
  802.                 LCD_WR_DATA(0X01);
  803.                 LCD_WR_DATA(0X22);
  804.                 LCD_WR_REG(0XC0);//REV SM GS
  805.                 LCD_WR_DATA(0X10);
  806.                 LCD_WR_DATA(0X3B);
  807.                 LCD_WR_DATA(0X00);
  808.                 LCD_WR_DATA(0X02);
  809.                 LCD_WR_DATA(0X11);
  810.                
  811.                 LCD_WR_REG(0XC5);// Frame rate setting = 72HZ  when setting 0x03
  812.                 LCD_WR_DATA(0X03);
  813.                
  814.                 LCD_WR_REG(0XC8);//Gamma setting
  815.                 LCD_WR_DATA(0X00);
  816.                 LCD_WR_DATA(0X25);
  817.                 LCD_WR_DATA(0X21);
  818.                 LCD_WR_DATA(0X05);
  819.                 LCD_WR_DATA(0X00);
  820.                 LCD_WR_DATA(0X0a);
  821.                 LCD_WR_DATA(0X65);
  822.                 LCD_WR_DATA(0X25);
  823.                 LCD_WR_DATA(0X77);
  824.                 LCD_WR_DATA(0X50);
  825.                 LCD_WR_DATA(0X0f);
  826.                 LCD_WR_DATA(0X00);          
  827.                                                   
  828.                    LCD_WR_REG(0XF8);
  829.                 LCD_WR_DATA(0X01);          

  830.                 LCD_WR_REG(0XFE);
  831.                 LCD_WR_DATA(0X00);
  832.                 LCD_WR_DATA(0X02);
  833.                
  834.                 LCD_WR_REG(0X20);//Exit invert mode

  835.                 LCD_WR_REG(0X36);
  836.                 LCD_WR_DATA(0X08);//原来是a
  837.                
  838.                 LCD_WR_REG(0X3A);
  839.                 LCD_WR_DATA(0X55);//16位模式          
  840.                 LCD_WR_REG(0X2B);
  841.                 LCD_WR_DATA(0X00);
  842.                 LCD_WR_DATA(0X00);
  843.                 LCD_WR_DATA(0X01);
  844.                 LCD_WR_DATA(0X3F);
  845.                
  846.                 LCD_WR_REG(0X2A);
  847.                 LCD_WR_DATA(0X00);
  848.                 LCD_WR_DATA(0X00);
  849.                 LCD_WR_DATA(0X01);
  850.                 LCD_WR_DATA(0XDF);
  851.                 delay_ms(120);
  852.                 LCD_WR_REG(0X29);          
  853.         }else if(lcddev.id==0x5310)
  854.         {
  855.                 LCD_WR_REG(0xED);
  856.                 LCD_WR_DATA(0x01);
  857.                 LCD_WR_DATA(0xFE);

  858.                 LCD_WR_REG(0xEE);
  859.                 LCD_WR_DATA(0xDE);
  860.                 LCD_WR_DATA(0x21);

  861.                 LCD_WR_REG(0xF1);
  862.                 LCD_WR_DATA(0x01);
  863.                 LCD_WR_REG(0xDF);
  864.                 LCD_WR_DATA(0x10);

  865.                 //VCOMvoltage//
  866.                 LCD_WR_REG(0xC4);
  867.                 LCD_WR_DATA(0x8F);          //5f

  868.                 LCD_WR_REG(0xC6);
  869.                 LCD_WR_DATA(0x00);
  870.                 LCD_WR_DATA(0xE2);
  871.                 LCD_WR_DATA(0xE2);
  872.                 LCD_WR_DATA(0xE2);
  873.                 LCD_WR_REG(0xBF);
  874.                 LCD_WR_DATA(0xAA);

  875.                 LCD_WR_REG(0xB0);
  876.                 LCD_WR_DATA(0x0D);
  877.                 LCD_WR_DATA(0x00);
  878.                 LCD_WR_DATA(0x0D);
  879.                 LCD_WR_DATA(0x00);
  880.                 LCD_WR_DATA(0x11);
  881.                 LCD_WR_DATA(0x00);
  882.                 LCD_WR_DATA(0x19);
  883.                 LCD_WR_DATA(0x00);
  884.                 LCD_WR_DATA(0x21);
  885.                 LCD_WR_DATA(0x00);
  886.                 LCD_WR_DATA(0x2D);
  887.                 LCD_WR_DATA(0x00);
  888.                 LCD_WR_DATA(0x3D);
  889.                 LCD_WR_DATA(0x00);
  890.                 LCD_WR_DATA(0x5D);
  891.                 LCD_WR_DATA(0x00);
  892.                 LCD_WR_DATA(0x5D);
  893.                 LCD_WR_DATA(0x00);

  894.                 LCD_WR_REG(0xB1);
  895.                 LCD_WR_DATA(0x80);
  896.                 LCD_WR_DATA(0x00);
  897.                 LCD_WR_DATA(0x8B);
  898.                 LCD_WR_DATA(0x00);
  899.                 LCD_WR_DATA(0x96);
  900.                 LCD_WR_DATA(0x00);

  901.                 LCD_WR_REG(0xB2);
  902.                 LCD_WR_DATA(0x00);
  903.                 LCD_WR_DATA(0x00);
  904.                 LCD_WR_DATA(0x02);
  905.                 LCD_WR_DATA(0x00);
  906.                 LCD_WR_DATA(0x03);
  907.                 LCD_WR_DATA(0x00);

  908.                 LCD_WR_REG(0xB3);
  909.                 LCD_WR_DATA(0x00);
  910.                 LCD_WR_DATA(0x00);
  911.                 LCD_WR_DATA(0x00);
  912.                 LCD_WR_DATA(0x00);
  913.                 LCD_WR_DATA(0x00);
  914.                 LCD_WR_DATA(0x00);
  915.                 LCD_WR_DATA(0x00);
  916.                 LCD_WR_DATA(0x00);
  917.                 LCD_WR_DATA(0x00);
  918.                 LCD_WR_DATA(0x00);
  919.                 LCD_WR_DATA(0x00);
  920.                 LCD_WR_DATA(0x00);
  921.                 LCD_WR_DATA(0x00);
  922.                 LCD_WR_DATA(0x00);
  923.                 LCD_WR_DATA(0x00);
  924.                 LCD_WR_DATA(0x00);
  925.                 LCD_WR_DATA(0x00);
  926.                 LCD_WR_DATA(0x00);
  927.                 LCD_WR_DATA(0x00);
  928.                 LCD_WR_DATA(0x00);
  929.                 LCD_WR_DATA(0x00);
  930.                 LCD_WR_DATA(0x00);
  931.                 LCD_WR_DATA(0x00);
  932.                 LCD_WR_DATA(0x00);

  933.                 LCD_WR_REG(0xB4);
  934.                 LCD_WR_DATA(0x8B);
  935.                 LCD_WR_DATA(0x00);
  936.                 LCD_WR_DATA(0x96);
  937.                 LCD_WR_DATA(0x00);
  938.                 LCD_WR_DATA(0xA1);
  939.                 LCD_WR_DATA(0x00);

  940.                 LCD_WR_REG(0xB5);
  941.                 LCD_WR_DATA(0x02);
  942.                 LCD_WR_DATA(0x00);
  943.                 LCD_WR_DATA(0x03);
  944.                 LCD_WR_DATA(0x00);
  945.                 LCD_WR_DATA(0x04);
  946.                 LCD_WR_DATA(0x00);

  947.                 LCD_WR_REG(0xB6);
  948.                 LCD_WR_DATA(0x00);
  949.                 LCD_WR_DATA(0x00);

  950.                 LCD_WR_REG(0xB7);
  951.                 LCD_WR_DATA(0x00);
  952.                 LCD_WR_DATA(0x00);
  953.                 LCD_WR_DATA(0x3F);
  954.                 LCD_WR_DATA(0x00);
  955.                 LCD_WR_DATA(0x5E);
  956.                 LCD_WR_DATA(0x00);
  957.                 LCD_WR_DATA(0x64);
  958.                 LCD_WR_DATA(0x00);
  959.                 LCD_WR_DATA(0x8C);
  960.                 LCD_WR_DATA(0x00);
  961.                 LCD_WR_DATA(0xAC);
  962.                 LCD_WR_DATA(0x00);
  963.                 LCD_WR_DATA(0xDC);
  964.                 LCD_WR_DATA(0x00);
  965.                 LCD_WR_DATA(0x70);
  966.                 LCD_WR_DATA(0x00);
  967.                 LCD_WR_DATA(0x90);
  968.                 LCD_WR_DATA(0x00);
  969.                 LCD_WR_DATA(0xEB);
  970.                 LCD_WR_DATA(0x00);
  971.                 LCD_WR_DATA(0xDC);
  972.                 LCD_WR_DATA(0x00);

  973.                 LCD_WR_REG(0xB8);
  974.                 LCD_WR_DATA(0x00);
  975.                 LCD_WR_DATA(0x00);
  976.                 LCD_WR_DATA(0x00);
  977.                 LCD_WR_DATA(0x00);
  978.                 LCD_WR_DATA(0x00);
  979.                 LCD_WR_DATA(0x00);
  980.                 LCD_WR_DATA(0x00);
  981.                 LCD_WR_DATA(0x00);

  982.                 LCD_WR_REG(0xBA);
  983.                 LCD_WR_DATA(0x24);
  984.                 LCD_WR_DATA(0x00);
  985.                 LCD_WR_DATA(0x00);
  986.                 LCD_WR_DATA(0x00);

  987.                 LCD_WR_REG(0xC1);
  988.                 LCD_WR_DATA(0x20);
  989.                 LCD_WR_DATA(0x00);
  990.                 LCD_WR_DATA(0x54);
  991.                 LCD_WR_DATA(0x00);
  992.                 LCD_WR_DATA(0xFF);
  993.                 LCD_WR_DATA(0x00);

  994.                 LCD_WR_REG(0xC2);
  995.                 LCD_WR_DATA(0x0A);
  996.                 LCD_WR_DATA(0x00);
  997.                 LCD_WR_DATA(0x04);
  998.                 LCD_WR_DATA(0x00);

  999.                 LCD_WR_REG(0xC3);
  1000.                 LCD_WR_DATA(0x3C);
  1001.                 LCD_WR_DATA(0x00);
  1002.                 LCD_WR_DATA(0x3A);
  1003.                 LCD_WR_DATA(0x00);
  1004.                 LCD_WR_DATA(0x39);
  1005.                 LCD_WR_DATA(0x00);
  1006.                 LCD_WR_DATA(0x37);
  1007.                 LCD_WR_DATA(0x00);
  1008.                 LCD_WR_DATA(0x3C);
  1009.                 LCD_WR_DATA(0x00);
  1010.                 LCD_WR_DATA(0x36);
  1011.                 LCD_WR_DATA(0x00);
  1012.                 LCD_WR_DATA(0x32);
  1013.                 LCD_WR_DATA(0x00);
  1014.                 LCD_WR_DATA(0x2F);
  1015.                 LCD_WR_DATA(0x00);
  1016.                 LCD_WR_DATA(0x2C);
  1017.                 LCD_WR_DATA(0x00);
  1018.                 LCD_WR_DATA(0x29);
  1019.                 LCD_WR_DATA(0x00);
  1020.                 LCD_WR_DATA(0x26);
  1021.                 LCD_WR_DATA(0x00);
  1022.                 LCD_WR_DATA(0x24);
  1023.                 LCD_WR_DATA(0x00);
  1024.                 LCD_WR_DATA(0x24);
  1025.                 LCD_WR_DATA(0x00);
  1026.                 LCD_WR_DATA(0x23);
  1027.                 LCD_WR_DATA(0x00);
  1028.                 LCD_WR_DATA(0x3C);
  1029.                 LCD_WR_DATA(0x00);
  1030.                 LCD_WR_DATA(0x36);
  1031.                 LCD_WR_DATA(0x00);
  1032.                 LCD_WR_DATA(0x32);
  1033.                 LCD_WR_DATA(0x00);
  1034.                 LCD_WR_DATA(0x2F);
  1035.                 LCD_WR_DATA(0x00);
  1036.                 LCD_WR_DATA(0x2C);
  1037.                 LCD_WR_DATA(0x00);
  1038.                 LCD_WR_DATA(0x29);
  1039.                 LCD_WR_DATA(0x00);
  1040.                 LCD_WR_DATA(0x26);
  1041.                 LCD_WR_DATA(0x00);
  1042.                 LCD_WR_DATA(0x24);
  1043.                 LCD_WR_DATA(0x00);
  1044.                 LCD_WR_DATA(0x24);
  1045.                 LCD_WR_DATA(0x00);
  1046.                 LCD_WR_DATA(0x23);
  1047.                 LCD_WR_DATA(0x00);

  1048.                 LCD_WR_REG(0xC4);
  1049.                 LCD_WR_DATA(0x62);
  1050.                 LCD_WR_DATA(0x00);
  1051.                 LCD_WR_DATA(0x05);
  1052.                 LCD_WR_DATA(0x00);
  1053.                 LCD_WR_DATA(0x84);
  1054.                 LCD_WR_DATA(0x00);
  1055.                 LCD_WR_DATA(0xF0);
  1056.                 LCD_WR_DATA(0x00);
  1057.                 LCD_WR_DATA(0x18);
  1058.                 LCD_WR_DATA(0x00);
  1059.                 LCD_WR_DATA(0xA4);
  1060.                 LCD_WR_DATA(0x00);
  1061.                 LCD_WR_DATA(0x18);
  1062.                 LCD_WR_DATA(0x00);
  1063.                 LCD_WR_DATA(0x50);
  1064.                 LCD_WR_DATA(0x00);
  1065.                 LCD_WR_DATA(0x0C);
  1066.                 LCD_WR_DATA(0x00);
  1067.                 LCD_WR_DATA(0x17);
  1068.                 LCD_WR_DATA(0x00);
  1069.                 LCD_WR_DATA(0x95);
  1070.                 LCD_WR_DATA(0x00);
  1071.                 LCD_WR_DATA(0xF3);
  1072.                 LCD_WR_DATA(0x00);
  1073.                 LCD_WR_DATA(0xE6);
  1074.                 LCD_WR_DATA(0x00);

  1075.                 LCD_WR_REG(0xC5);
  1076.                 LCD_WR_DATA(0x32);
  1077.                 LCD_WR_DATA(0x00);
  1078.                 LCD_WR_DATA(0x44);
  1079.                 LCD_WR_DATA(0x00);
  1080.                 LCD_WR_DATA(0x65);
  1081.                 LCD_WR_DATA(0x00);
  1082.                 LCD_WR_DATA(0x76);
  1083.                 LCD_WR_DATA(0x00);
  1084.                 LCD_WR_DATA(0x88);
  1085.                 LCD_WR_DATA(0x00);

  1086.                 LCD_WR_REG(0xC6);
  1087.                 LCD_WR_DATA(0x20);
  1088.                 LCD_WR_DATA(0x00);
  1089.                 LCD_WR_DATA(0x17);
  1090.                 LCD_WR_DATA(0x00);
  1091.                 LCD_WR_DATA(0x01);
  1092.                 LCD_WR_DATA(0x00);

  1093.                 LCD_WR_REG(0xC7);
  1094.                 LCD_WR_DATA(0x00);
  1095.                 LCD_WR_DATA(0x00);
  1096.                 LCD_WR_DATA(0x00);
  1097.                 LCD_WR_DATA(0x00);

  1098.                 LCD_WR_REG(0xC8);
  1099.                 LCD_WR_DATA(0x00);
  1100.                 LCD_WR_DATA(0x00);
  1101.                 LCD_WR_DATA(0x00);
  1102.                 LCD_WR_DATA(0x00);

  1103.                 LCD_WR_REG(0xC9);
  1104.                 LCD_WR_DATA(0x00);
  1105.                 LCD_WR_DATA(0x00);
  1106.                 LCD_WR_DATA(0x00);
  1107.                 LCD_WR_DATA(0x00);
  1108.                 LCD_WR_DATA(0x00);
  1109.                 LCD_WR_DATA(0x00);
  1110.                 LCD_WR_DATA(0x00);
  1111.                 LCD_WR_DATA(0x00);
  1112.                 LCD_WR_DATA(0x00);
  1113.                 LCD_WR_DATA(0x00);
  1114.                 LCD_WR_DATA(0x00);
  1115.                 LCD_WR_DATA(0x00);
  1116.                 LCD_WR_DATA(0x00);
  1117.                 LCD_WR_DATA(0x00);
  1118.                 LCD_WR_DATA(0x00);
  1119.                 LCD_WR_DATA(0x00);

  1120.                 LCD_WR_REG(0xE0);
  1121.                 LCD_WR_DATA(0x16);
  1122.                 LCD_WR_DATA(0x00);
  1123.                 LCD_WR_DATA(0x1C);
  1124.                 LCD_WR_DATA(0x00);
  1125.                 LCD_WR_DATA(0x21);
  1126.                 LCD_WR_DATA(0x00);
  1127.                 LCD_WR_DATA(0x36);
  1128.                 LCD_WR_DATA(0x00);
  1129.                 LCD_WR_DATA(0x46);
  1130.                 LCD_WR_DATA(0x00);
  1131.                 LCD_WR_DATA(0x52);
  1132.                 LCD_WR_DATA(0x00);
  1133.                 LCD_WR_DATA(0x64);
  1134.                 LCD_WR_DATA(0x00);
  1135.                 LCD_WR_DATA(0x7A);
  1136.                 LCD_WR_DATA(0x00);
  1137.                 LCD_WR_DATA(0x8B);
  1138.                 LCD_WR_DATA(0x00);
  1139.                 LCD_WR_DATA(0x99);
  1140.                 LCD_WR_DATA(0x00);
  1141.                 LCD_WR_DATA(0xA8);
  1142.                 LCD_WR_DATA(0x00);
  1143.                 LCD_WR_DATA(0xB9);
  1144.                 LCD_WR_DATA(0x00);
  1145.                 LCD_WR_DATA(0xC4);
  1146.                 LCD_WR_DATA(0x00);
  1147.                 LCD_WR_DATA(0xCA);
  1148.                 LCD_WR_DATA(0x00);
  1149.                 LCD_WR_DATA(0xD2);
  1150.                 LCD_WR_DATA(0x00);
  1151.                 LCD_WR_DATA(0xD9);
  1152.                 LCD_WR_DATA(0x00);
  1153.                 LCD_WR_DATA(0xE0);
  1154.                 LCD_WR_DATA(0x00);
  1155.                 LCD_WR_DATA(0xF3);
  1156.                 LCD_WR_DATA(0x00);

  1157.                 LCD_WR_REG(0xE1);
  1158.                 LCD_WR_DATA(0x16);
  1159.                 LCD_WR_DATA(0x00);
  1160.                 LCD_WR_DATA(0x1C);
  1161.                 LCD_WR_DATA(0x00);
  1162.                 LCD_WR_DATA(0x22);
  1163.                 LCD_WR_DATA(0x00);
  1164.                 LCD_WR_DATA(0x36);
  1165.                 LCD_WR_DATA(0x00);
  1166.                 LCD_WR_DATA(0x45);
  1167.                 LCD_WR_DATA(0x00);
  1168.                 LCD_WR_DATA(0x52);
  1169.                 LCD_WR_DATA(0x00);
  1170.                 LCD_WR_DATA(0x64);
  1171.                 LCD_WR_DATA(0x00);
  1172.                 LCD_WR_DATA(0x7A);
  1173.                 LCD_WR_DATA(0x00);
  1174.                 LCD_WR_DATA(0x8B);
  1175.                 LCD_WR_DATA(0x00);
  1176.                 LCD_WR_DATA(0x99);
  1177.                 LCD_WR_DATA(0x00);
  1178.                 LCD_WR_DATA(0xA8);
  1179.                 LCD_WR_DATA(0x00);
  1180.                 LCD_WR_DATA(0xB9);
  1181.                 LCD_WR_DATA(0x00);
  1182.                 LCD_WR_DATA(0xC4);
  1183.                 LCD_WR_DATA(0x00);
  1184.                 LCD_WR_DATA(0xCA);
  1185.                 LCD_WR_DATA(0x00);
  1186.                 LCD_WR_DATA(0xD2);
  1187.                 LCD_WR_DATA(0x00);
  1188.                 LCD_WR_DATA(0xD8);
  1189.                 LCD_WR_DATA(0x00);
  1190.                 LCD_WR_DATA(0xE0);
  1191.                 LCD_WR_DATA(0x00);
  1192.                 LCD_WR_DATA(0xF3);
  1193.                 LCD_WR_DATA(0x00);

  1194.                 LCD_WR_REG(0xE2);
  1195.                 LCD_WR_DATA(0x05);
  1196.                 LCD_WR_DATA(0x00);
  1197.                 LCD_WR_DATA(0x0B);
  1198.                 LCD_WR_DATA(0x00);
  1199.                 LCD_WR_DATA(0x1B);
  1200.                 LCD_WR_DATA(0x00);
  1201.                 LCD_WR_DATA(0x34);
  1202.                 LCD_WR_DATA(0x00);
  1203.                 LCD_WR_DATA(0x44);
  1204.                 LCD_WR_DATA(0x00);
  1205.                 LCD_WR_DATA(0x4F);
  1206.                 LCD_WR_DATA(0x00);
  1207.                 LCD_WR_DATA(0x61);
  1208.                 LCD_WR_DATA(0x00);
  1209.                 LCD_WR_DATA(0x79);
  1210.                 LCD_WR_DATA(0x00);
  1211.                 LCD_WR_DATA(0x88);
  1212.                 LCD_WR_DATA(0x00);
  1213.                 LCD_WR_DATA(0x97);
  1214.                 LCD_WR_DATA(0x00);
  1215.                 LCD_WR_DATA(0xA6);
  1216.                 LCD_WR_DATA(0x00);
  1217.                 LCD_WR_DATA(0xB7);
  1218.                 LCD_WR_DATA(0x00);
  1219.                 LCD_WR_DATA(0xC2);
  1220.                 LCD_WR_DATA(0x00);
  1221.                 LCD_WR_DATA(0xC7);
  1222.                 LCD_WR_DATA(0x00);
  1223.                 LCD_WR_DATA(0xD1);
  1224.                 LCD_WR_DATA(0x00);
  1225.                 LCD_WR_DATA(0xD6);
  1226.                 LCD_WR_DATA(0x00);
  1227.                 LCD_WR_DATA(0xDD);
  1228.                 LCD_WR_DATA(0x00);
  1229.                 LCD_WR_DATA(0xF3);
  1230.                 LCD_WR_DATA(0x00);
  1231.                 LCD_WR_REG(0xE3);
  1232.                 LCD_WR_DATA(0x05);
  1233.                 LCD_WR_DATA(0x00);
  1234.                 LCD_WR_DATA(0xA);
  1235.                 LCD_WR_DATA(0x00);
  1236.                 LCD_WR_DATA(0x1C);
  1237.                 LCD_WR_DATA(0x00);
  1238.                 LCD_WR_DATA(0x33);
  1239.                 LCD_WR_DATA(0x00);
  1240.                 LCD_WR_DATA(0x44);
  1241.                 LCD_WR_DATA(0x00);
  1242.                 LCD_WR_DATA(0x50);
  1243.                 LCD_WR_DATA(0x00);
  1244.                 LCD_WR_DATA(0x62);
  1245.                 LCD_WR_DATA(0x00);
  1246.                 LCD_WR_DATA(0x78);
  1247.                 LCD_WR_DATA(0x00);
  1248.                 LCD_WR_DATA(0x88);
  1249.                 LCD_WR_DATA(0x00);
  1250.                 LCD_WR_DATA(0x97);
  1251.                 LCD_WR_DATA(0x00);
  1252.                 LCD_WR_DATA(0xA6);
  1253.                 LCD_WR_DATA(0x00);
  1254.                 LCD_WR_DATA(0xB7);
  1255.                 LCD_WR_DATA(0x00);
  1256.                 LCD_WR_DATA(0xC2);
  1257.                 LCD_WR_DATA(0x00);
  1258.                 LCD_WR_DATA(0xC7);
  1259.                 LCD_WR_DATA(0x00);
  1260.                 LCD_WR_DATA(0xD1);
  1261.                 LCD_WR_DATA(0x00);
  1262.                 LCD_WR_DATA(0xD5);
  1263.                 LCD_WR_DATA(0x00);
  1264.                 LCD_WR_DATA(0xDD);
  1265.                 LCD_WR_DATA(0x00);
  1266.                 LCD_WR_DATA(0xF3);
  1267.                 LCD_WR_DATA(0x00);

  1268.                 LCD_WR_REG(0xE4);
  1269.                 LCD_WR_DATA(0x01);
  1270.                 LCD_WR_DATA(0x00);
  1271.                 LCD_WR_DATA(0x01);
  1272.                 LCD_WR_DATA(0x00);
  1273.                 LCD_WR_DATA(0x02);
  1274.                 LCD_WR_DATA(0x00);
  1275.                 LCD_WR_DATA(0x2A);
  1276.                 LCD_WR_DATA(0x00);
  1277.                 LCD_WR_DATA(0x3C);
  1278.                 LCD_WR_DATA(0x00);
  1279.                 LCD_WR_DATA(0x4B);
  1280.                 LCD_WR_DATA(0x00);
  1281.                 LCD_WR_DATA(0x5D);
  1282.                 LCD_WR_DATA(0x00);
  1283.                 LCD_WR_DATA(0x74);
  1284.                 LCD_WR_DATA(0x00);
  1285.                 LCD_WR_DATA(0x84);
  1286.                 LCD_WR_DATA(0x00);
  1287.                 LCD_WR_DATA(0x93);
  1288.                 LCD_WR_DATA(0x00);
  1289.                 LCD_WR_DATA(0xA2);
  1290.                 LCD_WR_DATA(0x00);
  1291.                 LCD_WR_DATA(0xB3);
  1292.                 LCD_WR_DATA(0x00);
  1293.                 LCD_WR_DATA(0xBE);
  1294.                 LCD_WR_DATA(0x00);
  1295.                 LCD_WR_DATA(0xC4);
  1296.                 LCD_WR_DATA(0x00);
  1297.                 LCD_WR_DATA(0xCD);
  1298.                 LCD_WR_DATA(0x00);
  1299.                 LCD_WR_DATA(0xD3);
  1300.                 LCD_WR_DATA(0x00);
  1301.                 LCD_WR_DATA(0xDD);
  1302.                 LCD_WR_DATA(0x00);
  1303.                 LCD_WR_DATA(0xF3);
  1304.                 LCD_WR_DATA(0x00);
  1305.                 LCD_WR_REG(0xE5);
  1306.                 LCD_WR_DATA(0x00);
  1307.                 LCD_WR_DATA(0x00);
  1308.                 LCD_WR_DATA(0x00);
  1309.                 LCD_WR_DATA(0x00);
  1310.                 LCD_WR_DATA(0x02);
  1311.                 LCD_WR_DATA(0x00);
  1312.                 LCD_WR_DATA(0x29);
  1313.                 LCD_WR_DATA(0x00);
  1314.                 LCD_WR_DATA(0x3C);
  1315.                 LCD_WR_DATA(0x00);
  1316.                 LCD_WR_DATA(0x4B);
  1317.                 LCD_WR_DATA(0x00);
  1318.                 LCD_WR_DATA(0x5D);
  1319.                 LCD_WR_DATA(0x00);
  1320.                 LCD_WR_DATA(0x74);
  1321.                 LCD_WR_DATA(0x00);
  1322.                 LCD_WR_DATA(0x84);
  1323.                 LCD_WR_DATA(0x00);
  1324.                 LCD_WR_DATA(0x93);
  1325.                 LCD_WR_DATA(0x00);
  1326.                 LCD_WR_DATA(0xA2);
  1327.                 LCD_WR_DATA(0x00);
  1328.                 LCD_WR_DATA(0xB3);
  1329.                 LCD_WR_DATA(0x00);
  1330.                 LCD_WR_DATA(0xBE);
  1331.                 LCD_WR_DATA(0x00);
  1332.                 LCD_WR_DATA(0xC4);
  1333.                 LCD_WR_DATA(0x00);
  1334.                 LCD_WR_DATA(0xCD);
  1335.                 LCD_WR_DATA(0x00);
  1336.                 LCD_WR_DATA(0xD3);
  1337.                 LCD_WR_DATA(0x00);
  1338.                 LCD_WR_DATA(0xDC);
  1339.                 LCD_WR_DATA(0x00);
  1340.                 LCD_WR_DATA(0xF3);
  1341.                 LCD_WR_DATA(0x00);

  1342.                 LCD_WR_REG(0xE6);
  1343.                 LCD_WR_DATA(0x11);
  1344.                 LCD_WR_DATA(0x00);
  1345.                 LCD_WR_DATA(0x34);
  1346.                 LCD_WR_DATA(0x00);
  1347.                 LCD_WR_DATA(0x56);
  1348.                 LCD_WR_DATA(0x00);
  1349.                 LCD_WR_DATA(0x76);
  1350.                 LCD_WR_DATA(0x00);
  1351.                 LCD_WR_DATA(0x77);
  1352.                 LCD_WR_DATA(0x00);
  1353.                 LCD_WR_DATA(0x66);
  1354.                 LCD_WR_DATA(0x00);
  1355.                 LCD_WR_DATA(0x88);
  1356.                 LCD_WR_DATA(0x00);
  1357.                 LCD_WR_DATA(0x99);
  1358.                 LCD_WR_DATA(0x00);
  1359.                 LCD_WR_DATA(0xBB);
  1360.                 LCD_WR_DATA(0x00);
  1361.                 LCD_WR_DATA(0x99);
  1362.                 LCD_WR_DATA(0x00);
  1363.                 LCD_WR_DATA(0x66);
  1364.                 LCD_WR_DATA(0x00);
  1365.                 LCD_WR_DATA(0x55);
  1366.                 LCD_WR_DATA(0x00);
  1367.                 LCD_WR_DATA(0x55);
  1368.                 LCD_WR_DATA(0x00);
  1369.                 LCD_WR_DATA(0x45);
  1370.                 LCD_WR_DATA(0x00);
  1371.                 LCD_WR_DATA(0x43);
  1372.                 LCD_WR_DATA(0x00);
  1373.                 LCD_WR_DATA(0x44);
  1374.                 LCD_WR_DATA(0x00);

  1375.                 LCD_WR_REG(0xE7);
  1376.                 LCD_WR_DATA(0x32);
  1377.                 LCD_WR_DATA(0x00);
  1378.                 LCD_WR_DATA(0x55);
  1379.                 LCD_WR_DATA(0x00);
  1380.                 LCD_WR_DATA(0x76);
  1381.                 LCD_WR_DATA(0x00);
  1382.                 LCD_WR_DATA(0x66);
  1383.                 LCD_WR_DATA(0x00);
  1384.                 LCD_WR_DATA(0x67);
  1385.                 LCD_WR_DATA(0x00);
  1386.                 LCD_WR_DATA(0x67);
  1387.                 LCD_WR_DATA(0x00);
  1388.                 LCD_WR_DATA(0x87);
  1389.                 LCD_WR_DATA(0x00);
  1390.                 LCD_WR_DATA(0x99);
  1391.                 LCD_WR_DATA(0x00);
  1392.                 LCD_WR_DATA(0xBB);
  1393.                 LCD_WR_DATA(0x00);
  1394.                 LCD_WR_DATA(0x99);
  1395.                 LCD_WR_DATA(0x00);
  1396.                 LCD_WR_DATA(0x77);
  1397.                 LCD_WR_DATA(0x00);
  1398.                 LCD_WR_DATA(0x44);
  1399.                 LCD_WR_DATA(0x00);
  1400.                 LCD_WR_DATA(0x56);
  1401.                 LCD_WR_DATA(0x00);
  1402.                 LCD_WR_DATA(0x23);
  1403.                 LCD_WR_DATA(0x00);
  1404.                 LCD_WR_DATA(0x33);
  1405.                 LCD_WR_DATA(0x00);
  1406.                 LCD_WR_DATA(0x45);
  1407.                 LCD_WR_DATA(0x00);

  1408.                 LCD_WR_REG(0xE8);
  1409.                 LCD_WR_DATA(0x00);
  1410.                 LCD_WR_DATA(0x00);
  1411.                 LCD_WR_DATA(0x99);
  1412.                 LCD_WR_DATA(0x00);
  1413.                 LCD_WR_DATA(0x87);
  1414.                 LCD_WR_DATA(0x00);
  1415.                 LCD_WR_DATA(0x88);
  1416.                 LCD_WR_DATA(0x00);
  1417.                 LCD_WR_DATA(0x77);
  1418.                 LCD_WR_DATA(0x00);
  1419.                 LCD_WR_DATA(0x66);
  1420.                 LCD_WR_DATA(0x00);
  1421.                 LCD_WR_DATA(0x88);
  1422.                 LCD_WR_DATA(0x00);
  1423.                 LCD_WR_DATA(0xAA);
  1424.                 LCD_WR_DATA(0x00);
  1425.                 LCD_WR_DATA(0xBB);
  1426.                 LCD_WR_DATA(0x00);
  1427.                 LCD_WR_DATA(0x99);
  1428.                 LCD_WR_DATA(0x00);
  1429.                 LCD_WR_DATA(0x66);
  1430.                 LCD_WR_DATA(0x00);
  1431.                 LCD_WR_DATA(0x55);
  1432.                 LCD_WR_DATA(0x00);
  1433.                 LCD_WR_DATA(0x55);
  1434.                 LCD_WR_DATA(0x00);
  1435.                 LCD_WR_DATA(0x44);
  1436.                 LCD_WR_DATA(0x00);
  1437.                 LCD_WR_DATA(0x44);
  1438.                 LCD_WR_DATA(0x00);
  1439.                 LCD_WR_DATA(0x55);
  1440.                 LCD_WR_DATA(0x00);

  1441.                 LCD_WR_REG(0xE9);
  1442.                 LCD_WR_DATA(0xAA);
  1443.                 LCD_WR_DATA(0x00);
  1444.                 LCD_WR_DATA(0x00);
  1445.                 LCD_WR_DATA(0x00);

  1446.                 LCD_WR_REG(0x00);
  1447.                 LCD_WR_DATA(0xAA);

  1448.                 LCD_WR_REG(0xCF);
  1449.                 LCD_WR_DATA(0x00);
  1450.                 LCD_WR_DATA(0x00);
  1451.                 LCD_WR_DATA(0x00);
  1452.                 LCD_WR_DATA(0x00);
  1453.                 LCD_WR_DATA(0x00);
  1454.                 LCD_WR_DATA(0x00);
  1455.                 LCD_WR_DATA(0x00);
  1456.                 LCD_WR_DATA(0x00);
  1457.                 LCD_WR_DATA(0x00);
  1458.                 LCD_WR_DATA(0x00);
  1459.                 LCD_WR_DATA(0x00);
  1460.                 LCD_WR_DATA(0x00);
  1461.                 LCD_WR_DATA(0x00);
  1462.                 LCD_WR_DATA(0x00);
  1463.                 LCD_WR_DATA(0x00);
  1464.                 LCD_WR_DATA(0x00);
  1465.                 LCD_WR_DATA(0x00);

  1466.                 LCD_WR_REG(0xF0);
  1467.                 LCD_WR_DATA(0x00);
  1468.                 LCD_WR_DATA(0x50);
  1469.                 LCD_WR_DATA(0x00);
  1470.                 LCD_WR_DATA(0x00);
  1471.                 LCD_WR_DATA(0x00);

  1472.                 LCD_WR_REG(0xF3);
  1473.                 LCD_WR_DATA(0x00);

  1474.                 LCD_WR_REG(0xF9);
  1475.                 LCD_WR_DATA(0x06);
  1476.                 LCD_WR_DATA(0x10);
  1477.                 LCD_WR_DATA(0x29);
  1478.                 LCD_WR_DATA(0x00);

  1479.                 LCD_WR_REG(0x3A);
  1480.                 LCD_WR_DATA(0x55);        //66

  1481.                 LCD_WR_REG(0x11);
  1482.                 delay_ms(100);
  1483.                 LCD_WR_REG(0x29);
  1484.                 LCD_WR_REG(0x35);
  1485.                 LCD_WR_DATA(0x00);

  1486.                 LCD_WR_REG(0x51);
  1487.                 LCD_WR_DATA(0xFF);
  1488.                 LCD_WR_REG(0x53);
  1489.                 LCD_WR_DATA(0x2C);
  1490.                 LCD_WR_REG(0x55);
  1491.                 LCD_WR_DATA(0x82);
  1492.                 LCD_WR_REG(0x2c);
  1493.         }else if(lcddev.id==0x5510)
  1494.         {
  1495.                 LCD_WriteReg(0xF000,0x55);
  1496.                 LCD_WriteReg(0xF001,0xAA);
  1497.                 LCD_WriteReg(0xF002,0x52);
  1498.                 LCD_WriteReg(0xF003,0x08);
  1499.                 LCD_WriteReg(0xF004,0x01);
  1500.                 //AVDD Set AVDD 5.2V
  1501.                 LCD_WriteReg(0xB000,0x0D);
  1502.                 LCD_WriteReg(0xB001,0x0D);
  1503.                 LCD_WriteReg(0xB002,0x0D);
  1504.                 //AVDD ratio
  1505.                 LCD_WriteReg(0xB600,0x34);
  1506.                 LCD_WriteReg(0xB601,0x34);
  1507.                 LCD_WriteReg(0xB602,0x34);
  1508.                 //AVEE -5.2V
  1509.                 LCD_WriteReg(0xB100,0x0D);
  1510.                 LCD_WriteReg(0xB101,0x0D);
  1511.                 LCD_WriteReg(0xB102,0x0D);
  1512.                 //AVEE ratio
  1513.                 LCD_WriteReg(0xB700,0x34);
  1514.                 LCD_WriteReg(0xB701,0x34);
  1515.                 LCD_WriteReg(0xB702,0x34);
  1516.                 //VCL -2.5V
  1517.                 LCD_WriteReg(0xB200,0x00);
  1518.                 LCD_WriteReg(0xB201,0x00);
  1519.                 LCD_WriteReg(0xB202,0x00);
  1520.                 //VCL ratio
  1521.                 LCD_WriteReg(0xB800,0x24);
  1522.                 LCD_WriteReg(0xB801,0x24);
  1523.                 LCD_WriteReg(0xB802,0x24);
  1524.                 //VGH 15V (Free pump)
  1525.                 LCD_WriteReg(0xBF00,0x01);
  1526.                 LCD_WriteReg(0xB300,0x0F);
  1527.                 LCD_WriteReg(0xB301,0x0F);
  1528.                 LCD_WriteReg(0xB302,0x0F);
  1529.                 //VGH ratio
  1530.                 LCD_WriteReg(0xB900,0x34);
  1531.                 LCD_WriteReg(0xB901,0x34);
  1532.                 LCD_WriteReg(0xB902,0x34);
  1533.                 //VGL_REG -10V
  1534.                 LCD_WriteReg(0xB500,0x08);
  1535.                 LCD_WriteReg(0xB501,0x08);
  1536.                 LCD_WriteReg(0xB502,0x08);
  1537.                 LCD_WriteReg(0xC200,0x03);
  1538.                 //VGLX ratio
  1539.                 LCD_WriteReg(0xBA00,0x24);
  1540.                 LCD_WriteReg(0xBA01,0x24);
  1541.                 LCD_WriteReg(0xBA02,0x24);
  1542.                 //VGMP/VGSP 4.5V/0V
  1543.                 LCD_WriteReg(0xBC00,0x00);
  1544.                 LCD_WriteReg(0xBC01,0x78);
  1545.                 LCD_WriteReg(0xBC02,0x00);
  1546.                 //VGMN/VGSN -4.5V/0V
  1547.                 LCD_WriteReg(0xBD00,0x00);
  1548.                 LCD_WriteReg(0xBD01,0x78);
  1549.                 LCD_WriteReg(0xBD02,0x00);
  1550.                 //VCOM
  1551.                 LCD_WriteReg(0xBE00,0x00);
  1552.                 LCD_WriteReg(0xBE01,0x64);
  1553.                 //Gamma Setting
  1554.                 LCD_WriteReg(0xD100,0x00);
  1555.                 LCD_WriteReg(0xD101,0x33);
  1556.                 LCD_WriteReg(0xD102,0x00);
  1557.                 LCD_WriteReg(0xD103,0x34);
  1558.                 LCD_WriteReg(0xD104,0x00);
  1559.                 LCD_WriteReg(0xD105,0x3A);
  1560.                 LCD_WriteReg(0xD106,0x00);
  1561.                 LCD_WriteReg(0xD107,0x4A);
  1562.                 LCD_WriteReg(0xD108,0x00);
  1563.                 LCD_WriteReg(0xD109,0x5C);
  1564.                 LCD_WriteReg(0xD10A,0x00);
  1565.                 LCD_WriteReg(0xD10B,0x81);
  1566.                 LCD_WriteReg(0xD10C,0x00);
  1567.                 LCD_WriteReg(0xD10D,0xA6);
  1568.                 LCD_WriteReg(0xD10E,0x00);
  1569.                 LCD_WriteReg(0xD10F,0xE5);
  1570.                 LCD_WriteReg(0xD110,0x01);
  1571.                 LCD_WriteReg(0xD111,0x13);
  1572.                 LCD_WriteReg(0xD112,0x01);
  1573.                 LCD_WriteReg(0xD113,0x54);
  1574.                 LCD_WriteReg(0xD114,0x01);
  1575.                 LCD_WriteReg(0xD115,0x82);
  1576.                 LCD_WriteReg(0xD116,0x01);
  1577.                 LCD_WriteReg(0xD117,0xCA);
  1578.                 LCD_WriteReg(0xD118,0x02);
  1579.                 LCD_WriteReg(0xD119,0x00);
  1580.                 LCD_WriteReg(0xD11A,0x02);
  1581.                 LCD_WriteReg(0xD11B,0x01);
  1582.                 LCD_WriteReg(0xD11C,0x02);
  1583.                 LCD_WriteReg(0xD11D,0x34);
  1584.                 LCD_WriteReg(0xD11E,0x02);
  1585.                 LCD_WriteReg(0xD11F,0x67);
  1586.                 LCD_WriteReg(0xD120,0x02);
  1587.                 LCD_WriteReg(0xD121,0x84);
  1588.                 LCD_WriteReg(0xD122,0x02);
  1589.                 LCD_WriteReg(0xD123,0xA4);
  1590.                 LCD_WriteReg(0xD124,0x02);
  1591.                 LCD_WriteReg(0xD125,0xB7);
  1592.                 LCD_WriteReg(0xD126,0x02);
  1593.                 LCD_WriteReg(0xD127,0xCF);
  1594.                 LCD_WriteReg(0xD128,0x02);
  1595.                 LCD_WriteReg(0xD129,0xDE);
  1596.                 LCD_WriteReg(0xD12A,0x02);
  1597.                 LCD_WriteReg(0xD12B,0xF2);
  1598.                 LCD_WriteReg(0xD12C,0x02);
  1599.                 LCD_WriteReg(0xD12D,0xFE);
  1600.                 LCD_WriteReg(0xD12E,0x03);
  1601.                 LCD_WriteReg(0xD12F,0x10);
  1602.                 LCD_WriteReg(0xD130,0x03);
  1603.                 LCD_WriteReg(0xD131,0x33);
  1604.                 LCD_WriteReg(0xD132,0x03);
  1605.                 LCD_WriteReg(0xD133,0x6D);
  1606.                 LCD_WriteReg(0xD200,0x00);
  1607.                 LCD_WriteReg(0xD201,0x33);
  1608.                 LCD_WriteReg(0xD202,0x00);
  1609.                 LCD_WriteReg(0xD203,0x34);
  1610.                 LCD_WriteReg(0xD204,0x00);
  1611.                 LCD_WriteReg(0xD205,0x3A);
  1612.                 LCD_WriteReg(0xD206,0x00);
  1613.                 LCD_WriteReg(0xD207,0x4A);
  1614.                 LCD_WriteReg(0xD208,0x00);
  1615.                 LCD_WriteReg(0xD209,0x5C);
  1616.                 LCD_WriteReg(0xD20A,0x00);

  1617.                 LCD_WriteReg(0xD20B,0x81);
  1618.                 LCD_WriteReg(0xD20C,0x00);
  1619.                 LCD_WriteReg(0xD20D,0xA6);
  1620.                 LCD_WriteReg(0xD20E,0x00);
  1621.                 LCD_WriteReg(0xD20F,0xE5);
  1622.                 LCD_WriteReg(0xD210,0x01);
  1623.                 LCD_WriteReg(0xD211,0x13);
  1624.                 LCD_WriteReg(0xD212,0x01);
  1625.                 LCD_WriteReg(0xD213,0x54);
  1626.                 LCD_WriteReg(0xD214,0x01);
  1627.                 LCD_WriteReg(0xD215,0x82);
  1628.                 LCD_WriteReg(0xD216,0x01);
  1629.                 LCD_WriteReg(0xD217,0xCA);
  1630.                 LCD_WriteReg(0xD218,0x02);
  1631.                 LCD_WriteReg(0xD219,0x00);
  1632.                 LCD_WriteReg(0xD21A,0x02);
  1633.                 LCD_WriteReg(0xD21B,0x01);
  1634.                 LCD_WriteReg(0xD21C,0x02);
  1635.                 LCD_WriteReg(0xD21D,0x34);
  1636.                 LCD_WriteReg(0xD21E,0x02);
  1637.                 LCD_WriteReg(0xD21F,0x67);
  1638.                 LCD_WriteReg(0xD220,0x02);
  1639.                 LCD_WriteReg(0xD221,0x84);
  1640.                 LCD_WriteReg(0xD222,0x02);
  1641.                 LCD_WriteReg(0xD223,0xA4);
  1642.                 LCD_WriteReg(0xD224,0x02);
  1643.                 LCD_WriteReg(0xD225,0xB7);
  1644.                 LCD_WriteReg(0xD226,0x02);
  1645.                 LCD_WriteReg(0xD227,0xCF);
  1646.                 LCD_WriteReg(0xD228,0x02);
  1647.                 LCD_WriteReg(0xD229,0xDE);
  1648.                 LCD_WriteReg(0xD22A,0x02);
  1649.                 LCD_WriteReg(0xD22B,0xF2);
  1650.                 LCD_WriteReg(0xD22C,0x02);
  1651.                 LCD_WriteReg(0xD22D,0xFE);
  1652.                 LCD_WriteReg(0xD22E,0x03);
  1653.                 LCD_WriteReg(0xD22F,0x10);
  1654.                 LCD_WriteReg(0xD230,0x03);
  1655.                 LCD_WriteReg(0xD231,0x33);
  1656.                 LCD_WriteReg(0xD232,0x03);
  1657.                 LCD_WriteReg(0xD233,0x6D);
  1658.                 LCD_WriteReg(0xD300,0x00);
  1659.                 LCD_WriteReg(0xD301,0x33);
  1660.                 LCD_WriteReg(0xD302,0x00);
  1661.                 LCD_WriteReg(0xD303,0x34);
  1662.                 LCD_WriteReg(0xD304,0x00);
  1663.                 LCD_WriteReg(0xD305,0x3A);
  1664.                 LCD_WriteReg(0xD306,0x00);
  1665.                 LCD_WriteReg(0xD307,0x4A);
  1666.                 LCD_WriteReg(0xD308,0x00);
  1667.                 LCD_WriteReg(0xD309,0x5C);
  1668.                 LCD_WriteReg(0xD30A,0x00);

  1669.                 LCD_WriteReg(0xD30B,0x81);
  1670.                 LCD_WriteReg(0xD30C,0x00);
  1671.                 LCD_WriteReg(0xD30D,0xA6);
  1672.                 LCD_WriteReg(0xD30E,0x00);
  1673.                 LCD_WriteReg(0xD30F,0xE5);
  1674.                 LCD_WriteReg(0xD310,0x01);
  1675.                 LCD_WriteReg(0xD311,0x13);
  1676.                 LCD_WriteReg(0xD312,0x01);
  1677.                 LCD_WriteReg(0xD313,0x54);
  1678.                 LCD_WriteReg(0xD314,0x01);
  1679.                 LCD_WriteReg(0xD315,0x82);
  1680.                 LCD_WriteReg(0xD316,0x01);
  1681.                 LCD_WriteReg(0xD317,0xCA);
  1682.                 LCD_WriteReg(0xD318,0x02);
  1683.                 LCD_WriteReg(0xD319,0x00);
  1684.                 LCD_WriteReg(0xD31A,0x02);
  1685.                 LCD_WriteReg(0xD31B,0x01);
  1686.                 LCD_WriteReg(0xD31C,0x02);
  1687.                 LCD_WriteReg(0xD31D,0x34);
  1688.                 LCD_WriteReg(0xD31E,0x02);
  1689.                 LCD_WriteReg(0xD31F,0x67);
  1690.                 LCD_WriteReg(0xD320,0x02);
  1691.                 LCD_WriteReg(0xD321,0x84);
  1692.                 LCD_WriteReg(0xD322,0x02);
  1693.                 LCD_WriteReg(0xD323,0xA4);
  1694.                 LCD_WriteReg(0xD324,0x02);
  1695.                 LCD_WriteReg(0xD325,0xB7);
  1696.                 LCD_WriteReg(0xD326,0x02);
  1697.                 LCD_WriteReg(0xD327,0xCF);
  1698.                 LCD_WriteReg(0xD328,0x02);
  1699.                 LCD_WriteReg(0xD329,0xDE);
  1700.                 LCD_WriteReg(0xD32A,0x02);
  1701.                 LCD_WriteReg(0xD32B,0xF2);
  1702.                 LCD_WriteReg(0xD32C,0x02);
  1703.                 LCD_WriteReg(0xD32D,0xFE);
  1704.                 LCD_WriteReg(0xD32E,0x03);
  1705.                 LCD_WriteReg(0xD32F,0x10);
  1706.                 LCD_WriteReg(0xD330,0x03);
  1707.                 LCD_WriteReg(0xD331,0x33);
  1708.                 LCD_WriteReg(0xD332,0x03);
  1709.                 LCD_WriteReg(0xD333,0x6D);
  1710.                 LCD_WriteReg(0xD400,0x00);
  1711.                 LCD_WriteReg(0xD401,0x33);
  1712.                 LCD_WriteReg(0xD402,0x00);
  1713.                 LCD_WriteReg(0xD403,0x34);
  1714.                 LCD_WriteReg(0xD404,0x00);
  1715.                 LCD_WriteReg(0xD405,0x3A);
  1716.                 LCD_WriteReg(0xD406,0x00);
  1717.                 LCD_WriteReg(0xD407,0x4A);
  1718.                 LCD_WriteReg(0xD408,0x00);
  1719.                 LCD_WriteReg(0xD409,0x5C);
  1720.                 LCD_WriteReg(0xD40A,0x00);
  1721.                 LCD_WriteReg(0xD40B,0x81);

  1722.                 LCD_WriteReg(0xD40C,0x00);
  1723.                 LCD_WriteReg(0xD40D,0xA6);
  1724.                 LCD_WriteReg(0xD40E,0x00);
  1725.                 LCD_WriteReg(0xD40F,0xE5);
  1726.                 LCD_WriteReg(0xD410,0x01);
  1727.                 LCD_WriteReg(0xD411,0x13);
  1728.                 LCD_WriteReg(0xD412,0x01);
  1729.                 LCD_WriteReg(0xD413,0x54);
  1730.                 LCD_WriteReg(0xD414,0x01);
  1731.                 LCD_WriteReg(0xD415,0x82);
  1732.                 LCD_WriteReg(0xD416,0x01);
  1733.                 LCD_WriteReg(0xD417,0xCA);
  1734.                 LCD_WriteReg(0xD418,0x02);
  1735.                 LCD_WriteReg(0xD419,0x00);
  1736.                 LCD_WriteReg(0xD41A,0x02);
  1737.                 LCD_WriteReg(0xD41B,0x01);
  1738.                 LCD_WriteReg(0xD41C,0x02);
  1739.                 LCD_WriteReg(0xD41D,0x34);
  1740.                 LCD_WriteReg(0xD41E,0x02);
  1741.                 LCD_WriteReg(0xD41F,0x67);
  1742.                 LCD_WriteReg(0xD420,0x02);
  1743.                 LCD_WriteReg(0xD421,0x84);
  1744.                 LCD_WriteReg(0xD422,0x02);
  1745.                 LCD_WriteReg(0xD423,0xA4);
  1746.                 LCD_WriteReg(0xD424,0x02);
  1747.                 LCD_WriteReg(0xD425,0xB7);
  1748.                 LCD_WriteReg(0xD426,0x02);
  1749.                 LCD_WriteReg(0xD427,0xCF);
  1750.                 LCD_WriteReg(0xD428,0x02);
  1751.                 LCD_WriteReg(0xD429,0xDE);
  1752.                 LCD_WriteReg(0xD42A,0x02);
  1753.                 LCD_WriteReg(0xD42B,0xF2);
  1754.                 LCD_WriteReg(0xD42C,0x02);
  1755.                 LCD_WriteReg(0xD42D,0xFE);
  1756.                 LCD_WriteReg(0xD42E,0x03);
  1757.                 LCD_WriteReg(0xD42F,0x10);
  1758.                 LCD_WriteReg(0xD430,0x03);
  1759.                 LCD_WriteReg(0xD431,0x33);
  1760.                 LCD_WriteReg(0xD432,0x03);
  1761.                 LCD_WriteReg(0xD433,0x6D);
  1762.                 LCD_WriteReg(0xD500,0x00);
  1763.                 LCD_WriteReg(0xD501,0x33);
  1764.                 LCD_WriteReg(0xD502,0x00);
  1765.                 LCD_WriteReg(0xD503,0x34);
  1766.                 LCD_WriteReg(0xD504,0x00);
  1767.                 LCD_WriteReg(0xD505,0x3A);
  1768.                 LCD_WriteReg(0xD506,0x00);
  1769.                 LCD_WriteReg(0xD507,0x4A);
  1770.                 LCD_WriteReg(0xD508,0x00);
  1771.                 LCD_WriteReg(0xD509,0x5C);
  1772.                 LCD_WriteReg(0xD50A,0x00);
  1773.                 LCD_WriteReg(0xD50B,0x81);

  1774.                 LCD_WriteReg(0xD50C,0x00);
  1775.                 LCD_WriteReg(0xD50D,0xA6);
  1776.                 LCD_WriteReg(0xD50E,0x00);
  1777.                 LCD_WriteReg(0xD50F,0xE5);
  1778.                 LCD_WriteReg(0xD510,0x01);
  1779.                 LCD_WriteReg(0xD511,0x13);
  1780.                 LCD_WriteReg(0xD512,0x01);
  1781.                 LCD_WriteReg(0xD513,0x54);
  1782.                 LCD_WriteReg(0xD514,0x01);
  1783.                 LCD_WriteReg(0xD515,0x82);
  1784.                 LCD_WriteReg(0xD516,0x01);
  1785.                 LCD_WriteReg(0xD517,0xCA);
  1786.                 LCD_WriteReg(0xD518,0x02);
  1787.                 LCD_WriteReg(0xD519,0x00);
  1788.                 LCD_WriteReg(0xD51A,0x02);
  1789.                 LCD_WriteReg(0xD51B,0x01);
  1790.                 LCD_WriteReg(0xD51C,0x02);
  1791.                 LCD_WriteReg(0xD51D,0x34);
  1792.                 LCD_WriteReg(0xD51E,0x02);
  1793.                 LCD_WriteReg(0xD51F,0x67);
  1794.                 LCD_WriteReg(0xD520,0x02);
  1795.                 LCD_WriteReg(0xD521,0x84);
  1796.                 LCD_WriteReg(0xD522,0x02);
  1797.                 LCD_WriteReg(0xD523,0xA4);
  1798.                 LCD_WriteReg(0xD524,0x02);
  1799.                 LCD_WriteReg(0xD525,0xB7);
  1800.                 LCD_WriteReg(0xD526,0x02);
  1801.                 LCD_WriteReg(0xD527,0xCF);
  1802.                 LCD_WriteReg(0xD528,0x02);
  1803.                 LCD_WriteReg(0xD529,0xDE);
  1804.                 LCD_WriteReg(0xD52A,0x02);
  1805.                 LCD_WriteReg(0xD52B,0xF2);
  1806.                 LCD_WriteReg(0xD52C,0x02);
  1807.                 LCD_WriteReg(0xD52D,0xFE);
  1808.                 LCD_WriteReg(0xD52E,0x03);
  1809.                 LCD_WriteReg(0xD52F,0x10);
  1810.                 LCD_WriteReg(0xD530,0x03);
  1811.                 LCD_WriteReg(0xD531,0x33);
  1812.                 LCD_WriteReg(0xD532,0x03);
  1813.                 LCD_WriteReg(0xD533,0x6D);
  1814.                 LCD_WriteReg(0xD600,0x00);
  1815.                 LCD_WriteReg(0xD601,0x33);
  1816.                 LCD_WriteReg(0xD602,0x00);
  1817.                 LCD_WriteReg(0xD603,0x34);
  1818.                 LCD_WriteReg(0xD604,0x00);
  1819.                 LCD_WriteReg(0xD605,0x3A);
  1820.                 LCD_WriteReg(0xD606,0x00);
  1821.                 LCD_WriteReg(0xD607,0x4A);
  1822.                 LCD_WriteReg(0xD608,0x00);
  1823.                 LCD_WriteReg(0xD609,0x5C);
  1824.                 LCD_WriteReg(0xD60A,0x00);
  1825.                 LCD_WriteReg(0xD60B,0x81);

  1826.                 LCD_WriteReg(0xD60C,0x00);
  1827.                 LCD_WriteReg(0xD60D,0xA6);
  1828.                 LCD_WriteReg(0xD60E,0x00);
  1829.                 LCD_WriteReg(0xD60F,0xE5);
  1830.                 LCD_WriteReg(0xD610,0x01);
  1831.                 LCD_WriteReg(0xD611,0x13);
  1832.                 LCD_WriteReg(0xD612,0x01);
  1833.                 LCD_WriteReg(0xD613,0x54);
  1834.                 LCD_WriteReg(0xD614,0x01);
  1835.                 LCD_WriteReg(0xD615,0x82);
  1836.                 LCD_WriteReg(0xD616,0x01);
  1837.                 LCD_WriteReg(0xD617,0xCA);
  1838.                 LCD_WriteReg(0xD618,0x02);
  1839.                 LCD_WriteReg(0xD619,0x00);
  1840.                 LCD_WriteReg(0xD61A,0x02);
  1841.                 LCD_WriteReg(0xD61B,0x01);
  1842.                 LCD_WriteReg(0xD61C,0x02);
  1843.                 LCD_WriteReg(0xD61D,0x34);
  1844.                 LCD_WriteReg(0xD61E,0x02);
  1845.                 LCD_WriteReg(0xD61F,0x67);
  1846.                 LCD_WriteReg(0xD620,0x02);
  1847.                 LCD_WriteReg(0xD621,0x84);
  1848.                 LCD_WriteReg(0xD622,0x02);
  1849.                 LCD_WriteReg(0xD623,0xA4);
  1850.                 LCD_WriteReg(0xD624,0x02);
  1851.                 LCD_WriteReg(0xD625,0xB7);
  1852.                 LCD_WriteReg(0xD626,0x02);
  1853.                 LCD_WriteReg(0xD627,0xCF);
  1854.                 LCD_WriteReg(0xD628,0x02);
  1855.                 LCD_WriteReg(0xD629,0xDE);
  1856.                 LCD_WriteReg(0xD62A,0x02);
  1857.                 LCD_WriteReg(0xD62B,0xF2);
  1858.                 LCD_WriteReg(0xD62C,0x02);
  1859.                 LCD_WriteReg(0xD62D,0xFE);
  1860.                 LCD_WriteReg(0xD62E,0x03);
  1861.                 LCD_WriteReg(0xD62F,0x10);
  1862.                 LCD_WriteReg(0xD630,0x03);
  1863.                 LCD_WriteReg(0xD631,0x33);
  1864.                 LCD_WriteReg(0xD632,0x03);
  1865.                 LCD_WriteReg(0xD633,0x6D);
  1866.                 //LV2 Page 0 enable
  1867.                 LCD_WriteReg(0xF000,0x55);
  1868.                 LCD_WriteReg(0xF001,0xAA);
  1869.                 LCD_WriteReg(0xF002,0x52);
  1870.                 LCD_WriteReg(0xF003,0x08);
  1871.                 LCD_WriteReg(0xF004,0x00);
  1872.                 //Display control
  1873.                 LCD_WriteReg(0xB100, 0xCC);
  1874.                 LCD_WriteReg(0xB101, 0x00);
  1875.                 //Source hold time
  1876.                 LCD_WriteReg(0xB600,0x05);
  1877.                 //Gate EQ control
  1878.                 LCD_WriteReg(0xB700,0x70);
  1879.                 LCD_WriteReg(0xB701,0x70);
  1880.                 //Source EQ control (Mode 2)
  1881.                 LCD_WriteReg(0xB800,0x01);
  1882.                 LCD_WriteReg(0xB801,0x03);
  1883.                 LCD_WriteReg(0xB802,0x03);
  1884.                 LCD_WriteReg(0xB803,0x03);
  1885.                 //Inversion mode (2-dot)
  1886.                 LCD_WriteReg(0xBC00,0x02);
  1887.                 LCD_WriteReg(0xBC01,0x00);
  1888.                 LCD_WriteReg(0xBC02,0x00);
  1889.                 //Timing control 4H w/ 4-delay
  1890.                 LCD_WriteReg(0xC900,0xD0);
  1891.                 LCD_WriteReg(0xC901,0x02);
  1892.                 LCD_WriteReg(0xC902,0x50);
  1893.                 LCD_WriteReg(0xC903,0x50);
  1894.                 LCD_WriteReg(0xC904,0x50);
  1895.                 LCD_WriteReg(0x3500,0x00);
  1896.                 LCD_WriteReg(0x3A00,0x55);  //16-bit/pixel
  1897.                 LCD_WR_REG(0x1100);
  1898.                 delay_us(120);
  1899.                 LCD_WR_REG(0x2900);
  1900.         }else if(lcddev.id==0x9325)//9325
  1901.         {
  1902.                 LCD_WriteReg(0x00E5,0x78F0);
  1903.                 LCD_WriteReg(0x0001,0x0100);
  1904.                 LCD_WriteReg(0x0002,0x0700);
  1905.                 LCD_WriteReg(0x0003,0x1030);
  1906.                 LCD_WriteReg(0x0004,0x0000);
  1907.                 LCD_WriteReg(0x0008,0x0202);  
  1908.                 LCD_WriteReg(0x0009,0x0000);
  1909.                 LCD_WriteReg(0x000A,0x0000);
  1910.                 LCD_WriteReg(0x000C,0x0000);
  1911.                 LCD_WriteReg(0x000D,0x0000);
  1912.                 LCD_WriteReg(0x000F,0x0000);
  1913.                 //power on sequence VGHVGL
  1914.                 LCD_WriteReg(0x0010,0x0000);   
  1915.                 LCD_WriteReg(0x0011,0x0007);  
  1916.                 LCD_WriteReg(0x0012,0x0000);  
  1917.                 LCD_WriteReg(0x0013,0x0000);
  1918.                 LCD_WriteReg(0x0007,0x0000);
  1919.                 //vgh
  1920.                 LCD_WriteReg(0x0010,0x1690);   
  1921.                 LCD_WriteReg(0x0011,0x0227);
  1922.                 //delayms(100);
  1923.                 //vregiout
  1924.                 LCD_WriteReg(0x0012,0x009D); //0x001b
  1925.                 //delayms(100);
  1926.                 //vom amplitude
  1927.                 LCD_WriteReg(0x0013,0x1900);
  1928.                 //delayms(100);
  1929.                 //vom H
  1930.                 LCD_WriteReg(0x0029,0x0025);
  1931.                 LCD_WriteReg(0x002B,0x000D);
  1932.                 //gamma
  1933.                 LCD_WriteReg(0x0030,0x0007);
  1934.                 LCD_WriteReg(0x0031,0x0303);
  1935.                 LCD_WriteReg(0x0032,0x0003);// 0006
  1936.                 LCD_WriteReg(0x0035,0x0206);
  1937.                 LCD_WriteReg(0x0036,0x0008);
  1938.                 LCD_WriteReg(0x0037,0x0406);
  1939.                 LCD_WriteReg(0x0038,0x0304);//0200
  1940.                 LCD_WriteReg(0x0039,0x0007);
  1941.                 LCD_WriteReg(0x003C,0x0602);// 0504
  1942.                 LCD_WriteReg(0x003D,0x0008);
  1943.                 //ram
  1944.                 LCD_WriteReg(0x0050,0x0000);
  1945.                 LCD_WriteReg(0x0051,0x00EF);
  1946.                 LCD_WriteReg(0x0052,0x0000);
  1947.                 LCD_WriteReg(0x0053,0x013F);  
  1948.                 LCD_WriteReg(0x0060,0xA700);
  1949.                 LCD_WriteReg(0x0061,0x0001);
  1950.                 LCD_WriteReg(0x006A,0x0000);
  1951.                 //
  1952.                 LCD_WriteReg(0x0080,0x0000);
  1953.                 LCD_WriteReg(0x0081,0x0000);
  1954.                 LCD_WriteReg(0x0082,0x0000);
  1955.                 LCD_WriteReg(0x0083,0x0000);
  1956.                 LCD_WriteReg(0x0084,0x0000);
  1957.                 LCD_WriteReg(0x0085,0x0000);
  1958.                 //
  1959.                 LCD_WriteReg(0x0090,0x0010);
  1960.                 LCD_WriteReg(0x0092,0x0600);
  1961.                
  1962.                 LCD_WriteReg(0x0007,0x0133);
  1963.                 LCD_WriteReg(0x00,0x0022);//
  1964.         }else if(lcddev.id==0x9328)//ILI9328   OK  
  1965.         {
  1966.                   LCD_WriteReg(0x00EC,0x108F);// internal timeing      
  1967.                 LCD_WriteReg(0x00EF,0x1234);// ADD        
  1968.                 //LCD_WriteReg(0x00e7,0x0010);      
  1969.         //LCD_WriteReg(0x0000,0x0001);//开启内部时钟
  1970.         LCD_WriteReg(0x0001,0x0100);     
  1971.         LCD_WriteReg(0x0002,0x0700);//电源开启                    
  1972.                 //LCD_WriteReg(0x0003,(1<<3)|(1<<4) );         //65K  RGB
  1973.                 //DRIVE TABLE(寄存器 03H)
  1974.                 //BIT3=AM BIT4:5=ID0:1
  1975.                 //AM ID0 ID1   FUNCATION
  1976.                 // 0  0   0           R->L D->U
  1977.                 // 1  0   0           D->U        R->L
  1978.                 // 0  1   0           L->R D->U
  1979.                 // 1  1   0    D->U        L->R
  1980.                 // 0  0   1           R->L U->D
  1981.                 // 1  0   1    U->D        R->L
  1982.                 // 0  1   1    L->R U->D 正常就用这个.
  1983.                 // 1  1   1           U->D        L->R
  1984.         LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(0<<3) );//65K   
  1985.         LCD_WriteReg(0x0004,0x0000);                                   
  1986.         LCD_WriteReg(0x0008,0x0202);                   
  1987.         LCD_WriteReg(0x0009,0x0000);         
  1988.         LCD_WriteReg(0x000a,0x0000);//display setting         
  1989.         LCD_WriteReg(0x000c,0x0001);//display setting         
  1990.         LCD_WriteReg(0x000d,0x0000);//0f3c         
  1991.         LCD_WriteReg(0x000f,0x0000);
  1992.                 //电源配置
  1993.         LCD_WriteReg(0x0010,0x0000);   
  1994.         LCD_WriteReg(0x0011,0x0007);
  1995.         LCD_WriteReg(0x0012,0x0000);                                                                 
  1996.         LCD_WriteReg(0x0013,0x0000);                 
  1997.              LCD_WriteReg(0x0007,0x0001);                 
  1998.                delay_ms(50);
  1999.         LCD_WriteReg(0x0010,0x1490);   
  2000.         LCD_WriteReg(0x0011,0x0227);
  2001.         delay_ms(50);
  2002.         LCD_WriteReg(0x0012,0x008A);                  
  2003.         delay_ms(50);
  2004.         LCD_WriteReg(0x0013,0x1a00);   
  2005.         LCD_WriteReg(0x0029,0x0006);
  2006.         LCD_WriteReg(0x002b,0x000d);
  2007.         delay_ms(50);
  2008.         LCD_WriteReg(0x0020,0x0000);                                                            
  2009.         LCD_WriteReg(0x0021,0x0000);           
  2010.                 delay_ms(50);
  2011.                 //伽马校正
  2012.         LCD_WriteReg(0x0030,0x0000);
  2013.         LCD_WriteReg(0x0031,0x0604);   
  2014.         LCD_WriteReg(0x0032,0x0305);
  2015.         LCD_WriteReg(0x0035,0x0000);
  2016.         LCD_WriteReg(0x0036,0x0C09);
  2017.         LCD_WriteReg(0x0037,0x0204);
  2018.         LCD_WriteReg(0x0038,0x0301);        
  2019.         LCD_WriteReg(0x0039,0x0707);     
  2020.         LCD_WriteReg(0x003c,0x0000);
  2021.         LCD_WriteReg(0x003d,0x0a0a);
  2022.         delay_ms(50);
  2023.         LCD_WriteReg(0x0050,0x0000); //水平GRAM起始位置
  2024.         LCD_WriteReg(0x0051,0x00ef); //水平GRAM终止位置                    
  2025.         LCD_WriteReg(0x0052,0x0000); //垂直GRAM起始位置                    
  2026.         LCD_WriteReg(0x0053,0x013f); //垂直GRAM终止位置  

  2027.          LCD_WriteReg(0x0060,0xa700);        
  2028.         LCD_WriteReg(0x0061,0x0001);
  2029.         LCD_WriteReg(0x006a,0x0000);
  2030.         LCD_WriteReg(0x0080,0x0000);
  2031.         LCD_WriteReg(0x0081,0x0000);
  2032.         LCD_WriteReg(0x0082,0x0000);
  2033.         LCD_WriteReg(0x0083,0x0000);
  2034.         LCD_WriteReg(0x0084,0x0000);
  2035.         LCD_WriteReg(0x0085,0x0000);
  2036.       
  2037.         LCD_WriteReg(0x0090,0x0010);     
  2038.         LCD_WriteReg(0x0092,0x0600);  
  2039.         //开启显示设置   
  2040.         LCD_WriteReg(0x0007,0x0133);
  2041.         }else if(lcddev.id==0x9320)//测试OK.
  2042.         {
  2043.                 LCD_WriteReg(0x00,0x0000);
  2044.                 LCD_WriteReg(0x01,0x0100);        //Driver Output Contral.
  2045.                 LCD_WriteReg(0x02,0x0700);        //LCD Driver Waveform Contral.
  2046.                 LCD_WriteReg(0x03,0x1030);//Entry Mode Set.
  2047.                 //LCD_WriteReg(0x03,0x1018);        //Entry Mode Set.
  2048.        
  2049.                 LCD_WriteReg(0x04,0x0000);        //Scalling Contral.
  2050.                 LCD_WriteReg(0x08,0x0202);        //Display Contral 2.(0x0207)
  2051.                 LCD_WriteReg(0x09,0x0000);        //Display Contral 3.(0x0000)
  2052.                 LCD_WriteReg(0x0a,0x0000);        //Frame Cycle Contal.(0x0000)
  2053.                 LCD_WriteReg(0x0c,(1<<0));        //Extern Display Interface Contral 1.(0x0000)
  2054.                 LCD_WriteReg(0x0d,0x0000);        //Frame Maker Position.
  2055.                 LCD_WriteReg(0x0f,0x0000);        //Extern Display Interface Contral 2.            
  2056.                 delay_ms(50);
  2057.                 LCD_WriteReg(0x07,0x0101);        //Display Contral.
  2058.                 delay_ms(50);                                                                   
  2059.                 LCD_WriteReg(0x10,(1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4));        //Power Control 1.(0x16b0)
  2060.                 LCD_WriteReg(0x11,0x0007);                                                                //Power Control 2.(0x0001)
  2061.                 LCD_WriteReg(0x12,(1<<8)|(1<<4)|(0<<0));                                //Power Control 3.(0x0138)
  2062.                 LCD_WriteReg(0x13,0x0b00);                                                                //Power Control 4.
  2063.                 LCD_WriteReg(0x29,0x0000);                                                                //Power Control 7.
  2064.        
  2065.                 LCD_WriteReg(0x2b,(1<<14)|(1<<4));            
  2066.                 LCD_WriteReg(0x50,0);        //Set X Star
  2067.                 //水平GRAM终止位置Set X End.
  2068.                 LCD_WriteReg(0x51,239);        //Set Y Star
  2069.                 LCD_WriteReg(0x52,0);        //Set Y End.t.
  2070.                 LCD_WriteReg(0x53,319);        //
  2071.        
  2072.                 LCD_WriteReg(0x60,0x2700);        //Driver Output Control.
  2073.                 LCD_WriteReg(0x61,0x0001);        //Driver Output Control.
  2074.                 LCD_WriteReg(0x6a,0x0000);        //Vertical Srcoll Control.
  2075.        
  2076.                 LCD_WriteReg(0x80,0x0000);        //Display Position? Partial Display 1.
  2077.                 LCD_WriteReg(0x81,0x0000);        //RAM Address Start? Partial Display 1.
  2078.                 LCD_WriteReg(0x82,0x0000);        //RAM Address End-Partial Display 1.
  2079.                 LCD_WriteReg(0x83,0x0000);        //Displsy Position? Partial Display 2.
  2080.                 LCD_WriteReg(0x84,0x0000);        //RAM Address Start? Partial Display 2.
  2081.                 LCD_WriteReg(0x85,0x0000);        //RAM Address End? Partial Display 2.
  2082.        
  2083.                 LCD_WriteReg(0x90,(0<<7)|(16<<0));        //Frame Cycle Contral.(0x0013)
  2084.                 LCD_WriteReg(0x92,0x0000);        //Panel Interface Contral 2.(0x0000)
  2085.                 LCD_WriteReg(0x93,0x0001);        //Panel Interface Contral 3.
  2086.                 LCD_WriteReg(0x95,0x0110);        //Frame Cycle Contral.(0x0110)
  2087.                 LCD_WriteReg(0x97,(0<<8));        //
  2088.                 LCD_WriteReg(0x98,0x0000);        //Frame Cycle Contral.          
  2089.                 LCD_WriteReg(0x07,0x0173);        //(0x0173)
  2090.         }else if(lcddev.id==0X9331)//OK |/|/|                         
  2091.         {
  2092.                 LCD_WriteReg(0x00E7, 0x1014);
  2093.                 LCD_WriteReg(0x0001, 0x0100); // set SS and SM bit
  2094.                 LCD_WriteReg(0x0002, 0x0200); // set 1 line inversion
  2095.         LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(1<<3));//65K   
  2096.                 //LCD_WriteReg(0x0003, 0x1030); // set GRAM write direction and BGR=1.
  2097.                 LCD_WriteReg(0x0008, 0x0202); // set the back porch and front porch
  2098.                 LCD_WriteReg(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
  2099.                 LCD_WriteReg(0x000A, 0x0000); // FMARK function
  2100.                 LCD_WriteReg(0x000C, 0x0000); // RGB interface setting
  2101.                 LCD_WriteReg(0x000D, 0x0000); // Frame marker Position
  2102.                 LCD_WriteReg(0x000F, 0x0000); // RGB interface polarity
  2103.                 //*************Power On sequence ****************//
  2104.                 LCD_WriteReg(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
  2105.                 LCD_WriteReg(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
  2106.                 LCD_WriteReg(0x0012, 0x0000); // VREG1OUT voltage
  2107.                 LCD_WriteReg(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
  2108.                 delay_ms(200); // Dis-charge capacitor power voltage
  2109.                 LCD_WriteReg(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
  2110.                 LCD_WriteReg(0x0011, 0x0227); // DC1[2:0], DC0[2:0], VC[2:0]
  2111.                 delay_ms(50); // Delay 50ms
  2112.                 LCD_WriteReg(0x0012, 0x000C); // Internal reference voltage= Vci;
  2113.                 delay_ms(50); // Delay 50ms
  2114.                 LCD_WriteReg(0x0013, 0x0800); // Set VDV[4:0] for VCOM amplitude
  2115.                 LCD_WriteReg(0x0029, 0x0011); // Set VCM[5:0] for VCOMH
  2116.                 LCD_WriteReg(0x002B, 0x000B); // Set Frame Rate
  2117.                 delay_ms(50); // Delay 50ms
  2118.                 LCD_WriteReg(0x0020, 0x0000); // GRAM horizontal Address
  2119.                 LCD_WriteReg(0x0021, 0x013f); // GRAM Vertical Address
  2120.                 // ----------- Adjust the Gamma Curve ----------//
  2121.                 LCD_WriteReg(0x0030, 0x0000);
  2122.                 LCD_WriteReg(0x0031, 0x0106);
  2123.                 LCD_WriteReg(0x0032, 0x0000);
  2124.                 LCD_WriteReg(0x0035, 0x0204);
  2125.                 LCD_WriteReg(0x0036, 0x160A);
  2126.                 LCD_WriteReg(0x0037, 0x0707);
  2127.                 LCD_WriteReg(0x0038, 0x0106);
  2128.                 LCD_WriteReg(0x0039, 0x0707);
  2129.                 LCD_WriteReg(0x003C, 0x0402);
  2130.                 LCD_WriteReg(0x003D, 0x0C0F);
  2131.                 //------------------ Set GRAM area ---------------//
  2132.                 LCD_WriteReg(0x0050, 0x0000); // Horizontal GRAM Start Address
  2133.                 LCD_WriteReg(0x0051, 0x00EF); // Horizontal GRAM End Address
  2134.                 LCD_WriteReg(0x0052, 0x0000); // Vertical GRAM Start Address
  2135.                 LCD_WriteReg(0x0053, 0x013F); // Vertical GRAM Start Address
  2136.                 LCD_WriteReg(0x0060, 0x2700); // Gate Scan Line
  2137.                 LCD_WriteReg(0x0061, 0x0001); // NDL,VLE, REV
  2138.                 LCD_WriteReg(0x006A, 0x0000); // set scrolling line
  2139.                 //-------------- Partial Display Control ---------//
  2140.                 LCD_WriteReg(0x0080, 0x0000);
  2141.                 LCD_WriteReg(0x0081, 0x0000);
  2142.                 LCD_WriteReg(0x0082, 0x0000);
  2143.                 LCD_WriteReg(0x0083, 0x0000);
  2144.                 LCD_WriteReg(0x0084, 0x0000);
  2145.                 LCD_WriteReg(0x0085, 0x0000);
  2146.                 //-------------- Panel Control -------------------//
  2147.                 LCD_WriteReg(0x0090, 0x0010);
  2148.                 LCD_WriteReg(0x0092, 0x0600);
  2149.                 LCD_WriteReg(0x0007, 0x0133); // 262K color and display ON
  2150.         }else if(lcddev.id==0x5408)
  2151.         {
  2152.                 LCD_WriteReg(0x01,0x0100);                                                                  
  2153.                 LCD_WriteReg(0x02,0x0700);//LCD Driving Waveform Contral
  2154.                 LCD_WriteReg(0x03,0x1030);//Entry Mode设置           
  2155.                 //指针从左至右自上而下的自动增模式
  2156.                 //Normal Mode(Window Mode disable)
  2157.                 //RGB格式
  2158.                 //16位数据2次传输的8总线设置
  2159.                 LCD_WriteReg(0x04,0x0000); //Scalling Control register     
  2160.                 LCD_WriteReg(0x08,0x0207); //Display Control 2
  2161.                 LCD_WriteReg(0x09,0x0000); //Display Control 3         
  2162.                 LCD_WriteReg(0x0A,0x0000); //Frame Cycle Control         
  2163.                 LCD_WriteReg(0x0C,0x0000); //External Display Interface Control 1
  2164.                 LCD_WriteReg(0x0D,0x0000); //Frame Maker Position                 
  2165.                 LCD_WriteReg(0x0F,0x0000); //External Display Interface Control 2
  2166.                 delay_ms(20);
  2167.                 //TFT 液晶彩色图像显示方法14
  2168.                 LCD_WriteReg(0x10,0x16B0); //0x14B0 //Power Control 1
  2169.                 LCD_WriteReg(0x11,0x0001); //0x0007 //Power Control 2
  2170.                 LCD_WriteReg(0x17,0x0001); //0x0000 //Power Control 3
  2171.                 LCD_WriteReg(0x12,0x0138); //0x013B //Power Control 4
  2172.                 LCD_WriteReg(0x13,0x0800); //0x0800 //Power Control 5
  2173.                 LCD_WriteReg(0x29,0x0009); //NVM read data 2
  2174.                 LCD_WriteReg(0x2a,0x0009); //NVM read data 3
  2175.                 LCD_WriteReg(0xa4,0x0000);         
  2176.                 LCD_WriteReg(0x50,0x0000); //设置操作窗口的X轴开始列
  2177.                 LCD_WriteReg(0x51,0x00EF); //设置操作窗口的X轴结束列
  2178.                 LCD_WriteReg(0x52,0x0000); //设置操作窗口的Y轴开始行
  2179.                 LCD_WriteReg(0x53,0x013F); //设置操作窗口的Y轴结束行
  2180.                 LCD_WriteReg(0x60,0x2700); //Driver Output Control
  2181.                 //设置屏幕的点数以及扫描的起始行
  2182.                 LCD_WriteReg(0x61,0x0001); //Driver Output Control
  2183.                 LCD_WriteReg(0x6A,0x0000); //Vertical Scroll Control
  2184.                 LCD_WriteReg(0x80,0x0000); //Display Position – Partial Display 1
  2185.                 LCD_WriteReg(0x81,0x0000); //RAM Address Start – Partial Display 1
  2186.                 LCD_WriteReg(0x82,0x0000); //RAM address End - Partial Display 1
  2187.                 LCD_WriteReg(0x83,0x0000); //Display Position – Partial Display 2
  2188.                 LCD_WriteReg(0x84,0x0000); //RAM Address Start – Partial Display 2
  2189.                 LCD_WriteReg(0x85,0x0000); //RAM address End – Partail Display2
  2190.                 LCD_WriteReg(0x90,0x0013); //Frame Cycle Control
  2191.                 LCD_WriteReg(0x92,0x0000);  //Panel Interface Control 2
  2192.                 LCD_WriteReg(0x93,0x0003); //Panel Interface control 3
  2193.                 LCD_WriteReg(0x95,0x0110);  //Frame Cycle Control
  2194.                 LCD_WriteReg(0x07,0x0173);                 
  2195.                 delay_ms(50);
  2196.         }       
  2197.         else if(lcddev.id==0x1505)//OK
  2198.         {
  2199.                 // second release on 3/5  ,luminance is acceptable,water wave appear during camera preview
  2200.         LCD_WriteReg(0x0007,0x0000);
  2201.         delay_ms(50);
  2202.         LCD_WriteReg(0x0012,0x011C);//0x011A   why need to set several times?
  2203.         LCD_WriteReg(0x00A4,0x0001);//NVM         
  2204.         LCD_WriteReg(0x0008,0x000F);
  2205.         LCD_WriteReg(0x000A,0x0008);
  2206.         LCD_WriteReg(0x000D,0x0008);            
  2207.                   //伽马校正
  2208.         LCD_WriteReg(0x0030,0x0707);
  2209.         LCD_WriteReg(0x0031,0x0007); //0x0707
  2210.         LCD_WriteReg(0x0032,0x0603);
  2211.         LCD_WriteReg(0x0033,0x0700);
  2212.         LCD_WriteReg(0x0034,0x0202);
  2213.         LCD_WriteReg(0x0035,0x0002); //?0x0606
  2214.         LCD_WriteReg(0x0036,0x1F0F);
  2215.         LCD_WriteReg(0x0037,0x0707); //0x0f0f  0x0105
  2216.         LCD_WriteReg(0x0038,0x0000);
  2217.         LCD_WriteReg(0x0039,0x0000);
  2218.         LCD_WriteReg(0x003A,0x0707);
  2219.         LCD_WriteReg(0x003B,0x0000); //0x0303
  2220.         LCD_WriteReg(0x003C,0x0007); //?0x0707
  2221.         LCD_WriteReg(0x003D,0x0000); //0x1313//0x1f08
  2222.         delay_ms(50);
  2223.         LCD_WriteReg(0x0007,0x0001);
  2224.         LCD_WriteReg(0x0017,0x0001);//开启电源
  2225.         delay_ms(50);
  2226.                   //电源配置
  2227.         LCD_WriteReg(0x0010,0x17A0);
  2228.         LCD_WriteReg(0x0011,0x0217);//reference voltage VC[2:0]   Vciout = 1.00*Vcivl
  2229.         LCD_WriteReg(0x0012,0x011E);//0x011c  //Vreg1out = Vcilvl*1.80   is it the same as Vgama1out ?
  2230.         LCD_WriteReg(0x0013,0x0F00);//VDV[4:0]-->VCOM Amplitude VcomL = VcomH - Vcom Ampl
  2231.         LCD_WriteReg(0x002A,0x0000);  
  2232.         LCD_WriteReg(0x0029,0x000A);//0x0001F  Vcomh = VCM1[4:0]*Vreg1out    gate source voltage??
  2233.         LCD_WriteReg(0x0012,0x013E);// 0x013C  power supply on
  2234.         //Coordinates Control//
  2235.         LCD_WriteReg(0x0050,0x0000);//0x0e00
  2236.         LCD_WriteReg(0x0051,0x00EF);
  2237.         LCD_WriteReg(0x0052,0x0000);
  2238.         LCD_WriteReg(0x0053,0x013F);
  2239.             //Pannel Image Control//
  2240.         LCD_WriteReg(0x0060,0x2700);
  2241.         LCD_WriteReg(0x0061,0x0001);
  2242.         LCD_WriteReg(0x006A,0x0000);
  2243.         LCD_WriteReg(0x0080,0x0000);
  2244.             //Partial Image Control//
  2245.         LCD_WriteReg(0x0081,0x0000);
  2246.         LCD_WriteReg(0x0082,0x0000);
  2247.         LCD_WriteReg(0x0083,0x0000);
  2248.         LCD_WriteReg(0x0084,0x0000);
  2249.         LCD_WriteReg(0x0085,0x0000);
  2250.                   //Panel Interface Control//
  2251.         LCD_WriteReg(0x0090,0x0013);//0x0010 frenqucy
  2252.         LCD_WriteReg(0x0092,0x0300);
  2253.         LCD_WriteReg(0x0093,0x0005);
  2254.         LCD_WriteReg(0x0095,0x0000);
  2255.         LCD_WriteReg(0x0097,0x0000);
  2256.         LCD_WriteReg(0x0098,0x0000);
  2257.   
  2258.         LCD_WriteReg(0x0001,0x0100);
  2259.         LCD_WriteReg(0x0002,0x0700);
  2260.         LCD_WriteReg(0x0003,0x1038);//扫描方向 上->下  左->右
  2261.         LCD_WriteReg(0x0004,0x0000);
  2262.         LCD_WriteReg(0x000C,0x0000);
  2263.         LCD_WriteReg(0x000F,0x0000);
  2264.         LCD_WriteReg(0x0020,0x0000);
  2265.         LCD_WriteReg(0x0021,0x0000);
  2266.         LCD_WriteReg(0x0007,0x0021);
  2267.         delay_ms(20);
  2268.         LCD_WriteReg(0x0007,0x0061);
  2269.         delay_ms(20);
  2270.         LCD_WriteReg(0x0007,0x0173);
  2271.         delay_ms(20);
  2272.         }else if(lcddev.id==0xB505)
  2273.         {
  2274.                 LCD_WriteReg(0x0000,0x0000);
  2275.                 LCD_WriteReg(0x0000,0x0000);
  2276.                 LCD_WriteReg(0x0000,0x0000);
  2277.                 LCD_WriteReg(0x0000,0x0000);
  2278.                
  2279.                 LCD_WriteReg(0x00a4,0x0001);
  2280.                 delay_ms(20);                  
  2281.                 LCD_WriteReg(0x0060,0x2700);
  2282.                 LCD_WriteReg(0x0008,0x0202);
  2283.                
  2284.                 LCD_WriteReg(0x0030,0x0214);
  2285.                 LCD_WriteReg(0x0031,0x3715);
  2286.                 LCD_WriteReg(0x0032,0x0604);
  2287.                 LCD_WriteReg(0x0033,0x0e16);
  2288.                 LCD_WriteReg(0x0034,0x2211);
  2289.                 LCD_WriteReg(0x0035,0x1500);
  2290.                 LCD_WriteReg(0x0036,0x8507);
  2291.                 LCD_WriteReg(0x0037,0x1407);
  2292.                 LCD_WriteReg(0x0038,0x1403);
  2293.                 LCD_WriteReg(0x0039,0x0020);
  2294.                
  2295.                 LCD_WriteReg(0x0090,0x001a);
  2296.                 LCD_WriteReg(0x0010,0x0000);
  2297.                 LCD_WriteReg(0x0011,0x0007);
  2298.                 LCD_WriteReg(0x0012,0x0000);
  2299.                 LCD_WriteReg(0x0013,0x0000);
  2300.                 delay_ms(20);
  2301.                
  2302.                 LCD_WriteReg(0x0010,0x0730);
  2303.                 LCD_WriteReg(0x0011,0x0137);
  2304.                 delay_ms(20);
  2305.                
  2306.                 LCD_WriteReg(0x0012,0x01b8);
  2307.                 delay_ms(20);
  2308.                
  2309.                 LCD_WriteReg(0x0013,0x0f00);
  2310.                 LCD_WriteReg(0x002a,0x0080);
  2311.                 LCD_WriteReg(0x0029,0x0048);
  2312.                 delay_ms(20);
  2313.                
  2314.                 LCD_WriteReg(0x0001,0x0100);
  2315.                 LCD_WriteReg(0x0002,0x0700);
  2316.         LCD_WriteReg(0x0003,0x1038);//扫描方向 上->下  左->右
  2317.                 LCD_WriteReg(0x0008,0x0202);
  2318.                 LCD_WriteReg(0x000a,0x0000);
  2319.                 LCD_WriteReg(0x000c,0x0000);
  2320.                 LCD_WriteReg(0x000d,0x0000);
  2321.                 LCD_WriteReg(0x000e,0x0030);
  2322.                 LCD_WriteReg(0x0050,0x0000);
  2323.                 LCD_WriteReg(0x0051,0x00ef);
  2324.                 LCD_WriteReg(0x0052,0x0000);
  2325.                 LCD_WriteReg(0x0053,0x013f);
  2326.                 LCD_WriteReg(0x0060,0x2700);
  2327.                 LCD_WriteReg(0x0061,0x0001);
  2328.                 LCD_WriteReg(0x006a,0x0000);
  2329.                 //LCD_WriteReg(0x0080,0x0000);
  2330.                 //LCD_WriteReg(0x0081,0x0000);
  2331.                 LCD_WriteReg(0x0090,0X0011);
  2332.                 LCD_WriteReg(0x0092,0x0600);
  2333.                 LCD_WriteReg(0x0093,0x0402);
  2334.                 LCD_WriteReg(0x0094,0x0002);
  2335.                 delay_ms(20);
  2336.                
  2337.                 LCD_WriteReg(0x0007,0x0001);
  2338.                 delay_ms(20);
  2339.                 LCD_WriteReg(0x0007,0x0061);
  2340.                 LCD_WriteReg(0x0007,0x0173);
  2341.                
  2342.                 LCD_WriteReg(0x0020,0x0000);
  2343.                 LCD_WriteReg(0x0021,0x0000);          
  2344.                 LCD_WriteReg(0x00,0x22);  
  2345.         }else if(lcddev.id==0xC505)
  2346.         {
  2347.                 LCD_WriteReg(0x0000,0x0000);
  2348.                 LCD_WriteReg(0x0000,0x0000);
  2349.                 delay_ms(20);                  
  2350.                 LCD_WriteReg(0x0000,0x0000);
  2351.                 LCD_WriteReg(0x0000,0x0000);
  2352.                 LCD_WriteReg(0x0000,0x0000);
  2353.                 LCD_WriteReg(0x0000,0x0000);
  2354.                 LCD_WriteReg(0x00a4,0x0001);
  2355.                 delay_ms(20);                  
  2356.                 LCD_WriteReg(0x0060,0x2700);
  2357.                 LCD_WriteReg(0x0008,0x0806);
  2358.                
  2359.                 LCD_WriteReg(0x0030,0x0703);//gamma setting
  2360.                 LCD_WriteReg(0x0031,0x0001);
  2361.                 LCD_WriteReg(0x0032,0x0004);
  2362.                 LCD_WriteReg(0x0033,0x0102);
  2363.                 LCD_WriteReg(0x0034,0x0300);
  2364.                 LCD_WriteReg(0x0035,0x0103);
  2365.                 LCD_WriteReg(0x0036,0x001F);
  2366.                 LCD_WriteReg(0x0037,0x0703);
  2367.                 LCD_WriteReg(0x0038,0x0001);
  2368.                 LCD_WriteReg(0x0039,0x0004);
  2369.                
  2370.                
  2371.                
  2372.                 LCD_WriteReg(0x0090, 0x0015);        //80Hz
  2373.                 LCD_WriteReg(0x0010, 0X0410);        //BT,AP
  2374.                 LCD_WriteReg(0x0011,0x0247);        //DC1,DC0,VC
  2375.                 LCD_WriteReg(0x0012, 0x01BC);
  2376.                 LCD_WriteReg(0x0013, 0x0e00);
  2377.                 delay_ms(120);
  2378.                 LCD_WriteReg(0x0001, 0x0100);
  2379.                 LCD_WriteReg(0x0002, 0x0200);
  2380.                 LCD_WriteReg(0x0003, 0x1030);
  2381.                
  2382.                 LCD_WriteReg(0x000A, 0x0008);
  2383.                 LCD_WriteReg(0x000C, 0x0000);
  2384.                
  2385.                 LCD_WriteReg(0x000E, 0x0020);
  2386.                 LCD_WriteReg(0x000F, 0x0000);
  2387.                 LCD_WriteReg(0x0020, 0x0000);        //H Start
  2388.                 LCD_WriteReg(0x0021, 0x0000);        //V Start
  2389.                 LCD_WriteReg(0x002A,0x003D);        //vcom2
  2390.                 delay_ms(20);
  2391.                 LCD_WriteReg(0x0029, 0x002d);
  2392.                 LCD_WriteReg(0x0050, 0x0000);
  2393.                 LCD_WriteReg(0x0051, 0xD0EF);
  2394.                 LCD_WriteReg(0x0052, 0x0000);
  2395.                 LCD_WriteReg(0x0053, 0x013F);
  2396.                 LCD_WriteReg(0x0061, 0x0000);
  2397.                 LCD_WriteReg(0x006A, 0x0000);
  2398.                 LCD_WriteReg(0x0092,0x0300);

  2399.                 LCD_WriteReg(0x0093, 0x0005);
  2400.                 LCD_WriteReg(0x0007, 0x0100);
  2401.         }else if(lcddev.id==0x4531)//OK |/|/|
  2402.         {
  2403.                 LCD_WriteReg(0X00,0X0001);   
  2404.                 delay_ms(10);   
  2405.                 LCD_WriteReg(0X10,0X1628);   
  2406.                 LCD_WriteReg(0X12,0X000e);//0x0006   
  2407.                 LCD_WriteReg(0X13,0X0A39);   
  2408.                 delay_ms(10);   
  2409.                 LCD_WriteReg(0X11,0X0040);   
  2410.                 LCD_WriteReg(0X15,0X0050);   
  2411.                 delay_ms(10);   
  2412.                 LCD_WriteReg(0X12,0X001e);//16   
  2413.                 delay_ms(10);   
  2414.                 LCD_WriteReg(0X10,0X1620);   
  2415.                 LCD_WriteReg(0X13,0X2A39);   
  2416.                 delay_ms(10);   
  2417.                 LCD_WriteReg(0X01,0X0100);   
  2418.                 LCD_WriteReg(0X02,0X0300);   
  2419.                 LCD_WriteReg(0X03,0X1038);//改变方向的   
  2420.                 LCD_WriteReg(0X08,0X0202);   
  2421.                 LCD_WriteReg(0X0A,0X0008);   
  2422.                 LCD_WriteReg(0X30,0X0000);   
  2423.                 LCD_WriteReg(0X31,0X0402);   
  2424.                 LCD_WriteReg(0X32,0X0106);   
  2425.                 LCD_WriteReg(0X33,0X0503);   
  2426.                 LCD_WriteReg(0X34,0X0104);   
  2427.                 LCD_WriteReg(0X35,0X0301);   
  2428.                 LCD_WriteReg(0X36,0X0707);   
  2429.                 LCD_WriteReg(0X37,0X0305);   
  2430.                 LCD_WriteReg(0X38,0X0208);   
  2431.                 LCD_WriteReg(0X39,0X0F0B);   
  2432.                 LCD_WriteReg(0X41,0X0002);   
  2433.                 LCD_WriteReg(0X60,0X2700);   
  2434.                 LCD_WriteReg(0X61,0X0001);   
  2435.                 LCD_WriteReg(0X90,0X0210);   
  2436.                 LCD_WriteReg(0X92,0X010A);   
  2437.                 LCD_WriteReg(0X93,0X0004);   
  2438.                 LCD_WriteReg(0XA0,0X0100);   
  2439.                 LCD_WriteReg(0X07,0X0001);   
  2440.                 LCD_WriteReg(0X07,0X0021);   
  2441.                 LCD_WriteReg(0X07,0X0023);   
  2442.                 LCD_WriteReg(0X07,0X0033);   
  2443.                 LCD_WriteReg(0X07,0X0133);   
  2444.                 LCD_WriteReg(0XA0,0X0000);
  2445.         }else if(lcddev.id==0x4535)
  2446.         {                             
  2447.                 LCD_WriteReg(0X15,0X0030);   
  2448.                 LCD_WriteReg(0X9A,0X0010);   
  2449.                 LCD_WriteReg(0X11,0X0020);   
  2450.                 LCD_WriteReg(0X10,0X3428);   
  2451.                 LCD_WriteReg(0X12,0X0002);//16   
  2452.                 LCD_WriteReg(0X13,0X1038);   
  2453.                 delay_ms(40);   
  2454.                 LCD_WriteReg(0X12,0X0012);//16   
  2455.                 delay_ms(40);   
  2456.                   LCD_WriteReg(0X10,0X3420);   
  2457.                 LCD_WriteReg(0X13,0X3038);   
  2458.                 delay_ms(70);   
  2459.                 LCD_WriteReg(0X30,0X0000);   
  2460.                 LCD_WriteReg(0X31,0X0402);   
  2461.                 LCD_WriteReg(0X32,0X0307);   
  2462.                 LCD_WriteReg(0X33,0X0304);   
  2463.                 LCD_WriteReg(0X34,0X0004);   
  2464.                 LCD_WriteReg(0X35,0X0401);   
  2465.                 LCD_WriteReg(0X36,0X0707);   
  2466.                 LCD_WriteReg(0X37,0X0305);   
  2467.                 LCD_WriteReg(0X38,0X0610);   
  2468.                 LCD_WriteReg(0X39,0X0610);
  2469.                   
  2470.                 LCD_WriteReg(0X01,0X0100);   
  2471.                 LCD_WriteReg(0X02,0X0300);   
  2472.                 LCD_WriteReg(0X03,0X1030);//改变方向的   
  2473.                 LCD_WriteReg(0X08,0X0808);   
  2474.                 LCD_WriteReg(0X0A,0X0008);   
  2475.                 LCD_WriteReg(0X60,0X2700);   
  2476.                 LCD_WriteReg(0X61,0X0001);   
  2477.                 LCD_WriteReg(0X90,0X013E);   
  2478.                 LCD_WriteReg(0X92,0X0100);   
  2479.                 LCD_WriteReg(0X93,0X0100);   
  2480.                 LCD_WriteReg(0XA0,0X3000);   
  2481.                 LCD_WriteReg(0XA3,0X0010);   
  2482.                 LCD_WriteReg(0X07,0X0001);   
  2483.                 LCD_WriteReg(0X07,0X0021);   
  2484.                 LCD_WriteReg(0X07,0X0023);   
  2485.                 LCD_WriteReg(0X07,0X0033);   
  2486.                 LCD_WriteReg(0X07,0X0133);   
  2487.         }else if(lcddev.id==0X1963)
  2488.         {
  2489.                 LCD_WR_REG(0xE2);                //Set PLL with OSC = 10MHz (hardware),        Multiplier N = 35, 250MHz < VCO < 800MHz = OSC*(N+1), VCO = 300MHz
  2490.                 LCD_WR_DATA(0x1D);                //参数1
  2491.                 LCD_WR_DATA(0x02);                //参数2 Divider M = 2, PLL = 300/(M+1) = 100MHz
  2492.                 LCD_WR_DATA(0x04);                //参数3 Validate M and N values   
  2493.                 delay_us(100);
  2494.                 LCD_WR_REG(0xE0);                // Start PLL command
  2495.                 LCD_WR_DATA(0x01);                // enable PLL
  2496.                 delay_ms(10);
  2497.                 LCD_WR_REG(0xE0);                // Start PLL command again
  2498.                 LCD_WR_DATA(0x03);                // now, use PLL output as system clock       
  2499.                 delay_ms(12);  
  2500.                 LCD_WR_REG(0x01);                //软复位
  2501.                 delay_ms(10);
  2502.                
  2503.                 LCD_WR_REG(0xE6);                //设置像素频率,33Mhz
  2504.                 LCD_WR_DATA(0x2F);
  2505.                 LCD_WR_DATA(0xFF);
  2506.                 LCD_WR_DATA(0xFF);
  2507.                
  2508.                 LCD_WR_REG(0xB0);                //设置LCD模式
  2509.                 LCD_WR_DATA(0x20);                //24位模式
  2510.                 LCD_WR_DATA(0x00);                //TFT 模式
  2511.        
  2512.                 LCD_WR_DATA((SSD_HOR_RESOLUTION-1)>>8);//设置LCD水平像素
  2513.                 LCD_WR_DATA(SSD_HOR_RESOLUTION-1);                 
  2514.                 LCD_WR_DATA((SSD_VER_RESOLUTION-1)>>8);//设置LCD垂直像素
  2515.                 LCD_WR_DATA(SSD_VER_RESOLUTION-1);                 
  2516.                 LCD_WR_DATA(0x00);                //RGB序列
  2517.                
  2518.                 LCD_WR_REG(0xB4);                //Set horizontal period
  2519.                 LCD_WR_DATA((SSD_HT-1)>>8);
  2520.                 LCD_WR_DATA(SSD_HT-1);
  2521.                 LCD_WR_DATA(SSD_HPS>>8);
  2522.                 LCD_WR_DATA(SSD_HPS);
  2523.                 LCD_WR_DATA(SSD_HOR_PULSE_WIDTH-1);
  2524.                 LCD_WR_DATA(0x00);
  2525.                 LCD_WR_DATA(0x00);
  2526.                 LCD_WR_DATA(0x00);
  2527.                 LCD_WR_REG(0xB6);                //Set vertical period
  2528.                 LCD_WR_DATA((SSD_VT-1)>>8);
  2529.                 LCD_WR_DATA(SSD_VT-1);
  2530.                 LCD_WR_DATA(SSD_VPS>>8);
  2531.                 LCD_WR_DATA(SSD_VPS);
  2532.                 LCD_WR_DATA(SSD_VER_FRONT_PORCH-1);
  2533.                 LCD_WR_DATA(0x00);
  2534. ……………………

  2535. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码



评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏3 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:292759 发表于 2019-11-29 17:49 | 只看该作者
下载了 学习下
回复

使用道具 举报

板凳
ID:724263 发表于 2020-4-8 16:57 | 只看该作者
很完整,谢谢。
回复

使用道具 举报

地板
ID:726062 发表于 2020-4-14 20:13 | 只看该作者
请问资料里面包括仿真图吗?
回复

使用道具 举报

5#
ID:756782 发表于 2020-5-21 19:15 | 只看该作者
感谢楼主的分享
回复

使用道具 举报

6#
ID:757689 发表于 2020-5-21 19:30 | 只看该作者

感谢楼主的分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表