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

📄 lcd.c

📁 三星4510 BOOTLOADER全部源代码
💻 C
字号:
//******************************************************
//Institute of Automation, Chinese Academy of Sciences.
//File Name:	LCD_Test.c
//Description: 	LCD Test
//Author:	JuGuang,Lee
//Date:		
//All Rights Reserved.
//******************************************************

//*****************************************************************************
//LCD模块的硬件地址由跳线JP200~JP203决定,以下地址对应于S3C4510B的nECS1;
//跳线JP201短接,如跳线改变,需要修改该地址,建议用户不要改变跳线的设置。
#define LCD_Base1_I	(*(volatile unsigned char *)0x03F00040) //LCD左半屏指令地址
#define LCD_Base1_D	(*(volatile unsigned char *)0x03F00042) //LCD左半屏数据地址
#define LCD_Base2_I	(*(volatile unsigned char *)0x03F00050) //LCD右半屏指令地址 
#define LCD_Base2_D	(*(volatile unsigned char *)0x03F00052) //LCD右半屏数据地址 
//*****************************************************************************
#include "uart.h"
#include"s3c4510b_add.h"

extern void LCD_Test(void);

static void Delay(unsigned int);
static void LCDInit(void);
static void LCDTest(unsigned char Data);
static void DispData(unsigned char);
static void SetPageAddress(unsigned char);
static void SetY(unsigned char);
static void DispChinese(unsigned char Data[],int Pos,int Line,int Index);


