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

📄 clcd.c

📁 这是三星公司的arm7 s3c44b0x芯片的所有外设中断程序
💻 C
字号:
//44BTEST : clcd.c
#include <string.h>
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\clcd.h"
#include "..\inc\def.h"
#include "..\inc\lcdlib.h"
void Lcd_PutPixel(int x,int y,U8 rgb);
void DrawLine(void);
//unsigned int (*frameBuffer256)[60]=(unsigned int (*)[60])0x0;
void Test_Clcd(void)
{
	int i,j;
	Uart_Printf("[(240x3)x320 COLOR STN LCD TEST]\n");
	Uart_Printf("1-1)COLOR BAR TEST\n");
	Uart_Printf(" R:0 ... 7 \n");
	Uart_Printf("G:0 B0:1 B0:1 B0:1 \n");
	Uart_Printf("G:. 2:3 2:3 2:3 \n");
	Uart_Printf("G:. B0:1 B0:1 B0:1 \n");
	Uart_Printf("G:. 2:3 2:3 2:3 \n");
	Uart_Printf("G:. B0:1 B0:1 B0:1 \n");
	Uart_Printf("G:7 2:3 2:3 2:3 \n");
	Clcd_Init();
	for(j=0;j<320;j++)
	{
		for(i=0;i<240;i++)
		{ //RRRGGGBB
			Lcd_PutPixel( i,j,(i/30<<5)+(j/40<<2)+((i/15)&0x1)+((j/20&0x1)<<1) );
		}
	}
	Uart_Printf("Press any key!!!\n");
	DrawLine();
	Uart_Getch();
}
void DrawLine(void)
{
	int x=0,y=0,xd=1,yd=1,count=0;
	while(Uart_GetKey()==0)
	{
		if(x==0)
			xd=1;
		if(x==240)
			xd=-1;
		if(y==0)
			yd=1;
		if(y==319)
			yd=-1;
		Lcd_PutPixel(x,y,0xff);
		x+=xd;
		y+=yd;
		Delay(100);
		if(count++==2000)
			break;
	}
}
void Lcd_PutPixel(int x,int y,U8 rgb)
{
	U32 mask[4]={0x00ffffff,0xff00ffff,0xffff00ff,0xffffff00};
	frameBuffer256[y][x/4]=(frameBuffer256[y][x/4] & mask[x%4]) | ( (U32)rgb<<(3-x%4)*8 );
}
void Clcd_Init(void)
{
	//Now, the dithering function doesn't operate. So, Only 3 levels(100%,50%,0%) are supported.
	//(240x3)x320 color STN LCD(8-bit interface)
	//frame rate =75Hz
	//MCLK=40Mhz
	if(frameBuffer256==0)
	{
//yaya		frameBuffer256=(unsigned int (*)[60])malloc(76800+16); //240x320
//yaya		frameBuffer256=(unsigned int (*)[60])( (((unsigned)frameBuffer256+15)>>4)<<4 );
		//rNCACHBE0=( ( ( ((unsigned)frameBuffer256+76800+16)>>12 )+1 )	<<16)|((unsigned)frameBuffer256>>12);
	}
	// 4bit single scan, VM=frame, WDLY=8clk, WLH=8clk CLKVAL=8->85.2Hz
	// 8-bit single scan,VM=each line, WDLY=6clk, WLH=6clk,
	// VCLK=2.3Mhz, CLKVAL=9 ->2.22Mhz
	rLCDCON1=(2<<5)|(1<<7)|(0x3<<8)|(0x3<<10)|((8)<<12);
	// LIVEVAL=320-1, HOZVAL=(240x3)/8-1=89, LINEBLANK=10, MODESEL=color
	rLCDCON2=(319)|(89<<10)|(10<<19)|(0x3<<30);
	rLCDSADDR1= ( ((unsigned int)frameBuffer256>>20)<<16 ) | ( (unsigned int)frameBuffer256>>4 );
	rLCDSADDR2= ( ((unsigned int)frameBuffer256+76800)>>4 )-1 |(35<<16);
	rREDLUT =0xfdb96420;
	rGREENLUT=0xfdb96420;
	rBLUELUT =0xfb40;
	/*
	rDP1_2 =0xa5a5;
	rDP4_7H=0x00b5a5a5;
	rDP4_7L=0xe;
	rDP3_5 =0x5a5be;
	rDP2_3 =0xd6b;
	rDP3_4 =0x7dbe;
	rDP5_7H=0x007be5db;
	rDP5_7L=0xe;
	rDP4_5 =0x7ebdf;
	rDP6_7H=0x007fdfbf;
	rDP6_7L=0xe;
	*/
	rLCDCON1=(2<<5)|(1<<7)|(0x2<<8)|(0x2<<10)|((8)<<12)|0x1;
}

⌨️ 快捷键说明

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