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

📄 lcd_st7787_qvga.c

📁 LCD ST7787 QVGA 屏 的 驱 动
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
********************************************************************************
*          Copyright (C),2004-2007, Fuzhou Rockchip Electronics Co.,Ltd.
*                             All Rights Reserved
*
*Description: LCD 驱动
*
$Header: LCD_ST7787_QVGA.c,v 1.35 2007/04/25 05:31:54 FangZhenFu Exp $
$Author: FangZhenFu $
$Date: 2007/04/25 05:31:54 $ 
$Revision: 1.9 Release$
********************************************************************************
*/
//******************************************************************************
#define     _IN_LCD_LTPS
//------------------------------------------------------------------------------
#include "Memap.h"
#include "Macro.h"
#include "Global.h"
#include "MsgDef.h"
#include "Lcd.h"
#include "LcdChar.h"
#include "Dma.h"
//---------driver program HX8309---TFT2.0-------------------------------------------------------------------
#undef   Parallel8
#define  UINT16     unsigned short
#define LCD_INIT_NORMAL 0
#define MP4_LCD_INIT    2
void  PowerOnLcdinit();

void LCD_Init(unsigned int type) ;
void LCD_SetDispAddr(unsigned int x,unsigned int y);
void LCDDEV_SetWindow(int x0, int y0, int x1, int y1);
void LCDDEV_RevertWindow(int x0, int y0, int x1, int y1);
void Display_off(void) ;

unsigned int LcdScanType=0;




#ifndef CAM_MODULE

void LCD_Command(unsigned int cmd)
{
    write_mem(LCD_COMMAND,cmd);
}

void LCD_Data(unsigned int data)
{
    write_mem(LCD_DATA,data);
}
#endif

void LCD_Reg_Set(unsigned int cmd,unsigned int data)
{
	LCD_Command(cmd);
	LCD_Data(data);

}       

unsigned int LCD_StatusRead(void)
{
//    unsigned int i,j;
//    i = read_XDATA(LCD_COMMAND);
//#ifdef  Parallel8
//    j = read_XDATA(LCD_COMMAND);
//    i = ((i & 0xff00) | (j >> 8));
//#endif
//    return i;
}



void LCD_SetDispAddr(unsigned int x,unsigned int y)
{
/*
	unsigned  int Parameter1,Parameter2;
	Parameter1 = x;
	Parameter1 = Parameter1 >>8;
	Parameter2 = x;
   // LCD_Reg_Set(0x002a, y);    //RAM Addr x
    write_mem(LCD_COMMAND,0x002a); 
    write_mem(LCD_DATA,Parameter1);
write_mem(LCD_DATA,Parameter2);
//write_mem(LCD_DATA,Parameter1);
//write_mem(LCD_DATA,Parameter2);

	Parameter1 = y;
	Parameter1 = Parameter1 >>8;
	Parameter2 = y;
//	LCD_Reg_Set(0x002b, x);    //RAM Addr y
    write_mem(LCD_COMMAND,0x002b); 
    write_mem(LCD_DATA,Parameter1);
write_mem(LCD_DATA,Parameter2);
//write_mem(LCD_DATA,Parameter1);
//write_mem(LCD_DATA,Parameter2);
	//LCD_Command(0x0022);
*/
	LCD_Command(0x002c);
}

void LCD_SetPixel(unsigned int x, unsigned int y, unsigned int color)
{
    LCD_SetDispAddr(x,y);	
	LCD_Data(color);	        //color表示RGB值, 这个函数的功能是往(x,y)写入color值
}


unsigned int LCD_GetPixel(unsigned int x, unsigned int y)
{
//	unsigned int color;
//	unsigned int i;
//
//	LCD_SetDispAddr(x,y);		
//	color = read_XDATA(LCD_DATA);
//	//for(i=10; i>0; i--);
//	color = read_XDATA(LCD_DATA);
//	//color = DataChange(color);
//	return(color);
}


void LCD_XorPixel(unsigned int x, unsigned int y)
{
//	unsigned int color;
//	color = LCD_GetPixel(x,y);
//	LCD_SetPixel(x,y,0xFFFF-color);	
}

