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

📄 lcd_1289_8312.c

📁 当前流行的屏驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************

 C   S O U R C E   F I L E

 Copyright 2005 SISIS, Inc. All Rights Reserved.

*******************************************************************************

 Project Name : HS32002 SDK
 Project No.  : 
 Title        : 
 Template Ver : 0.1
 File Name    : lcd_Toshiba.h
 Last Modified: 2006/05/31
 
 Current Version:      0.1
 Authors:              Jupiter.Huang
 Date:                 2006/05/31
 Description  : modify function interface,add function Lcd_Ioctl(). 

 Current Version:      0.1
 Authors:              Keying Fang
 Date:                 2005/10/10

 Assumptions  : NA
 
 Dependency Comments : NA
 
 Project Specific Data : NA

*******************************************************************************
Version:				1.1              
Authors:				ConanVV
Date:					2007-01-15   
Modification:			1. rename LCD_Open and LCD_Write.
                           add dma interrupt supporing in LCD_Open();
******************************************************************************/


/**************************************************************************************/
/************************      Global Varible         *********************************/
/**************************************************************************************/
static INT32 BACK_LIGHT_VALUE = 0xCCCC;
static INT32 FLAG_LCD = 0;

static TEIM_Reg* regEMI = EIM_Reg_Address;

UINT8 chip_id;
/**************************************************************************************/
/************************      Internal function      *********************************/
/**************************************************************************************/
/*----  set EMI  ----*/
void InitCS0()
{
	//CS0 control register configuration// 
	regEMI->CS0U = 0x0000d200;
	regEMI->CS0L = 0x28280D01;  
}

void  Delay(unsigned int t)
{
	unsigned int n,m;
	for(n=0;n<t;n++)
		for(m=0;m<1000;m++);
}

void WriteCommand( UINT16 command)
{	
	GPIO_SetOutput(LCD_RS_PORT, 0, 1<<LCD_RS_BIT);
	(*EXT_CHIP_CMD_ADDR) = command;
	
}

void WriteData( UINT16 command)
{	
	GPIO_SetOutput(LCD_RS_PORT, 1<<LCD_RS_BIT, 0);
	
	(*EXT_CHIP_DATA_ADDR) = command;		
}

/*----  set LCD reg  ----*/
INT32 WriteReg( UINT16 command, UINT16 value)
{	
	
	GPIO_SetOutput(LCD_RS_PORT, 0, 1<<LCD_RS_BIT);
	
	(*EXT_CHIP_CMD_ADDR) = command;
	
	
	GPIO_SetOutput(LCD_RS_PORT, 1<<LCD_RS_BIT, 0);
	
	(*EXT_CHIP_DATA_ADDR) = value;
	
	return 0;
}
/*----  read LCD reg  ----*/
UINT8 ReadReg( UINT16 command)
{
	UINT8 read_value;
	
	GPIO_SetOutput(LCD_RS_PORT, 0, 1<<LCD_RS_BIT);
	
	(*EXT_CHIP_CMD_ADDR) = command;
	
	read_value=(*EXT_CHIP_DATA_ADDR);
	
	return read_value;
}

void SetLCDWindows(UINT16 xstart,UINT16 xend,UINT16 ystart,UINT16 yend)
{
	if(((chip_id)&0xff)==0x89)
	{
		WriteReg(0x004e,(xstart)&0x00ff);   //x	
		WriteReg(0x004f,ystart&0x01ff);   //y	
		WriteReg(0x0044,((xend<<8)&0xff00)|((xstart)&0x00ff));//xstar -end
		WriteReg(0x0045,ystart);  //ystart
		WriteReg(0x0046,yend);   //yend	
	}
	else
	{	
		// WriteCommand(0x4200);  //SRAM_X
		WriteCommand(((xstart)&0x00ff)|0x4200);  //SRAM_X
		WriteCommand(((ystart>>8)&0x0001)|0x4300);  //SRAM_Y
		// WriteCommand(((ystart>>8)&0x0001)|0x4400);
		WriteCommand(((ystart)&0x00ff)|0x4400);
		
		WriteCommand(((xstart)&0x00ff)|0x4500);// X-START,0
		WriteCommand(((xend)&0x00ff)|0x4600);// X-END,240
		WriteCommand(((ystart>>8)&0x0001)|0x4700);// Y-START
		WriteCommand(((ystart)&0x00ff)|0x4800);// Y-START,0
		WriteCommand(((yend>>8)&0x0001)|0x4900);// Y-END
		WriteCommand(((yend)&0x00ff)|0x4A00);// Y-END, 320
	}	
}

