Chinaunix首页 | 论坛 | 博客
  • 博客访问: 312879
  • 博文数量: 169
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 12
  • 用 户 组: 普通用户
  • 注册时间: 2013-07-10 12:00
文章分类

全部博文(169)

文章存档

2014年(38)

2013年(131)

我的朋友

分类: C/C++

2014-02-24 22:07:36

/****************************************Copyright (c)**************************************************                         
**
**                                 http://www.powermcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: GLCD.c
** Descriptions: 已测试通过SSD1289、ILI9320、R61505U、SSD1298、ST7781、SPFD5408B、ILI9325、ILI9328
**
**------------------------------------------------------------------------------------------------------
** Created by: AVRman
** Created date: 2011-3-29
** Version: 2.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
********************************************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "GLCD.h" 
#include "HzLib.h"
#include "AsciiLib.h"
//#include
#include
#include


/* Private variables ---------------------------------------------------------*/
static uint8_t LCD_Code;//无符号8位的数据

/* Private define ------------------------------------------------------------*/
#define  ILI9320    0  /* 0x9320 */
#define  ILI9325    1  /* 0x9325 */
#define  ILI9328    2  /* 0x9328 */
#define  ILI9331    3  /* 0x9331 */
#define  SSD1298    4  /* 0x8999 */
#define  SSD1289    5  /* 0x8989 */
#define  ST7781     6  /* 0x7783 */
#define  LGDP4531   7  /* 0x4531 */
#define  SPFD5408B  8  /* 0x5408 */
#define  R61505U    9  /* 0x1505 0x0505 */   
#define  HX8347D    10 /* 0x0047 */
#define  HX8347A    11 /* 0x0047 */
#define  LGDP4535   12 /* 0x4535 */  
#define  SSD2119    13 /* 3.5 LCD 0x9919 */


/*******************************************************************************
* Function Name  : Lcd_Configuration
* Description    : Configures LCD Control lines
* Input          : None
* Output         : None
* Return         : None
* Attention : None
*******************************************************************************/
static void LCD_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOD and GPIOE clocks */
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE);  
                   
/* PE.00(D0), PE.01(D1), PE.02(D2), PE.03(D3), PE.04(D4), PE.05(D5), PE.06(D6), PE.07(D7), PE.08(D8)
PE.09(D9), PE.10(D10), PE.11(D11), PE.12(D12), PE.13(D13), PE.14(D14), PE.15(D15)   */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* PD.13(RS), PD.14(WR), PD.15(RD) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* PD.12(CS)*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
}

/*******************************************************************************
* Function Name  : LCD_WriteReg
* Description    : LCD控制器寄存器地址
* Input          : - index: 寄存器地址
* Output         : None
* Return         : None
* Attention : None
*******************************************************************************/
__inline void LCD_WriteIndex(uint16_t index)   //向其中写命令
{
Clr_Rs;
Set_nRd;
GPIOE->ODR = index; /* GPIO_Write(GPIOE,index); */
Clr_nWr;
Set_nWr;
}

/*******************************************************************************
* Function Name  : LCD_WriteReg
* Description    : LCD寄存器数据
* Input          : - index: 寄存器数据
* Output         : None
* Return         : None
* Attention : None
*******************************************************************************/
__inline void LCD_WriteData(uint16_t data)//向其中写数据
{
Set_Rs;
GPIOE->ODR = data; /* GPIO_Write(GPIOE,data); */
Clr_nWr;
Set_nWr;
}

/*******************************************************************************
* Function Name  : LCD_ReadData
* Description    : 读取控制器数据
* Input          : None
* Output         : None
* Return         : 返回读取到的数据
* Attention : None
*******************************************************************************/
__inline uint16_t LCD_ReadData(void)//从液晶中国读取一条数据
uint16_t value;

Set_Rs;
Set_nWr;
Clr_nRd;