void LCD_Init(unsigned int type)
{

	 LcdScanType = 0;
	LCD_Command(0x0036);
	LCD_Data(0x0060);
    LCDDEV_SetWindow(0, 0, LCD_MAX_XSIZE-1, LCD_MAX_YSIZE-1);
    
 //   PowerOnLcdinit();
}

void  PowerOnLcdinit()
	
#if 1
{
	int x,y;
	
	LCD_Command(0x11);
	Delay1Ms(600);

	LCD_Command(0xb1);
	LCD_Data(0x3c);     //3//jhtg3a
	LCD_Data(0x02);
	LCD_Data(0x02);


	LCD_Command(0xbc);

	
	LCD_Command(0xc2);
	LCD_Data(0x04);
	LCD_Data(0xe6);           //d4
	LCD_Data(0x86);           //
	LCD_Data(0x33);
	LCD_Data(0x03);

	LCD_Command(0xc3);
	LCD_Data(0x03);
	LCD_Data(0x33);
	LCD_Data(0x03);
	LCD_Data(0x00);
	LCD_Data(0x00);

	LCD_Command(0xf4);
	LCD_Data(0xff);
	LCD_Data(0x3f);

	LCD_Command(0xf5);
	LCD_Data(0x10);


	LCD_Command(0xfb);
	LCD_Data(0x7f);

	

	LCD_Command(0xc5);
	LCD_Data(0xc9);        //0xc8
	LCD_Data(0x1a);        //0x1a

	LCD_Command(0xc6);
	LCD_Data(0x24);        //26
	LCD_Data(0x00);	       //00

	LCD_Command(0xc0);
	LCD_Data(0x00);

	LCD_Command(0xb6);
	LCD_Data(0x02);
	LCD_Data(0x04);		


	
	LCD_Command(0x36);	 //扫描方向	
	LCD_Data(0x60);

	LCD_Command(0x3a);
	LCD_Data(0x05);

	LCD_Command(0x2a);
	LCD_Data(0x00);	
	LCD_Data(0x00);	
	LCD_Data(0x01);	
	LCD_Data(0x3f);	
		
		LCD_Command(0x2b);
		LCD_Data(0x00); 
		LCD_Data(0x00); 
		LCD_Data(0x00); 
		LCD_Data(0xef);
	
	Delay1Ms(100);

	
	LCD_Command(0x29);


	


}