/******* enable_back_light ***********/ 
void pwm_enable_backlight(void)
{	
	PWMCTL pwmctl;
	
	/*config PA01 for LCD blacklight*/
	GPIO_SetPeriA(GPIO_PORTA,BIT1,1);
	
	pwmctl.value_period = 0xFFFE;
	pwmctl.value_sample = BACK_LIGHT_VALUE;
	
	PWM_Start(&pwmctl);
	
}

/********** modify back light *********/
void pwm_set_backlight(UINT16 value)
{
	PWMCTL pwmctl;
	pwmctl.value_sample = value;
	PWM_Ioctl(SET_PWM_SAMPLE, &pwmctl);
}


/*---- LCD Initial ----*/
void LcdInit()
{
	
	int i;
	for(i=0; i<0xFF; i++);//delay 
	/*open back light*/
	//pwm_enable_backlight();
	
	GPIO_SetOutput(LCD_RESET_PORT, 1<<LCD_RESET_BIT, 0);
	GPIO_SetOutput(LCD_POWER_ON_PORT, 1<<LCD_POWER_ON_BIT, 0);

	/***   Power ON Sequence   ***/
	Delay(50);	     
    chip_id = ReadReg(0x0000);	  
    //printf("The CHIP ID is 0x%X\n",chip_id); 
	if(((chip_id)&0xff)==0x89)
	{                                                          //创维LCD
		WriteReg(0x0000,0x0001); // start osc
		
		WriteReg(0x0003,0xA2A4); // power control_1
		WriteReg(0x000C,0x0000); // power control_2
		WriteReg(0x000D,0x0308); // power control_3
		WriteReg(0x000E,0x3001); // power control_4
		WriteReg(0x001E,0x00AC); // power control_5      
		Delay(100);    
		WriteReg(0x0001,0x2B3F); // driver ouput
		// WriteReg(0x0001,0x6B3F); // driver ouput
		WriteReg(0x0002,0x0600); // driver waveform
		WriteReg(0x0010,0x0000); // sleep mode cancel
		WriteReg(0x0011,0x6028); // enter mode; horizontal display     
		// WriteReg(0x0011,0x6008); // enter mode; horizontal display     
		//WriteReg(0x0007,0x0033); // display on
		WriteReg(0x0007,0x0233); // display on
                WriteReg(0x000B,0x0050); // frame cycle control//WriteReg(0x000B,0x0039); // frame cycle control
		WriteReg(0x000F,0x0000); // gate scan
		WriteReg(0x0048,0x0000); // 
		WriteReg(0x0049,0x013F); // 
		WriteReg(0x004A,0x0000); // 
		WriteReg(0x004B,0x0000); // 
		WriteReg(0x004e,0x0000); // horizontal(x) star(low 8bit)-end(high 8bit)
		WriteReg(0x004f,0x0000); // horizontal(x) star(low 8bit)-end(high 8bit)
		WriteReg(0x0044,0xEF00); // horizontal(x) star(low 8bit)-end(high 8bit)
		WriteReg(0x0045,0x0000); // vertical(y) start
		WriteReg(0x0046,0x013F); // vertical(y) end
   
								 //gamma control
								 WriteReg(0x0030,0x0707); //  gamma control1
								 WriteReg(0x0031,0x0204); //  gamma control2
								 WriteReg(0x0032,0x0204); //  gamma control3
								 WriteReg(0x0033,0x0502); //  gamma control4
								 WriteReg(0x0034,0x0507); //  gamma control5
								 WriteReg(0x0035,0x0204); //  gamma control6
								 WriteReg(0x0036,0x0204); //  gamma control7
        	Delay(200);  	
								 WriteReg(0x0037,0x0502); //  gamma control8
        	Delay(200);  		
								 WriteReg(0x003a,0x0302); //  gamma control9
		Delay(200);  		
								 WriteReg(0x003b,0x0302); //  gamma control10
		Delay(200);  		
		WriteReg(0x0023,0x0000); // write data mask1
		WriteReg(0x0024,0x0000); // write data mask2
		WriteCommand(0x0022);   ;// Display Data Write...
        // Delay(100);          
	}
    else
	{                                                                         //宇顺
		WriteCommand(0x0100);  // Start oscillation ,x0-x0+n;y0-y0+n
		WriteCommand(0x00A0);  // Standby mode cancel
		WriteCommand(0x0301);  // Software reset operation
		Delay(10);
		WriteCommand(0x0300);  // Software reset operation cancel
		//WriteCommand(0x0600);        
		WriteCommand(0x2B02);  // Oscillator frequency adjust setting
		//         chip_id = ReadReg(0x0031);
		//	   printf("The CHIP ID is 0x%X\n",chip_id);
		//WriteCommand(0x2818);  // DC/DC clock frequency adjust setting
		WriteCommand(0x5901);  //test
		WriteCommand(0x6022);
		WriteCommand(0x5900);
		WriteCommand(0x2818);  // DC/DC clock frequency adjust setting
		WriteCommand(0x1A05);  // Step up circuit frequency adjust setting
		WriteCommand(0x2507);  // Step up factor in step up circuit 2 setting 
		
		WriteCommand(0x1C73);  // Step up circuit operating current setting
		//  WriteCommand(0x3708);  //// Step up circuit operating current setting 2
		WriteCommand(0x2474); //V18 AND VCOM regulator current setting
		//############# void Power_on_Set(void) ################//
        
		WriteCommand(0x1e01);  // Extra step up circuit1 operation
		WriteCommand(0x1900);  // VR1 and VR2 regulator setting  
        // WriteCommand(0x18c0);  // VR1 and VR2 regulator setting  
		WriteCommand(0x18f5);  // VR1 and VR2 regulator on   18c1
		Delay(10);
		
		WriteCommand(0x18f5);  // VCL turn on   18e1
		WriteCommand(0x18F5);  // VGH and VGL turn on  18f1
		Delay(60);
		
		WriteCommand(0x18F5);  // DDVDH turn on
		Delay(60);;
		
		WriteCommand(0x1B09);  // VS/VDH turn on and set
		Delay(10);
		
		WriteCommand(0x1f11);  // VCOMH voltage setting
		WriteCommand(0x2010);  //2019 // VCOM amplitude voltage setting
		WriteCommand(0x1e81);  // VCOM operation start
		Delay(10);
		
		//############# void Chip_Set (void) ################//
		
		WriteCommand(0x0180);
		WriteCommand(0x0514); //d2=am;
		WriteCommand(0x9D00);   //横屏显示
		WriteCommand(0xC000);
		WriteCommand(0xC100);
		WriteCommand(0x0E00);
		WriteCommand(0x0F00);
		WriteCommand(0x1000);
		WriteCommand(0x1100);
		WriteCommand(0x1200);
		WriteCommand(0x1300);
		WriteCommand(0x1400);
		WriteCommand(0x1500);
		WriteCommand(0x1600);
		WriteCommand(0x1700);
		WriteCommand(0x3401);
		WriteCommand(0x3500);
		WriteCommand(0x4B00);
		WriteCommand(0x4C00);
		WriteCommand(0x4E00);
		WriteCommand(0x4F00);
		WriteCommand(0x5000);   //
		
		WriteCommand(0x3C00);
		WriteCommand(0x3D00);
		WriteCommand(0x3E01);
		WriteCommand(0x3F3f);
		WriteCommand(0x4002);
		WriteCommand(0x4102);
		
		WriteCommand(0x4200);
		WriteCommand(0x4300);
		WriteCommand(0x4400);
		WriteCommand(0x4500);// X-START,0
		WriteCommand(0x46ef);// X-END,240
		WriteCommand(0x4700);// Y-START
		WriteCommand(0x4800);// Y-START,0
		WriteCommand(0x4901);// Y-END
		WriteCommand(0x4A3f);// Y-END, 320
		
		//WriteCommand(0x0600);
		WriteCommand(0x1D0f);  // Gate scan direction setting
		WriteCommand(0x8600);
		WriteCommand(0x8730);
		WriteCommand(0x8802);
		WriteCommand(0x8905);
		WriteCommand(0x8D01);  // Register set-up mode for one line clock number
		WriteCommand(0x8b25); //(x8B30);  // One line SYSCLK number in one-line scan
		WriteCommand(0x3301);  // N line inversion setting
		WriteCommand(0x3701);  // Scanning method setting
		WriteCommand(0x7600);
		//WriteCommand(0xc100);
		/*
		//############# void Gamma_Set(void) ################//
		
		  WriteCommand(0x8F10);
		  WriteCommand(0x9067);
		  WriteCommand(0x9107);
		  WriteCommand(0x9256);
		  WriteCommand(0x9307);
		  WriteCommand(0x9401);
		  WriteCommand(0x9576);
		  WriteCommand(0x9665);
		  WriteCommand(0x9700);
		  WriteCommand(0x9800);
		  WriteCommand(0x9900);
		  WriteCommand(0x9A00);
		  
			//############# void Display_On(void) ################//

⌨️ 快捷键说明

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