/* 
    PE.00(D0), PE.01(D1), PE.02(D2), PE.03(D3), PE.04(D4), PE.05(D5), PE.06(D6), PE.07(D7), PE.08(D8)
    PE.09(D9), PE.10(D10), PE.11(D11), PE.12(D12), PE.13(D13), PE.14(D14), PE.15(D15)   */
/* 
    GPIO_InitTypeDef GPIO_InitStructure; 
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOE, &GPIO_InitStructure);
*/
GPIOE->CRH = 0x44444444;
GPIOE->CRL = 0x44444444;
/*
    value = GPIO_ReadInputData(GPIOE);
    value = GPIO_ReadInputData(GPIOE);
*/
    value = GPIOE->IDR;
    value = GPIOE->IDR;

/*  
    PE.00(D0), PE.01(D1), PE.02(D2), PE.03(D3), PE.04(D4), PE.05(D5), PE.06(D6), PE.07(D7), PE.08(D8)
    PE.09(D9), PE.10(D10), PE.11(D11), PE.12(D12), PE.13(D13), PE.14(D14), PE.15(D15)   */
/*
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOE, &GPIO_InitStructure);
*/
    GPIOE->CRH = 0x33333333;
    GPIOE->CRL = 0x33333333;

    Set_nRd;

    return value;
}


/*******************************************************************************
* Function Name  : LCD_WriteReg
* Description    : Writes to the selected LCD register.
* Input          : - LCD_Reg: address of the selected register.
*                  - LCD_RegValue: value to write to the selected register.
* Output         : None
* Return         : None
* Attention : None
*******************************************************************************/
__inline void LCD_WriteReg(uint16_t LCD_Reg,uint16_t LCD_RegValue)//向液晶中写数据
/* Write 16-bit Index, then Write Reg */  
Clr_Cs;
LCD_WriteIndex(LCD_Reg);         
/* Write 16-bit Reg */
LCD_WriteData(LCD_RegValue);  
Set_Cs; 
}

/*******************************************************************************
* Function Name  : LCD_WriteReg
* Description    : Reads the selected LCD Register.
* Input          : None
* Output         : None
* Return         : LCD Register Value.
* Attention : None
*******************************************************************************/
__inline uint16_t LCD_ReadReg(uint16_t LCD_Reg)//从液晶中读数据
{
uint16_t LCD_RAM;
/* Write 16-bit Index (then Read Reg) */
Clr_Cs;
LCD_WriteIndex(LCD_Reg);
/* Read 16-bit Reg */
LCD_RAM = LCD_ReadData();      
Set_Cs;
return LCD_RAM;
}

/*******************************************************************************
* Function Name  : LCD_SetCursor
* Description    : Sets the cursor position.
* Input          : - Xpos: specifies the X position.
*                  - Ypos: specifies the Y position. 
* Output         : None
* Return         : None
* Attention : None
*******************************************************************************/
static void LCD_SetCursor( uint16_t Xpos, uint16_t Ypos ) //对不同的型号进行数据初始化
{
    #if  ( DISP_ORIENTATION == 90 ) || ( DISP_ORIENTATION == 270 )
  uint16_t temp = Xpos;

Xpos = Ypos;
Ypos = ( MAX_X - 1 ) - temp;  

#elif  ( DISP_ORIENTATION == 0 ) || ( DISP_ORIENTATION == 180 )
#endif

  switch( LCD_Code )  //ILI9325这是从屏幕上读取的产品特征
  {
     default: /* 0x9320 0x9325 0x9328 0x9331 0x5408 0x1505 0x0505 0x7783 0x4531 0x4535 */
          LCD_WriteReg(0x0020, Xpos );     
          LCD_WriteReg(0x0021, Ypos );     
     break; 

     case SSD1298: /* 0x8999 */
     case SSD1289:   /* 0x8989 */
     LCD_WriteReg(0x004e, Xpos );      
          LCD_WriteReg(0x004f, Ypos );          
     break;  

     case HX8347A: /* 0x0047 */
     case HX8347D: /* 0x0047 */
     LCD_WriteReg(0x02, Xpos>>8 );                                                  
     LCD_WriteReg(0x03, Xpos );  

     LCD_WriteReg(0x06, Ypos>>8 );                           
     LCD_WriteReg(0x07, Ypos );    
     break;     
     case SSD2119: /* 3.5 LCD 0x9919 */
     break; 
  }
}