//*********************************************************
//函数名:	LCD_Test();
//描述:	循环显示汉字信息;
//参数:	无;
//返回值:	0;
//*********************************************************
void LCD_Test(void)
{
//*********************************************************
//以下为16×16点阵汉字字模
//*********************************************************
	
//空白
	unsigned char ChE[32]={0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
		     0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
//恒
	unsigned char Ch1[32]={0x80,0x70,0x00,0xff,0x10,0x22,0xF2,0x92,0x92,0x92,0x92,0x92,0x92,0xfb,0x12,0x00,
		   0x00,0x00,0x00,0xff,0x20,0x20,0x27,0x24,0x24,0x24,0x24,0x24,0x24,0x27,0x30,0x20};	
//颐
	unsigned char Ch2[32]={0x00,0x00,0xfe,0x2,0xe2,0x3e,0x23,0xe2,0x2,0xf2,0x1a,0x16,0xd2,0x12,0xfb,0x12,
		   0x00,0x00,0x7f,0x40,0x43,0x7e,0x42,0x43,0x80,0x5f,0x20,0x1c,0x23,0x20,0x5f,0xc0};	
//高
	unsigned char Ch3[32]={0x4,0x4,0x4,0xf4,0x94,0x94,0x95,0x96,0x94,0x94,0x94,0xf4,0x4,0x4,0x06,0x4,
		   0x00,0xfe,0x2,0x2,0x7a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x7a,0x2,0x82,0xff,0x02};
//科
	unsigned char Ch5[32]={0x24,0x24,0x24,0xa4,0xfe,0xa3,0x22,0x00,0x24,0x48,0x00,0xff,0x00,0x80,0x00,0x00,
		   0x10,0x08,0x06,0x01,0xff,0x00,0x01,0x02,0x02,0x02,0x02,0xff,0x01,0x01,0x01,0x00};
//技
	unsigned char Ch6[32]={0x10,0x10,0x10,0xff,0x10,0x10,0x88,0x88,0x88,0xff,0x88,0x88,0x8c,0x08,0x00,0x00,
		   0x04,0x44,0x82,0x7f,0x01,0x80,0x81,0x46,0x28,0x10,0x28,0x26,0x41,0xc0,0x40,0x00};
//与
	unsigned char Ch7[32]={0x00,0x00,0x00,0xff,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0xcc,0x88,0x00,0x00,
		   0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4c,0x88,0x40,0x3f,0x00,0x00,0x00};
//您
	unsigned char Ch8[32]={0x40,0x20,0x10,0xfc,0x23,0x10,0x8c,0x67,0x04,0x04,0xf4,0x04,0x44,0x94,0x8c,0x00,
		   0x40,0x30,0x00,0x77,0x80,0x81,0x88,0x92,0xb4,0x83,0x80,0xe0,0x00,0x11,0x60,0x00};
//共
	unsigned char Ch9[32]={0x0,0x10,0x10,0x10,0xff,0x10,0x10,0x10,0x10,0x10,0xff,0x10,0x10,0x18,0x10,0x0,
		   0x04,0x04,0x84,0x44,0x27,0x34,0x04,0x04,0x04,0x14,0x27,0x64,0xc4,0x06,0x04,0x00};
//创
	unsigned char Ch10[32]={0x80,0x40,0xf0,0x4c,0x43,0x44,0xc8,0x10,0x30,0x00,0xf8,0x00,0x00,0xff,0x00,0x00,
		   0x0,0x0,0x3f,0x40,0x42,0x44,0x43,0x70,0x0,0x00,0x7,0x40,0x80,0x7f,0x00,0x00};
//辉
	unsigned char Ch11[32]={0x44,0x48,0xd0,0x7f,0xd0,0x4c,0x48,0xa6,0x62,0x3a,0xa2,0x22,0x32,0x26,0x02,0x00,
		   0x40,0x30,0x0f,0x00,0x3f,0x10,0x08,0x09,0x09,0x09,0xff,0x09,0x09,0x0d,0x08,0x00};
//煌
	unsigned char Ch12[32]={0x80,0x70,0x00,0xff,0x10,0x08,0x7c,0x54,0x56,0x55,0x54,0x54,0x7e,0x04,0x00,0x00,
		   0x40,0x20,0x10,0x0f,0x50,0x61,0x49,0x49,0x49,0x7f,0x49,0x4d,0x49,0x61,0x40,0x00};
//!
	unsigned char Ch13[32]={0x0,0x0,0x00,0x0,0x0,0x0,0x1c,0xfe,0xfe,0x1c,0x00,0x00,0x00,0x0,0x00,0x00,
		   0x0,0x0,0x0,0x0,0x0,0x00,0x00,0x33,0x33,0x0,0x0,0x0,0x0,0x0,0x0,0x00};
		   
	unsigned int tmp;
	i_printf("\r\n\r\n\r\nLCD Test,Press any Key to Continue...\r\n\r\n");
	
	tmp=EXTDBWTH;
	EXTDBWTH=0x05503002;		//设置外部I/O Bank的数据总线宽度为8位;
	
	LCDInit(); 			//LCD初始化;
	while(1)
		{
		LCDTest(0x00);		//清屏
		Delay(0xffff);
		LCDTest(0xf0);
		Delay(0xffff);
		LCDTest(0xf);
		Delay(0xffff);
		if(kbd_hit())		//如有用户按键,则清屏后返回主程序;
			{
			LCDTest(0x00);
			EXTDBWTH=tmp;
			return;
			}
		DispChinese(ChE,0,0,0);	//第一行
		DispChinese(ChE,0,0,1);
		DispChinese(Ch1,0,0,2);	
		DispChinese(Ch2,0,0,3);
		
		DispChinese(Ch3,1,0,0);
		DispChinese(Ch5,1,0,1);
		DispChinese(ChE,1,0,2);
		DispChinese(ChE,1,0,3);
		
		DispChinese(ChE,0,1,0);	//第二行
		DispChinese(ChE,0,1,1);
		DispChinese(ChE,0,1,2);
		DispChinese(ChE,0,1,3);
		DispChinese(ChE,1,1,0);
		DispChinese(ChE,1,1,1);
		DispChinese(ChE,1,1,2);
		DispChinese(ChE,1,1,3);
		
		DispChinese(ChE,0,2,0);	//第三行
		DispChinese(Ch7,0,2,1);	
		DispChinese(Ch8,0,2,2);
		DispChinese(Ch9,0,2,3);
		DispChinese(Ch10,1,2,0);
		DispChinese(Ch11,1,2,1);
		DispChinese(Ch12,1,2,2);
		DispChinese(Ch13,1,2,3);
		
		DispChinese(ChE,0,3,0);	//第四行
		DispChinese(ChE,0,3,1);
		DispChinese(ChE,0,3,2);
		DispChinese(ChE,0,3,3);
		DispChinese(ChE,1,3,0);
		DispChinese(ChE,1,3,1);
		DispChinese(ChE,1,3,2);
		DispChinese(ChE,1,3,3);
		Delay(0xffffff);
		if(kbd_hit())		//如有用户按键,则清屏后返回主程序;
			{
			LCDTest(0x00);
			EXTDBWTH=tmp;
			return;
			}
		}
		
}

//*********************************************************
//函数名:	Delay();
//描述:	软件延时;
//参数:	延时时间;
//返回值:	无;
//*********************************************************
static void Delay(unsigned int x)
{
	int i,j;
	for(i=0;i<x;i++);
		for(j=0;j<0x20;j++);	
}

//*********************************************************
//函数名:	DispChinese();
//描述:	在LCD屏的某个位置显示一个16×16点阵的汉字;
//参数:	汉字字模;左右半屏选择;行信息;列信息
//返回值:	无;
//*********************************************************
static void DispChinese(unsigned char Data[],int Pos,int Line,int Index)
{
	int i;
	if(Pos==0)
		{SetPageAddress(0xB8+Line*2);
		SetY(0x40+16*Index);
		for(i=0;i<16;i++){
			LCD_Base1_D=Data[i];
			Delay(5000);
			}
	
		SetPageAddress(0xB9+Line*2);
		SetY(0x40+16*Index);
		for(i=16;i<32;i++){
			LCD_Base1_D=Data[i];
			Delay(5000);
			}
		}
	else
		{SetPageAddress(0xB8+Line*2);
		SetY(0x40+16*Index);
		for(i=0;i<16;i++){
			LCD_Base2_D=Data[i];
			Delay(5000);
			}
	
		SetPageAddress(0xB9+Line*2);
		SetY(0x40+16*Index);
		for(i=16;i<32;i++){
			LCD_Base2_D=Data[i];
			Delay(5000);
			}
		}

}

//*********************************************************
//函数名:	DispData();
//描述:	向显示缓冲区写入一个字符;
//参数:	写入的字符信息;
//返回值:	无;
//*********************************************************
static void DispData(unsigned char Data)
{
	int i;
	for(i=0;i<64;i++){
		LCD_Base1_D=Data;
		Delay(5000);
		LCD_Base2_D=Data;
		Delay(5000);
		}
}

//*********************************************************
//函数名:	LCDInit();
//描述:	初始化LCD显示屏;
//参数:	无;
//返回值:	无;
//*********************************************************
static void LCDInit()
{
//首先关闭左、右半屏		
	LCD_Base1_I=0x3E;
	Delay(5000);
	LCD_Base2_I=0x3E;
	Delay(5000);
//然后打开
	LCD_Base1_I=0x3F;
	Delay(5000);
	LCD_Base2_I=0x3F;
	Delay(5000);
//设置起始行数
	LCD_Base1_I=0xC0;
	Delay(5000);
	//BusyCheck();
	LCD_Base2_I=0xC0;
	Delay(5000);
	//BusyCheck();
//设置Y地址(Y=0)
	LCD_Base1_I=0x40;
	Delay(5000);
	//BusyCheck();
	LCD_Base2_I=0x40;
	Delay(5000);
	//BusyCheck();
	return;
}

//*********************************************************
//函数名:	LCDTest();
//描述:	向全屏发送同一个字符,用于测试;
//参数:	要发送的字符;
//返回值:	无;
//*********************************************************
static void LCDTest(unsigned char Data)
{
	int i;
	for(i=0;i<8;i++)
		{SetPageAddress(0xB8+i);
		DispData(Data);}

}

//*********************************************************
//函数名:	SetY();
//描述:	设置Y地址;
//参数:	Y地址信息;
//返回值:	无;
//*********************************************************
static void SetY(unsigned char YAddress)
{
	LCD_Base1_I=YAddress;
	Delay(5000);
	LCD_Base2_I=YAddress;
	Delay(5000);
}

//*********************************************************
//函数名:	SetPageAddress();
//描述:	设置页地址;
//参数:	页地址信息;
//返回值:	无;
//*********************************************************
static void SetPageAddress(unsigned char PageAddress)
{
	LCD_Base1_I=PageAddress;
	Delay(5000);
	LCD_Base2_I=PageAddress;
	Delay(5000);
}

⌨️ 快捷键说明

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