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

📄 display.c

📁 基于EPSON 的一种操作系统内核改造的实时嵌入式操作系统ASIXOS,国内一家研发中心开发。精炼可靠
💻 C
字号:
/*                                                                                            
********************************************************************************************  
*filename:			lcdc.c						                                                  
*author:			gfd	                                                                  
*create date:		        2003-4-2 16:54                                                           
*description:	    The file consists of the function define of lcdc         
*modify history:	                                                                          
*misc:                                                                                        
********************************************************************************************  
*/ 
#include "HA_TypeDef.h" 
#include "hardware.h"
#include "hardware_reg.h"



#define		xsize	240
#define		ysize	240
 
void init_LCD(void)
{
	U32 i = 4;
	U32 t;

	*(RP)LECR = 0x00000000;     //disable the LCDC
	
	*(RP)PORTE_SEL = 0X1<<11;	//GPIO to select lcd_backlight
	*(RP)PORTE_DATA =( 0X1 << 11);
	
	/* config the register of lcdc */
	*(RP)SSA = VS_BASE;
	*(RP)SIZE = 0x00F00140;			    	//the size of display is 240*320
	*(RP)PCR = 0x22080009;
	//*(RP)PCR = 0x22080003;//0x220c0003;     	//_2bpp,  one eighth of AMBA frequency
	*(RP)HCR = 0xc80008b4;//;0xc80008ab;
	//*(RP)HCR = 0x08000812;//;0xc80008ab;      	//H_WAIT_1=10, H_WAIT_2=10
	*(RP)VCR = 0x14000304;//0x14000304;      	//V_WAIT_1=4, V_WAIT_1=4
	*(RP)PWMR = 0x00000113;//0x00000114;     	//select the Pixel clock
	*(RP)DMACR = 0x80070003;//0x80070003;    	//burst=0
	*(RP)LCDICR = 0x00000000;
	
	/* to config the grey */
	*(RP)LGPMR = 0x00000000;
	*(RP)(LGPMR+1*i) = 0x00000004;
	*(RP)(LGPMR+2*i) = 0x0000000a;
	*(RP)(LGPMR+3*i) = 0x0000000f;
		
	*(RP)LECR = 0x0000001;     //enable the LCDC
	
	for(t=0; t<2400*2; t++) *(RP)(VS_BASE+t*4) = 0xffff;

}


U32 lcd_draw(U8 x1, U8 y1, U8 x2, U8 y2, U8 color)
{
	U32 pixelptr, i;// *ptr2;
	U8 temp, x, bpp=0x2; 
	U8 color0, color1, color2, color3;
	
//// choose the color:: 0x00:white   0x0f:grey one   0xf0:grey two   0xff:black	
	switch(color)
	{
		case 0x00: color0=0x00;color1=0x00;color2=0x00;color3=0x00;
		           break;
		case 0x0f: color0=0x40;color1=0x10;color2=0x04;color3=0x01;
		           break;
		case 0xf0: color0=0x80;color1=0x20;color2=0x08;color3=0x02;
		           break;
		case 0xff: color0=0xc0;color1=0x30;color2=0x0c;color3=0x03;
		           break;
		default  : return 0;
		}
	
//// to check the edge of screen
        if((x1<=xsize)&&(x2<=xsize)&&(y1<=ysize)&&(y2<=ysize)) 
         {}                                           
	else  
	 return 0;

//// assure that (x1,y1) should be little than (x2,y2)	 
	if((x1<=x2)&&(y2<=y2))
	 {}
	else
	 return 0;
	 
//// display line one by one	 
	for(i=y1; i<=y2; i++)
	{
		x = x1;
		do                           ////display pixel one by one
		{
			if(x%4==1)
			{
				pixelptr = VS_BASE+(i*xsize*bpp)/8 + (x-1)*bpp/8;
				temp = *(U8 *)pixelptr;
				temp |= color3;
				*(U8 *)pixelptr = temp;
			}
			else if(x%4==2)
			{
				pixelptr = VS_BASE+(i*xsize*bpp)/8 + (x-2)*bpp/8;
				temp = *(U8 *)pixelptr;
				temp |= color2;
				*(U8 *)pixelptr = temp;
			}
			else if(x%4==3)
			{
				pixelptr = VS_BASE+(i*xsize*bpp)/8 + (x-3)*bpp/8;
				temp = *(U8 *)pixelptr;
				temp |= color1;
				*(U8 *)pixelptr = temp;
			}
			else if(x%4==0)
			{
				pixelptr = VS_BASE+(i*xsize*bpp)/8 + (x-4)*bpp/8;
				temp = *(U8 *)pixelptr;
				temp |= color0;
				*(U8 *)pixelptr = temp;
			}
			else 
			 return 0;
			
			x += 0x1;
			
		}while(x<=x2); 
	}
	

	return E_OK;	
	
}

⌨️ 快捷键说明

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