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

📄 lcd.c

📁 s3c2410/s3c2440的bootloader演示程序
💻 C
字号:
#include "2410addr.h"
#include "lcd.h" 


//LCD_CSTN
#ifdef LCD_CSTN


volatile static unsigned char LCD_BUFER[SCR_YSIZE][SCR_XSIZE];

//LCD_CSTN
static void Lcd_Port_Init(void)
{
    rGPCUP = 0x0;
    rGPCCON = 0xaaaa56a9;

    rGPDUP = 0x0;
    rGPDCON=0xaaaaaaaa;
}

//LCD_CSTN
void Lcd_Init(void)
{
	Lcd_Port_Init();
	
	rLCDCON1=(CLKVAL<<8)|(MVAL_USED<<7)|(2<<5)|(0<<1)|0;
	rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW);
	rLCDCON3=(WDLY<<19)|(HOZVAL<<8)|(LINEBLANK);
	rLCDCON4=(MVAL<<8)|(WLH);
	rLCDCON5=(1<<11)|(0<<10)|(0<<9)|(0<<8)|(0<<7)|(0<<6)|(BSWP<<1)|(HWSWP);
		
	rLCDSADDR1=(((int)LCD_BUFER>>22)<<21)|M5D((int)LCD_BUFER>>1);
	rLCDSADDR2=M5D( ((int)LCD_BUFER+(SCR_XSIZE*LCD_YSIZE))>>1 );
	rLCDSADDR3=(((SCR_XSIZE-LCD_XSIZE)/2)<<11)|(LCD_XSIZE/2);
	
	rLCDINTMSK|=(3);
	rLPCSEL&=(~7);
	rTPAL=0;
	rLCDCON1 |= 1;
}


//LCD_CSTN
void Lcd_Clear(LCD_PIXELINDEX c)
{
	int x,y ;
		
    for( y = 0 ; y < SCR_YSIZE ; y++ )
    {
    	for( x = 0 ; x < SCR_XSIZE ; x++ )
    	{
			LCD_BUFER[y][x] = c;
    	}
    }
}

//LCD_CSTN
static void Lcd_PutPixel(int x,int y,LCD_PIXELINDEX c)
{
	if ( (x < SCR_XSIZE) && (y < SCR_YSIZE) )
	LCD_BUFER[(y)][(x)] = c;
}

#endif





//LCD_TFT
#ifdef	LCD_TFT


volatile static unsigned short LCD_BUFER[SCR_YSIZE][SCR_XSIZE];


//LCD_TFT
static void Lcd_Port_Init(void)
{
    rGPCUP = 0x0;
    rGPCCON = 0xaaaa56a9;

    rGPDUP = 0x0;
    rGPDCON=0xaaaaaaaa;
}

//LCD_TFT
void Lcd_Init(void)
{
	Lcd_Port_Init();
	
	rLCDCON1=(CLKVAL<<8)|(MVAL_USED<<7)|(3<<5)|(12<<1)|0;
	rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW);
	rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);
	rLCDCON4=(MVAL<<8)|(HSPW);
	rLCDCON5=(1<<11)|(0<<10)|(1<<9)|(1<<8)|(0<<7)|(0<<6)|(BSWP<<1)|(HWSWP);
		
	rLCDSADDR1=(((int)LCD_BUFER>>22)<<21)|M5D((int)LCD_BUFER>>1);
	rLCDSADDR2=M5D( ((int)LCD_BUFER+(SCR_XSIZE*LCD_YSIZE*2))>>1 );
	rLCDSADDR3=(((SCR_XSIZE-LCD_XSIZE)/1)<<11)|(LCD_XSIZE/1);
	
	rLCDINTMSK|=(3);
	rLPCSEL&=(~7);
	rTPAL=0;
	rLCDCON1 |= 1;
}


//LCD_TFT
void Lcd_Clear(LCD_PIXELINDEX c)
{
	int x,y ;
    for( y = 0 ; y < SCR_YSIZE ; y++ )
    {
    	for( x = 0 ; x < SCR_XSIZE ; x++ )
    	{
			LCD_BUFER[y][x] = c;
    	}
    }
}

//LCD_TFT
void Lcd_PutPixel(int x,int y,LCD_PIXELINDEX c)
{
	if ( (x < SCR_XSIZE) && (y < SCR_YSIZE) )
	LCD_BUFER[(y)][(x)] = c;
}

void Lcd_DispColorBar(void)
{
	int x,y;

	//red
	for( y = 0 ; y < SCR_YSIZE/3 ; y++ )
	{
   		for( x = 0 ; x < SCR_XSIZE ; x++ )
   		{
   			LCD_BUFER[y][x] = ((31-(x/(SCR_XSIZE/32)))<<11);
   		}
   	}

   	//green
   	for( y = SCR_YSIZE/3 ; y < 2*(SCR_YSIZE/3) ; y++ )
	{
   		for( x = 0 ; x < SCR_XSIZE ; x++ )
   		{
   			LCD_BUFER[y][x] = ((63-(x/((SCR_XSIZE%64) ? (SCR_XSIZE/64+1) : (SCR_XSIZE/64))))<<5);
   		}
   	}

   	//blue
   	for( y = 2*(SCR_YSIZE/3) ; y < SCR_YSIZE ; y++ )
	{
   		for( x = 0 ; x < SCR_XSIZE ; x++ )
   		{
   			LCD_BUFER[y][x] = ((31-(x/(SCR_XSIZE/32)))<<0);
   		}
   	}
}