/*******************************************************************************
* Function Name  : LCD_Delay
* Description    : Delay Time
* Input          : - nCount: Delay Time
* Output         : None
* Return         : None
* Return         : None
* Attention : None
*******************************************************************************/
static void delay_ms(uint16_t ms)    
uint16_t i,j; 
for( i = 0; i < ms; i )
for( j = 0; j < 1141; j );
}

/*******************************************************************************
* Function Name  : LCD_Initializtion
* Description    : Initialize TFT Controller.
* Input          : None
* Output         : None
* Return         : None
* Attention : None
*******************************************************************************/
void LCD_Initializtion(void) //lcd初始化
{
uint16_t DeviceCode;
LCD_Configuration();  //lcd管教初始化
DeviceCode = LCD_ReadReg(0x0000); /* 读取屏ID */
/* 不同屏驱动IC 初始化不同 */
if( DeviceCode == 0x9325 || DeviceCode == 0x9328 )
{
LCD_Code = ILI9325;
LCD_WriteReg(0x00e7,0x0010);   //命令和数据(前面是命令后面是数据)     
LCD_WriteReg(0x0000,0x0001);   /* start internal osc *///使能液晶使其起振
LCD_WriteReg(0x0001,0x0100);     
LCD_WriteReg(0x0002,0x0700); /* power on sequence */
LCD_WriteReg(0x0003,(1<<12)|(1<<5)|(1<<4)|(0<<3) ); /* importance */
LCD_WriteReg(0x0004,0x0000);                                   
LCD_WriteReg(0x0008,0x0207);           
LCD_WriteReg(0x0009,0x0000);         
LCD_WriteReg(0x000a,0x0000); /* display setting */        
LCD_WriteReg(0x000c,0x0001); /* display setting */        
LCD_WriteReg(0x000d,0x0000);        
LCD_WriteReg(0x000f,0x0000);
/* Power On sequence */
LCD_WriteReg(0x0010,0x0000);   
LCD_WriteReg(0x0011,0x0007);
LCD_WriteReg(0x0012,0x0000);                                                                 
LCD_WriteReg(0x0013,0x0000);                 
delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0010,0x1590);   
LCD_WriteReg(0x0011,0x0227);
delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0012,0x009c);                  
delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0013,0x1900);   
LCD_WriteReg(0x0029,0x0023);
LCD_WriteReg(0x002b,0x000e);
delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0020,0x0000);                                                            
LCD_WriteReg(0x0021,0x0000);           
delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0030,0x0007); 
LCD_WriteReg(0x0031,0x0707);   
LCD_WriteReg(0x0032,0x0006);
LCD_WriteReg(0x0035,0x0704);
LCD_WriteReg(0x0036,0x1f04); 
LCD_WriteReg(0x0037,0x0004);
LCD_WriteReg(0x0038,0x0000);        
LCD_WriteReg(0x0039,0x0706);     
LCD_WriteReg(0x003c,0x0701);
LCD_WriteReg(0x003d,0x000f);
delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0050,0x0000);        
LCD_WriteReg(0x0051,0x00ef);   
LCD_WriteReg(0x0052,0x0000);     
LCD_WriteReg(0x0053,0x013f);
LCD_WriteReg(0x0060,0xa700);        
LCD_WriteReg(0x0061,0x0001); 
LCD_WriteReg(0x006a,0x0000);
LCD_WriteReg(0x0080,0x0000);
LCD_WriteReg(0x0081,0x0000);
LCD_WriteReg(0x0082,0x0000);
LCD_WriteReg(0x0083,0x0000);
LCD_WriteReg(0x0084,0x0000);
LCD_WriteReg(0x0085,0x0000);
 