/*    //xichuang 
{
	   unsigned int x,y;
	
		Delay1Ms(10);
		LCD_INIT:
//	LCD_Command(0x01);	
	
	LCD_Command(0x10);	
	Delay1Ms(100);
	
		LCD_Command(0x11);	 
		Delay1Ms(800);

		 LCD_Command(0xb1);   
		 LCD_Data(0x30);
		 LCD_Data(0x02);
		 LCD_Data(0x02);
		 
		 LCD_Command(0xbc);   

	
		LCD_Command(0xC2);	 
		LCD_Data(0x01);
		LCD_Data(0xd4);
		LCD_Data(0x85);
		LCD_Data(0x00);
		LCD_Data(0x00);
		
		LCD_Command(0xC3);	 
		LCD_Data(0x01);
		LCD_Data(0x22);
		LCD_Data(0x01);
		LCD_Data(0x00);
		LCD_Data(0x00);

		LCD_Command(0xf4);	 
		LCD_Data(0xff);
		LCD_Data(0x3f);

		LCD_Command(0xf5);	 
		LCD_Data(0x10);

		LCD_Command(0xfb);	 
		LCD_Data(0x7f);

		LCD_Command(0xc5);	 
		LCD_Data(0xc0);
		LCD_Data(0x1a);
		
		
		LCD_Command(0xc6);	 
		LCD_Data(0x24);
		LCD_Data(0x00);
 
		LCD_Command(0xC0);	 
		LCD_Data(0x00);

	 Delay1Ms(100);

			 LCD_Command(0xb6);   
			 LCD_Data(0x02);
			 LCD_Data(0x02);
			 
			 LCD_Command(0x20);	//29

				
		   LCD_Command(0x3a);	
		   LCD_Data(0x05);

		   
		  // LCD_Command(0x38);	
		   //LCD_Data(0x55);
	
	
		   LCD_Command(0x36); 	//扫描方向
		   LCD_Data(0x60);	   
	
	   
		   Delay1Ms(40);
		   Delay1Ms(80);
		   
//		   LCD_Command(0x29);	  //29
 	
			LCD_Command(0x2A);	
		   LCD_Data(0x00);
		   LCD_Data(0x00);
		   LCD_Data(0x01);
		   LCD_Data(0x3F);
	
		   LCD_Command(0x2b);	
		   LCD_Data(0x00);
		   LCD_Data(0x00);
		   LCD_Data(0x00);
		   LCD_Data(0xeF);	

	   
			LCD_Command(0x29);		 // //2c	
			
			LCD_Command(0x2c);		 // //2c	   
    
    for(x=0; x<30; x++){
        for(y=0; y<320; y++){
            LCD_Data(0xf80f);
        }
    } 	

for(x=0; x<30; x++){
	for(y=0; y<320; y++){
		  LCD_Data(0xAAaa);
	}
} 
for(x=0; x<30; x++){
	for(y=0; y<320; y++){
		 LCD_Data(0x3333);
	}
} 
for(x=0; x<30; x++){
	for(y=0; y<320; y++){
		LCD_Data(0xf01f);
	}
} 


    for(x=0; x<30; x++){
        for(y=0; y<320; y++){
            LCD_Data(0xf8ff);
        }
    } 	

for(x=0; x<30; x++){
	for(y=0; y<320; y++){
		 LCD_Data(0x00ff);
	}
} 
for(x=0; x<30; x++){
	for(y=0; y<320; y++){
		 LCD_Data(0x1111);
	}
} 
for(x=0; x<30; x++){
	for(y=0; y<320; y++){
		LCD_Data(0xeeee);
	}
} 

while(1);		

}*/

#else
{

  unsigned int x,y;

	 LcdScanType = 0;
	LCD_Command(0x0011);

	Delay1Ms(600);

	LCD_Command(0x00bc);

	LCD_Command(0x00c3);
	LCD_Data(0x0001);
	LCD_Data(0x0066);
	LCD_Data(0x0001);
	LCD_Data(0x0000);
	LCD_Data(0x0000);

	LCD_Command(0x00b1);
	LCD_Data(0x0030);
	LCD_Data(0x0002);
	LCD_Data(0x0002);	

	Delay1Ms(30);

	LCD_Command(0x00f4);
	LCD_Data(0x00ff);
	LCD_Data(0x003f);


	LCD_Command(0x00c2);
	LCD_Data(0x0001);
	LCD_Data(0x00d6);
	LCD_Data(0x0085);
	LCD_Data(0x0030);
	LCD_Data(0x0000);	

	Delay1Ms(24);

	LCD_Command(0x00fb);
	LCD_Data(0x007f);	

	LCD_Command(0x00c5);
	LCD_Data(0x00c0);//0xba
	LCD_Data(0x001a);

	Delay1Ms(30);

	
	LCD_Command(0x00c6);
	LCD_Data(0x0026);//0x22
	LCD_Data(0x0000);

	Delay1Ms(30);

	LCD_Command(0x00c0);
	LCD_Data(0x0000);
	Delay1Ms(30);


	LCD_Command(0x0035);
	LCD_Data(0x0000);
	Delay1Ms(30);

	LCD_Command(0x0036);
	LCD_Data(0x0060);

	LCD_Command(0x00b6);
	LCD_Data(0x0002);
	LCD_Data(0x0004);
	//Delay1Ms(30);

	LCD_Command(0x003a);
	LCD_Data(0x0005);

	LCD_Command(0x0029);
	LCD_Command(0x002c);

    LCDDEV_SetWindow(0, 0,  LCD_MAX_XSIZE-1, LCD_MAX_YSIZE-1); 	

#ifdef LCD_MEMORY_DEV
 //  LCD_Command(0x0022);

   	LCD_Command(0x002c);
	
    for(x=0; x<240; x++){
        for(y=0; y<320; y++){

⌨️ 快捷键说明

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