void Lcd_DispBlackLine(void)
{
	int x,y;
	for( y = 0 ; y < SCR_YSIZE ; y++ )
	{
   		for( x = 0 ; x < SCR_XSIZE ; x++ )
   		{
   			LCD_BUFER[y][x] = ((y%(SCR_YSIZE/50))==0) ? 0 : (((x%(SCR_XSIZE/50))==0) ? 0 : 0xffff);
   		}
   	}
}

#include <math.h>

static int GETDA(double data)
{
	int  k= (int)data;
	if(data > (double)k+0.5)
	{
		return k+1;
	}
	else
	{
		return k;
	}
}

void Lcd_DispEllipse (int x0, int y0, int xr, int yr, LCD_PIXELINDEX c)
{
	int  i,yy,xx;
	double  tt;
	LCD_PIXELINDEX *DispBuf = (LCD_PIXELINDEX *)&LCD_BUFER[0][0];
	LCD_PIXELINDEX *Plcdbu = (LCD_PIXELINDEX *)&LCD_BUFER[0][0];

	if(x0 >(LCD_XSIZE-1))
	{
		x0 = (LCD_XSIZE-1);
	}
	if(y0 >(LCD_YSIZE-1))
	{
		y0 = (LCD_YSIZE-1);
	}
	if(xr >LCD_XSIZE)
	{
		xr = LCD_XSIZE-1;
	}
	if(yr >LCD_YSIZE)
	{
		yr = LCD_YSIZE-1;
	}
	if(x0 +xr >LCD_XSIZE)
	{
		xr = LCD_XSIZE -1 -x0;
	}
	if(y0 +yr >LCD_YSIZE)
	{
		yr = LCD_YSIZE -1 -y0;
	}

	if(xr==0 ||yr ==0)
	{      
		//Lcd_Dot(x0,y0,color);
		Plcdbu = DispBuf + (x0 + (LCD_XSIZE * y0));
		*Plcdbu = c;
	}
	else
	{
		for ( i=0; i < xr; i++)
		{
			tt = sqrt(((xr*xr)*(yr*yr)-(yr*yr)*(i*i))/(xr*xr));
			yy = GETDA(tt);
			if(x0+i <LCD_XSIZE && y0+yy <LCD_YSIZE)
			{
				//Lcd_Dot(x0+i,y0+yy,color);
				Plcdbu = DispBuf + ((x0+i) + (LCD_XSIZE * (y0+yy)));
				*Plcdbu = c;
			}
			if(x0-i >=0 && y0+yy <LCD_YSIZE)
			{
				//Lcd_Dot(x0-i,y0+yy,color);
				Plcdbu = DispBuf + ((x0-i) + (LCD_XSIZE * (y0+yy)));
				*Plcdbu = c;
			}
			if(x0+1 <LCD_XSIZE && y0-yy >=0)
			{
				//Lcd_Dot(x0+i,y0-yy,color);
				Plcdbu = DispBuf + ((x0+i) + (LCD_XSIZE * (y0-yy)));
				*Plcdbu = c;
			}
			if(x0-i >=0 && y0-yy >=0)
			{
				// Lcd_Dot(x0-i,y0-yy,color);
				Plcdbu = DispBuf + ((x0-i) + (LCD_XSIZE *(y0-yy)));
				*Plcdbu = c;
			}
		}
		for ( i=0; i < yr; i++)
		{
			tt = sqrt(((xr*xr)*(yr*yr)-(xr*xr)*(i*i))/(yr*yr));
			xx = GETDA(tt);
			if(x0+xx<LCD_XSIZE && y0+i<LCD_YSIZE)
			{
				//Lcd_Dot(x0+xx,y0+i,color);
				Plcdbu = DispBuf + ((x0+xx) + (LCD_XSIZE * (y0+i)));
				*Plcdbu = c;
			}
			if(x0+xx<LCD_XSIZE && y0-i>=0)
			{
				//Lcd_Dot(x0+xx,y0-i,color);
				Plcdbu = DispBuf + ((x0+xx) + (LCD_XSIZE * (y0-i)));
				*Plcdbu = c;
			}
			if(x0-xx>=0 && y0+i<LCD_YSIZE)
			{
				//Lcd_Dot(x0-xx,y0+i,color);
				Plcdbu = DispBuf + ((x0-xx) + (LCD_XSIZE * (y0+i)));
				*Plcdbu = c;
			}
			if(x0-xx>=0 && y0-i>=0)
			{
				//Lcd_Dot(x0-xx,y0-i,color);
				Plcdbu = DispBuf + ((x0-xx) + (LCD_XSIZE * (y0-i)));
				*Plcdbu = c;
			}
		}
	}
}


#endif

⌨️ 快捷键说明

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