LCD_WriteReg(0x0090,0x0010);     
LCD_WriteReg(0x0092,0x0000);  
LCD_WriteReg(0x0093,0x0003);
LCD_WriteReg(0x0095,0x0110);
LCD_WriteReg(0x0097,0x0000);        
LCD_WriteReg(0x0098,0x0000);  
/* display on sequence */    
LCD_WriteReg(0x0007,0x0133);
LCD_WriteReg(0x0020,0x0000);  /* 行首址0 */                                                          
LCD_WriteReg(0x0021,0x0000);  /* 列首址0 */     
}
else if( DeviceCode == 0x9320 || DeviceCode == 0x9300 )
{
   LCD_Code = ILI9320;
   LCD_WriteReg(0x00,0x0000);
LCD_WriteReg(0x01,0x0100); /* Driver Output Contral */
LCD_WriteReg(0x02,0x0700); /* LCD Driver Waveform Contral */
LCD_WriteReg(0x03,0x1018); /* Entry Mode Set */
LCD_WriteReg(0x04,0x0000); /* Scalling Contral */
   LCD_WriteReg(0x08,0x0202); /* Display Contral */
LCD_WriteReg(0x09,0x0000); /* Display Contral 3.(0x0000) */
LCD_WriteReg(0x0a,0x0000); /* Frame Cycle Contal.(0x0000) */
   LCD_WriteReg(0x0c,(1<<0)); /* Extern Display Interface Contral */
LCD_WriteReg(0x0d,0x0000); /* Frame Maker Position */
LCD_WriteReg(0x0f,0x0000); /* Extern Display Interface Contral 2. */
   delay_ms(100);  /* delay 100 ms */
LCD_WriteReg(0x07,0x0101); /* Display Contral */
   delay_ms(100);  /* delay 100 ms */
LCD_WriteReg(0x10,(1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4)); /* Power Control 1.(0x16b0) */
LCD_WriteReg(0x11,0x0007); /* Power Control 2 */
LCD_WriteReg(0x12,(1<<8)|(1<<4)|(0<<0)); /* Power Control 3.(0x0138) */
LCD_WriteReg(0x13,0x0b00); /* Power Control 4 */
LCD_WriteReg(0x29,0x0000); /* Power Control 7 */
LCD_WriteReg(0x2b,(1<<14)|(1<<4));
LCD_WriteReg(0x50,0);       /* Set X Start */
LCD_WriteReg(0x51,239);    /* Set X End */
LCD_WriteReg(0x52,0);    /* Set Y Start */
LCD_WriteReg(0x53,319);    /* Set Y End */
LCD_WriteReg(0x60,0x2700); /* Driver Output Control */
LCD_WriteReg(0x61,0x0001); /* Driver Output Control */
LCD_WriteReg(0x6a,0x0000); /* Vertical Srcoll Control */
LCD_WriteReg(0x80,0x0000); /* Display Position? Partial Display 1 */
LCD_WriteReg(0x81,0x0000); /* RAM Address Start? Partial Display 1 */
LCD_WriteReg(0x82,0x0000); /* RAM Address End-Partial Display 1 */
LCD_WriteReg(0x83,0x0000); /* Displsy Position? Partial Display 2 */
LCD_WriteReg(0x84,0x0000); /* RAM Address Start? Partial Display 2 */
LCD_WriteReg(0x85,0x0000); /* RAM Address End? Partial Display 2 */
   LCD_WriteReg(0x90,(0<<7)|(16<<0)); /* Frame Cycle Contral.(0x0013) */
LCD_WriteReg(0x92,0x0000); /* Panel Interface Contral 2.(0x0000) */
LCD_WriteReg(0x93,0x0001); /* Panel Interface Contral 3. */
   LCD_WriteReg(0x95,0x0110); /* Frame Cycle Contral.(0x0110) */
LCD_WriteReg(0x97,(0<<8));
LCD_WriteReg(0x98,0x0000); /* Frame Cycle Contral */
   LCD_WriteReg(0x07,0x0173);
}
else if( DeviceCode == 0x9331 )
{
   LCD_Code = ILI9331;
LCD_WriteReg(0x00E7, 0x1014);
LCD_WriteReg(0x0001, 0x0100);   /* set SS and SM bit */
LCD_WriteReg(0x0002, 0x0200);   /* set 1 line inversion */
LCD_WriteReg(0x0003, 0x1030);   /* set GRAM write direction and BGR=1 */
LCD_WriteReg(0x0008, 0x0202);   /* set the back porch and front porch */
   LCD_WriteReg(0x0009, 0x0000);   /* set non-display area refresh cycle ISC[3:0] */
LCD_WriteReg(0x000A, 0x0000);   /* FMARK function */
LCD_WriteReg(0x000C, 0x0000);   /* RGB interface setting */
LCD_WriteReg(0x000D, 0x0000);   /* Frame marker Position */
LCD_WriteReg(0x000F, 0x0000);   /* RGB interface polarity */
/* Power On sequence */
LCD_WriteReg(0x0010, 0x0000);   /* SAP, BT[3:0], AP, DSTB, SLP, STB */
LCD_WriteReg(0x0011, 0x0007);   /* DC1[2:0], DC0[2:0], VC[2:0] */
LCD_WriteReg(0x0012, 0x0000);   /* VREG1OUT voltage */
LCD_WriteReg(0x0013, 0x0000);   /* VDV[4:0] for VCOM amplitude */
   delay_ms(200);  /* delay 200 ms */
LCD_WriteReg(0x0010, 0x1690);   /* SAP, BT[3:0], AP, DSTB, SLP, STB */
LCD_WriteReg(0x0011, 0x0227);   /* DC1[2:0], DC0[2:0], VC[2:0] */
   delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0012, 0x000C);   /* Internal reference voltage= Vci */
   delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0013, 0x0800);   /* Set VDV[4:0] for VCOM amplitude */
