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

📄 44blcd.c

📁 《基于s3c44B0X嵌入式uCLinux系统原理及应用》李岩编的ppt
💻 C
字号:
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\lcdlib.h"
#include "..\inc\44blcd.h"

void PutPixelColor(U32 x,U32 y,U8 c);
void clrscreen(void);
void Lcd_Init(void);
U8 High_Low( U8 x );

unsigned int (*frameBuffer1)[SCR_XSIZE/32];
unsigned int (*frameBuffer4)[SCR_XSIZE/16];
unsigned int (*frameBuffer16)[SCR_XSIZE/8];
unsigned int (*frameBuffer256)[SCR_XSIZE/4];

#define frameBuffer   0xc400000
extern unsigned char *Buf;

void LcdInit(void)
{
   	Lcd_Init();
   	clrscreen();
}

void Lcd_Init(void)
{
//	if((U32)frameBuffer256==0)
//	{
	    frameBuffer256=(0xc400000); 
//	}
	rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
	    // disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
	rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21);  
	    //LINEBLANK=10 (without any calculation) 
	rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
	    // 256-color, LCDBANK, LCDBASEU
	rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
	rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );

	//The following value has to be changed for better display.
	rREDLUT  =0xfdb96420;
	rGREENLUT=0xfdb96420;
	rBLUELUT =0xfb40;

	rDITHMODE=0x0;
	rDP1_2 =0xa5a5;      
	rDP4_7 =0xba5da65;
	rDP3_5 =0xa5a5f;
	rDP2_3 =0xd6b;
	rDP5_7 =0xeb7b5ed;
	rDP3_4 =0x7dbe;
	rDP4_5 =0x7ebdf;
	rDP6_7 =0x7fdfbfe;

	rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
	    // enable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
}

void Lcd_C256_Bmp( U16 x0, U16 y0, U16 x1, U16 y1 , unsigned char bmp[] )
{
    int x, y ;
    int m = 0;
    
    for( y = y0; y < y1; y++ )		//画16色图片
    {
    	for( x = x0; x < x1; x++ )
    	{
    	    PutPixelColor( x, y, High_Low( bmp[m] ) );
    	    m++;
    	}
    }
}
void PutPixelColor(U32 x,U32 y,U8 c)
{
    if(x<SCR_XSIZE && y<SCR_YSIZE)
        frameBuffer256[(y)][(x)/4]=( frameBuffer256[(y)][x/4] & ~(0xff000000>>((x)%4)*8) )
            | ( (c)<<((4-1-((x)%4))*8) );
}

void clrscreen(void)
{
  	int i,j;
	unsigned int *pbuffer;

	pbuffer =(U32*) frameBuffer256;
 	for (i=0;i<19200;i++)
       {
     		pbuffer[i] =0;//(0x0FFFFFFFF);
   	}
}

U8 High_Low( U8 x )
{
	x = ( (x>>1)&0x1c ) | (x>>6) | (x<<5);
	return x ;
}








⌨️ 快捷键说明

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