LCD_WriteReg(0x0029, 0x0011);   /* Set VCM[5:0] for VCOMH */
LCD_WriteReg(0x002B, 0x000B);   /* Set Frame Rate */
   delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0020, 0x0000);   /* GRAM horizontal Address */
LCD_WriteReg(0x0021, 0x0000);   /* GRAM Vertical Address */
/* Adjust the Gamma Curve */
LCD_WriteReg(0x0030, 0x0000);
LCD_WriteReg(0x0031, 0x0106);
LCD_WriteReg(0x0032, 0x0000);
LCD_WriteReg(0x0035, 0x0204);
LCD_WriteReg(0x0036, 0x160A);
LCD_WriteReg(0x0037, 0x0707);
LCD_WriteReg(0x0038, 0x0106);
LCD_WriteReg(0x0039, 0x0707);
LCD_WriteReg(0x003C, 0x0402);
LCD_WriteReg(0x003D, 0x0C0F);
/* Set GRAM area */
LCD_WriteReg(0x0050, 0x0000);   /* Horizontal GRAM Start Address */
LCD_WriteReg(0x0051, 0x00EF);   /* Horizontal GRAM End Address */
LCD_WriteReg(0x0052, 0x0000);   /* Vertical GRAM Start Address */
LCD_WriteReg(0x0053, 0x013F);   /* Vertical GRAM Start Address */
LCD_WriteReg(0x0060, 0x2700);   /* Gate Scan Line */
LCD_WriteReg(0x0061, 0x0001);   /*  NDL,VLE, REV */
LCD_WriteReg(0x006A, 0x0000);   /* set scrolling line */
/* Partial Display Control */
LCD_WriteReg(0x0080, 0x0000);
LCD_WriteReg(0x0081, 0x0000);
LCD_WriteReg(0x0082, 0x0000);
LCD_WriteReg(0x0083, 0x0000);
LCD_WriteReg(0x0084, 0x0000);
LCD_WriteReg(0x0085, 0x0000);
/* Panel Control */
LCD_WriteReg(0x0090, 0x0010);
LCD_WriteReg(0x0092, 0x0600);
LCD_WriteReg(0x0007,0x0021);
   delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0007,0x0061);
   delay_ms(50);  /* delay 50 ms */
LCD_WriteReg(0x0007,0x0133);    /* 262K color and display ON */
}
else if( DeviceCode == 0x9919 )
{
   LCD_Code = SSD2119;
   /* POWER ON &RESET DISPLAY OFF */
LCD_WriteReg(0x28,0x0006);
LCD_WriteReg(0x00,0x0001);
LCD_WriteReg(0x10,0x0000);
LCD_WriteReg(0x01,0x72ef);
LCD_WriteReg(0x02,0x0600);
LCD_WriteReg(0x03,0x6a38);
LCD_WriteReg(0x11,0x6874);
LCD_WriteReg(0x0f,0x0000);    /* RAM WRITE DATA MASK */
LCD_WriteReg(0x0b,0x5308);    /* RAM WRITE DATA MASK */
LCD_WriteReg(0x0c,0x0003);
LCD_WriteReg(0x0d,0x000a);
LCD_WriteReg(0x0e,0x2e00);  
LCD_WriteReg(0x1e,0x00be);
LCD_WriteReg(0x25,0x8000);
LCD_WriteReg(0x26,0x7800);
LCD_WriteReg(0x27,0x0078);
LCD_WriteReg(0x4e,0x0000);
LCD_WriteReg(0x4f,0x0000);
LCD_WriteReg(0x12,0x08d9);
/* Adjust the Gamma Curve */
LCD_WriteReg(0x30,0x0000);
LCD_WriteReg(0x31,0x0104);  
LCD_WriteReg(0x32,0x0100);
   LCD_WriteReg(0x33,0x0305);
   LCD_WriteReg(0x34,0x0505);  
LCD_WriteReg(0x35,0x0305);
   LCD_WriteReg(0x36,0x0707);
   LCD_WriteReg(0x37,0x0300);
LCD_WriteReg(0x3a,0x1200);
LCD_WriteReg(0x3b,0x0800);  
   LCD_WriteReg(0x07,0x0033);
}
else if( DeviceCode == 0x1505 || DeviceCode == 0x0505 )
{
   LCD_Code = R61505U;
  /* second release on 3/5  ,luminance is acceptable,water wave appear during camera preview */
   LCD_WriteReg(0x0007,0x0000);
   delay_ms(50);  /* delay 50 ms */
   LCD_WriteReg(0x0012,0x011C);    /* why need to set several times? */
   LCD_WriteReg(0x00A4,0x0001);    /* NVM */
   LCD_WriteReg(0x0008,0x000F);
   LCD_WriteReg(0x000A,0x0008);
   LCD_WriteReg(0x000D,0x0008);    
   /* GAMMA CONTROL */
   LCD_WriteReg(0x0030,0x0707);
   LCD_WriteReg(0x0031,0x0007); 
   LCD_WriteReg(0x0032,0x0603); 
   LCD_WriteReg(0x0033,0x0700); 
   LCD_WriteReg(0x0034,0x0202); 
   LCD_WriteReg(0x0035,0x0002); 
   LCD_WriteReg(0x0036,0x1F0F);
   LCD_WriteReg(0x0037,0x0707); 
   LCD_WriteReg(0x0038,0x0000); 
   LCD_WriteReg(0x0039,0x0000); 
   LCD_WriteReg(0x003A,0x0707); 
   LCD_WriteReg(0x003B,0x0000); 
   LCD_WriteReg(0x003C,0x0007); 
   LCD_WriteReg(0x003D,0x0000); 
   delay_ms(50);  /* delay 50 ms */
   LCD_WriteReg(0x0007,0x0001);
   LCD_WriteReg(0x0017,0x0001);    /* Power supply startup enable */
   delay_ms(50);  /* delay 50 ms */
   /* power control */
   LCD_WriteReg(0x0010,0x17A0); 
   LCD_WriteReg(0x0011,0x0217);    /* reference voltage VC[2:0]   Vciout = 1.00*Vcivl */
   LCD_WriteReg(0x0012,0x011E);    /* Vreg1out = Vcilvl*1.80   is it the same as Vgama1out ? */
   LCD_WriteReg(0x0013,0x0F00);    /* VDV[4:0]-->VCOM Amplitude VcomL = VcomH - Vcom Ampl */
   LCD_WriteReg(0x002A,0x0000);  
   LCD_WriteReg(0x0029,0x000A);    /* Vcomh = VCM1[4:0]*Vreg1out    gate source voltage?? */
   LCD_WriteReg(0x0012,0x013E);    /* power supply on */
   /* Coordinates Control */
   LCD_WriteReg(0x0050,0x0000);
   LCD_WriteReg(0x0051,0x00EF); 
   LCD_WriteReg(0x0052,0x0000); 
   LCD_WriteReg(0x0053,0x013F); 
   /* Pannel Image Control */
   LCD_WriteReg(0x0060,0x2700); 
   LCD_WriteReg(0x0061,0x0001); 
   LCD_WriteReg(0x006A,0x0000); 
   LCD_WriteReg(0x0080,0x0000); 
   /* Partial Image Control */
   LCD_WriteReg(0x0081,0x0000); 
   LCD_WriteReg(0x0082,0x0000); 
   LCD_WriteReg(0x0083,0x0000); 
   LCD_WriteReg(0x0084,0x0000); 
   LCD_WriteReg(0x0085,0x0000); 
   /* Panel Interface Control */
   LCD_WriteReg(0x0090,0x0013);      /* frenqucy */
   LCD_WriteReg(0x0092,0x0300); 
   LCD_WriteReg(0x0093,0x0005); 
   LCD_WriteReg(0x0095,0x0000); 
   LCD_WriteReg(0x0097,0x0000); 
   LCD_WriteReg(0x0098,0x0000); 
 
   LCD_WriteReg(0x0001,0x0100); 
   LCD_WriteReg(0x0002,0x0700); 
   LCD_WriteReg(0x0003,0x1030); 
   LCD_WriteReg(0x0004,0x0000); 
   LCD_WriteReg(0x000C,0x0000); 
   LCD_WriteReg(0x000F,0x0000); 
   LCD_WriteReg(0x0020,0x0000); 
   LCD_WriteReg(0x0021,0x0000); 
   LCD_WriteReg(0x0007,0x0021); 
   delay_ms(200);  /* delay 200 ms */
   LCD_WriteReg(0x0007,0x0061); 
   delay_ms(200);  /* delay 200 ms */
   LCD_WriteReg(0x0007,0x0173); 
}  
else if( DeviceCode == 0x8989 )
{
   LCD_Code = SSD1289;
   LCD_WriteReg(0x0000,0x0001);    delay_ms(50);   /* 打开晶振 */
   LCD_WriteReg(0x0003,0xA8A4);    delay_ms(50);   
   LCD_WriteReg(0x000C,0x0000);    delay_ms(50);   
   LCD_WriteReg(0x000D,0x080C);    delay_ms(50);   
   LCD_WriteReg(0x000E,0x2B00);    delay_ms(50);   
   LCD_WriteReg(0x001E,0x00B0);    delay_ms(50);   
   LCD_WriteReg(0x0001,0x2B3F);    delay_ms(50);   /* 驱动输出控制320*240 0x2B3F */
   LCD_WriteReg(0x0002,0x0600);    delay_ms(50);
   LCD_WriteReg(0x0010,0x0000);    delay_ms(50);
   LCD_WriteReg(0x0011,0x6070);    delay_ms(50);   /* 定义数据格式 16位色 横屏 0x6070 */
   LCD_WriteReg(0x0005,0x0000);    delay_ms(50);
注:暂存的内容只能恢复到当前文章的编辑器中,如需恢复到其他文章中,请编辑该文章并从暂存箱中恢复;或者直接复制以上内容,手工恢复到相关文章。
阅读(2153) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~